/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --primary:       #fbbb01;
  --primary-dark:  #e0a800;
  --primary-light: #fff8e1;
  --accent:        #fbbb01;
  --sidebar-bg:    #0d1b2a;
  --sidebar-bg2:   #162436;
  --text-dark:     #1a2332;
  --text-mid:      #4a5568;
  --text-light:    #8a9ab0;
  --surface:       #ffffff;
  --bg:            #f4f6f8;
  --border:        #e2e8f0;
  --sidebar-w:     340px;
  --radius:        12px;
  --shadow:        0 4px 24px rgba(0,0,0,0.08);
  --shadow-lg:     0 12px 40px rgba(0,0,0,0.14);
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: scroll;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.page-wrapper { display: flex; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(160deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  border-radius: 0 24px 24px 0;
}
.sidebar::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}
.sidebar::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}
.sidebar-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 2.5rem 2rem;
  gap: 2rem;
}

/* Logo */
.logo-block { display: flex; align-items: center; gap: 0.85rem; }
.logo-mark { width: 120px; flex-shrink: 0; }
.logo-img { width: 100%; height: auto; display: block; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.2)); }
.logo-text { display: flex; flex-direction: column; }
.logo-name {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem; font-weight: 700;
  color: #fff; letter-spacing: 0.05em; line-height: 1.1;
}
.logo-sub {
  font-size: 0.72rem; color: rgba(255,255,255,0.65);
  font-weight: 300; letter-spacing: 0.08em; text-transform: uppercase;
}

/* Copyright footer */
.sidebar-footer {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.38);
  line-height: 1.5;
  text-align: center;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-footer-link {
  color: rgba(251,187,1,0.75);
  text-decoration: none;
  transition: color 0.15s;
}
.sidebar-footer-link:hover { color: var(--primary); }

/* Title */
.sidebar-content { flex: 1; }
.sidebar-title {
  font-family: 'Fraunces', serif;
  font-size: 2rem; font-weight: 600;
  color: #fff; line-height: 1.2; margin-bottom: 1rem;
  text-wrap: balance;
}
.sidebar-title em { font-style: italic; font-weight: 300; color: rgba(255,255,255,0.85); }
.sidebar-desc {
  font-size: 0.87rem; color: rgba(255,255,255,0.72);
  line-height: 1.6; margin-bottom: 2rem;
}

/* Steps */
.sidebar-steps { display: flex; flex-direction: column; gap: 0.85rem; }
.step { display: flex; align-items: flex-start; gap: 0.75rem; }
.step-num {
  font-family: 'Fraunces', serif; font-size: 0.72rem; font-weight: 700;
  color: var(--accent); letter-spacing: 0.06em; padding-top: 0.1rem; flex-shrink: 0;
}
.step-text { font-size: 0.82rem; color: rgba(255,255,255,0.78); line-height: 1.4; }

/* Preview */
.sidebar-preview { margin-top: auto; }
.preview-label {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: rgba(255,255,255,0.45); margin-bottom: 0.5rem;
}
.preview-thumb-wrapper {
  border-radius: 8px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
  max-height: 160px; box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.preview-thumb { width: 100%; display: block; opacity: 0.85; transition: opacity 0.3s; }
.preview-thumb:hover { opacity: 1; }

/* ─── Background Aleatorio ────────────────────────────────────────────── */
.bg-random {
  position: fixed;
  inset: 0 0 0 var(--sidebar-w);
  z-index: 0;
  background-size: cover;
  background-position: center;
}
.bg-random-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ─── Main Content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 3rem 2.5rem;
  display: flex; justify-content: center;
  position: relative; z-index: 1;
}
.form-container {
  width: 100%; max-width: 680px;
  display: flex; flex-direction: column; gap: 1.5rem;
  animation: fadeUp 0.5s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Form Cards ─────────────────────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: fadeUp 0.4s ease both;
}
.form-card:nth-child(1) { animation-delay: 0.05s; }
.form-card:nth-child(2) { animation-delay: 0.10s; }
.form-card:nth-child(3) { animation-delay: 0.15s; }
.form-card:nth-child(4) { animation-delay: 0.20s; }

.form-card-header {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(90deg, #fffbea, #fff);
  border-bottom: 1px solid var(--border);
}
.card-icon { font-size: 1rem; line-height: 1; color: var(--sidebar-bg); }
.card-title {
  font-family: 'Fraunces', serif;
  font-size: 0.95rem; font-weight: 600;
  color: var(--sidebar-bg); letter-spacing: 0.01em;
  text-wrap: balance;
  min-width: 0;
}
.card-fields {
  padding: 1.25rem 1.5rem;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
}

/* ─── Form Groups ────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-group label {
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-mid); letter-spacing: 0.03em; text-transform: uppercase;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-dark); background: #fafcfe;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.form-group input:focus-visible,
.form-group textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(251,187,1,0.18);
}
.form-group textarea { resize: vertical; }

/* span full width */
.form-group--full,
.form-group--checkbox { grid-column: 1 / -1; }

/* ─── Checkboxes ─────────────────────────────────────────────────────────── */
.form-group--checkbox { flex-direction: row; align-items: flex-start; }
.checkbox-label {
  display: flex; align-items: flex-start; gap: 0.65rem;
  cursor: pointer; font-size: 0.88rem; color: var(--text-dark);
  line-height: 1.4; padding: 0.2rem 0; transition: color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.checkbox-label:hover { color: var(--primary-dark); }
.custom-checkbox {
  position: relative; flex-shrink: 0;
  width: 18px; height: 18px; margin-top: 0.1rem;
}
.custom-checkbox input[type="checkbox"] {
  position: absolute; opacity: 0;
  width: 100%; height: 100%; cursor: pointer; margin: 0;
}
.checkmark {
  position: absolute; inset: 0;
  border: 2px solid var(--border); border-radius: 4px;
  background: #fafcfe; transition: border-color 0.15s, background 0.15s;
  pointer-events: none;
}
.checkmark::after {
  content: '';
  position: absolute;
  top: 2px; left: 5px;
  width: 5px; height: 9px;
  border: 2px solid #fff;
  border-top: 0; border-left: 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s;
}
.custom-checkbox input:checked ~ .checkmark {
  background: var(--sidebar-bg); border-color: var(--sidebar-bg);
}
.custom-checkbox input:checked ~ .checkmark::after {
  transform: rotate(45deg) scale(1);
}
.custom-checkbox input:focus ~ .checkmark {
  box-shadow: 0 0 0 3px rgba(251,187,1,0.3);
}

/* ─── Radio Buttons ──────────────────────────────────────────────────────── */
.custom-radio {
  position: relative; flex-shrink: 0;
  width: 18px; height: 18px; margin-top: 0.1rem;
}
.custom-radio input[type="radio"] {
  position: absolute; opacity: 0;
  width: 100%; height: 100%; cursor: pointer; margin: 0;
}
.radiomark {
  position: absolute; inset: 0;
  border: 2px solid var(--border); border-radius: 50%;
  background: #fafcfe; transition: border-color 0.15s, background 0.15s;
  pointer-events: none;
}
.radiomark::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 8px;
  background: #fff; border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s;
}
.custom-radio input:checked ~ .radiomark {
  background: var(--sidebar-bg); border-color: var(--sidebar-bg);
}
.custom-radio input:checked ~ .radiomark::after {
  transform: translate(-50%, -50%) scale(1);
}
.custom-radio input:focus ~ .radiomark {
  box-shadow: 0 0 0 3px rgba(251,187,1,0.3);
}

/* ─── Validation ─────────────────────────────────────────────────────────── */
.required-mark {
  color: #e53e3e;
  margin-left: 0.2em;
  font-weight: 700;
}
.form-error {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fff5f5;
  border: 1.5px solid #fc8181;
  border-radius: 8px;
  color: #c53030;
  font-size: 0.875rem;
  font-weight: 500;
}
.form-error[hidden] { display: none; }
.form-group input:user-invalid,
.form-group textarea:user-invalid {
  border-color: #fc8181;
  background: #fff5f5;
}

/* ─── Submit Button ──────────────────────────────────────────────────────── */
.btn-generate {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  width: 100%; padding: 1rem 2rem;
  background: var(--accent);
  color: var(--sidebar-bg); border: none; border-radius: var(--radius);
  font-size: 1rem; font-family: 'DM Sans', sans-serif;
  font-weight: 700; letter-spacing: 0.02em; cursor: pointer;
  position: relative; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(251,187,1,0.40);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-generate::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,0); transition: background 0.2s;
}
.btn-generate:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(251,187,1,0.55); }
.btn-generate:hover::before { background: rgba(255,255,255,0.07); }
.btn-generate:active { transform: translateY(0); }
.btn-generate:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.btn-text, .btn-loading { display: flex; align-items: center; gap: 0.6rem; }
.btn-loading[hidden], .btn-text[hidden] { display: none; }
.spin { animation: spinner 0.8s linear infinite; }
@keyframes spinner { to { transform: rotate(360deg); } }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
/* Tablet: sidebar collapses to compact top bar */
@media (max-width: 900px) {
  .page-wrapper { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto;
    position: static; overflow: visible;
  }
  .sidebar::before, .sidebar::after { display: none; }
  .sidebar-inner {
    flex-direction: row; align-items: center;
    padding: 0.875rem 1.5rem; gap: 1.25rem; flex-wrap: nowrap;
  }
  .sidebar-content, .sidebar-preview, .sidebar-steps, .sidebar-desc { display: none; }
  .logo-mark { width: 90px; }
  .main-content { padding: 2rem 1.5rem; }
  .form-container { max-width: 100%; }
  .bg-random { inset: 0; }
}
/* Mobile: single column, tighter spacing */
@media (max-width: 600px) {
  .sidebar-inner { padding: 0.75rem 1rem; }
  .logo-mark { width: 72px; }
  .main-content { padding: 1rem 0.75rem; }
  .card-fields {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 0.85rem;
  }
  .form-card-header { padding: 0.85rem 1rem; }
  .form-group { grid-column: 1 / -1; }
  .card-title { font-size: 0.88rem; }
  .form-container { gap: 1rem; }
}
/* ─── Reduced Motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* ─── Skip Link ──────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute; top: -100%; left: 1rem;
  background: var(--sidebar-bg); color: var(--accent);
  padding: 0.6rem 1.2rem;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 0.875rem; font-weight: 600; z-index: 9999;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus-visible { top: 0; }
/* ─── Scroll anchors ─────────────────────────────────────────────────────── */
.form-card { scroll-margin-top: 1rem; }
