/* ============================================================
   BASE
   ============================================================ */
[hidden] { display: none !important; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__inner {
  max-width: 1500px;
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header__logo {
  width: 34px;
  height: 34px;
  background: var(--gradient-primary);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-primary);
}

.header__name {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-strong);
  letter-spacing: var(--tracking-tight);
}

.header__tagline {
  font-size: var(--text-xs);
  color: var(--text-light);
  display: none;
  margin-left: var(--space-3);
  padding-left: var(--space-3);
  border-left: 1px solid var(--border);
}

@media (min-width: 768px) {
  .header__tagline { display: block; }
}

.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header__badge {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid var(--primary-muted);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-layout {
  flex: 1;
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Form Panel (sidebar) --- */
.panel--form {
  width: var(--panel-form-w);
  min-width: var(--panel-form-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  /* Reserva o espaço da barra de rolagem permanentemente: assim, quando o
     scrollbar aparece/some durante o loading, a largura interna não muda e os
     campos não "tremem" lateralmente. Fallback abaixo para navegadores antigos. */
  scrollbar-gutter: stable;
  box-shadow: 1px 0 0 rgba(16,24,40,.02), 4px 0 16px rgba(16,24,40,.03);
  position: relative;
  z-index: 5;
}

/* Fallback p/ navegadores sem suporte a scrollbar-gutter (Safari < 16):
   mantém a barra sempre visível, evitando o reflow horizontal. */
@supports not (scrollbar-gutter: stable) {
  .panel--form { overflow-y: scroll; }
}

/* --- Preview Panel --- */
.panel--preview {
  flex: 1;
  background: var(--surface);
  overflow: hidden;
  position: relative;
}

/* ============================================================
   PANEL HEADER + PROGRESS
   ============================================================ */
.panel__header {
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border-soft);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.panel__header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.panel__title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text);
  letter-spacing: -0.2px;
}

.editing-badge {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: #92400E;
  background: var(--warning-light);
  border: 1px solid #FDE68A;
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  white-space: nowrap;
  animation: fadeIn 0.25s ease;
}

/* Progress bar */
.form-progress {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-progress__track {
  height: 6px;
  background: var(--surface-deep);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.form-progress__fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.form-progress__fill.is-complete {
  background: var(--success);
}

.form-progress__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

/* ============================================================
   DEMO BANNER
   ============================================================ */
.demo-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-4) var(--space-5) 0;
  padding: var(--space-3) var(--space-4);
  background: var(--warning-light);
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  animation: fadeIn 0.25s ease;
}

.demo-banner__text {
  font-size: var(--text-xs);
  color: #92400E;
  line-height: 1.45;
}

.demo-banner__text strong {
  font-weight: var(--font-semibold);
}

.demo-banner__clear {
  flex-shrink: 0;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: #92400E;
  background: transparent;
  border: 1px solid #F0C24B;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
  transition: background 0.15s;
}

.demo-banner__clear:hover {
  background: #FDE68A;
}

/* ============================================================
   QUICK TEMPLATES
   ============================================================ */
.templates-block {
  padding: var(--space-4) var(--space-5) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.templates-block__label {
  font-size: 0.72rem;
  font-weight: var(--font-semibold);
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.templates-block__pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.template-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}

.template-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.template-pill.is-active {
  background:
    linear-gradient(var(--primary-light), var(--primary-light)) padding-box,
    var(--gradient-brand) border-box;
  border-color: transparent;
  color: var(--purple);
  font-weight: var(--font-semibold);
}

/* Example card */
.example-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.example-card__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.example-card__title {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.example-card__text {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Field flash — applied when a template fills a field */
@keyframes fieldFlash {
  0%   { background-color: #FEF3C7; border-color: var(--warning); }
  100% { background-color: var(--card); }
}

.field-flash {
  animation: fieldFlash 0.4s ease-out;
}

/* ============================================================
   BRANDING — logo upload, accent color, cover styles
   ============================================================ */
.logo-upload {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.logo-upload__preview {
  width: 110px;
  height: 52px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.logo-upload__preview span {
  font-size: var(--text-xs);
  color: var(--text-light);
}

.logo-upload__preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.logo-upload__preview.has-logo {
  border-style: solid;
  background: var(--card);
}

.logo-upload__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.logo-upload__btn { cursor: pointer; }

.accent-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.color-swatches {
  display: flex;
  gap: var(--space-2);
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.7);
  transition: transform 0.12s, border-color 0.15s;
}

.color-swatch:hover { transform: scale(1.12); }

.color-swatch.is-active {
  border-color: var(--text);
  transform: scale(1.12);
}

.accent-picker {
  width: 36px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--card);
}

/* Cover style selector — mini thumbnails */
.cover-styles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.cover-style-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cover-style-option:hover { border-color: var(--primary); }

.cover-style-option.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.cover-style-option__label {
  font-size: 0.68rem;
  font-weight: var(--font-medium);
  color: var(--text-muted);
}

.cover-style-option.is-active .cover-style-option__label {
  color: var(--primary);
  font-weight: var(--font-semibold);
}

/* Thumbnails (pure CSS mini covers) */
.cover-thumb {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: block;
}

.ct-strip {
  position: absolute; top: 0; left: 0; right: 0; height: 6%;
  background: var(--primary);
}

.ct-band {
  position: absolute; top: 0; left: 0; right: 0; height: 48%;
  background: var(--primary);
}

.ct-diagonal {
  position: absolute; top: -28%; left: -20%; width: 150%; height: 75%;
  background: var(--primary);
  transform: rotate(-9deg);
}

.ct-title {
  position: absolute; top: 32%; left: 12%; width: 55%; height: 7%;
  background: var(--text);
  border-radius: 2px;
  opacity: 0.85;
}

.ct-line {
  position: absolute; left: 12%; width: 60%; height: 4%;
  background: var(--surface-deep);
  border-radius: 2px;
}

.cover-thumb--minimal  .ct-line { top: 48%; }
.cover-thumb--minimal  .ct-line--short { top: 58%; width: 38%; }
.cover-thumb--corporate .ct-line { top: 60%; }
.cover-thumb--corporate .ct-line--short { top: 70%; width: 38%; }
.cover-thumb--creative .ct-line { top: 60%; }
.cover-thumb--creative .ct-line--short { top: 70%; width: 38%; }

/* ============================================================
   FORM
   ============================================================ */
.form {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ── Collapsible cards ── */
.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.form-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #D8DCE3;
}

.form-card__header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  background: transparent;
  cursor: pointer;
  text-align: left;
  user-select: none;
}

.form-card__icon {
  font-size: 1rem;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.form-card__title {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text);
  letter-spacing: -0.1px;
}

.form-card__optional {
  font-size: 0.65rem;
  font-weight: var(--font-medium);
  color: var(--text-light);
  background: var(--surface);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-card__check {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--success-light);
  color: var(--success);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.form-card__chevron {
  color: var(--text-light);
  display: flex;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.form-card.is-open .form-card__chevron {
  transform: rotate(180deg);
}

/* Body: collapsed by default, expanded via grid-rows trick */
.form-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: 0 var(--space-4);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.25s ease,
              padding 0.3s ease;
}

.form-card.is-open .form-card__body {
  max-height: 1200px;
  opacity: 1;
  padding: var(--space-1) var(--space-4) var(--space-5);
}

/* ── Fields ── */
.form__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form__label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text);
}

.required {
  color: var(--error);
}

.form__input,
.form__select,
.form__textarea {
  width: 100%;
  padding: var(--space-3) var(--space-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--card);
  transition: border-color 0.15s, box-shadow 0.2s;
  outline: none;
}

.form__input::placeholder,
.form__textarea::placeholder {
  color: #C3C8D1;
}

.form__input:focus,
.form__select:focus,
.form__textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.14);
}

.form__input--error,
.form__select--error {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px var(--error-light) !important;
}

.form__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form__textarea {
  resize: vertical;
  min-height: 80px;
}

.form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.form__hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: var(--space-1);
}

/* Checkbox */
.form__field--checkbox {
  flex-direction: row;
  align-items: center;
  padding: var(--space-1) 0;
}

.form__checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}

.form__checkbox {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.form__checkbox-text {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
}

.form__checkbox:checked + .form__checkbox-text {
  color: var(--primary);
}

/* Conditional field (Empresa) — smooth show/hide */
.form__field--collapsible {
  transition: opacity 0.25s ease, max-height 0.3s ease;
  max-height: 120px;
  opacity: 1;
  overflow: hidden;
}

.form__field--collapsible.is-hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Deadline / Value rows */
.form__row--deadline { grid-template-columns: 1fr 1fr; }
.form__row--value    { grid-template-columns: 2fr 1fr; }

#deadline_value::-webkit-outer-spin-button,
#deadline_value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#deadline_value { -moz-appearance: textfield; }

/* ── Sticky footer with generate button ── */
.form__sticky-footer {
  position: sticky;
  bottom: 0;
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(to top, var(--card) 75%, rgba(255,255,255,0));
  border-top: 1px solid var(--border-soft);
  z-index: 10;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
  cursor: pointer;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn--primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.btn--outline {
  background: var(--card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn--outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn--ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary-muted);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--primary);
}

.btn--sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  gap: 6px;
}

.btn--full {
  width: 100%;
  padding: var(--space-4);
  font-size: var(--text-base);
}

/* Generate button — the hero of the sidebar */
.btn--generate {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: var(--shadow-glow);
  font-weight: var(--font-bold);
  letter-spacing: 0.1px;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-fast), box-shadow var(--t-fast), filter var(--t-fast);
}

.btn--generate:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow: 0 12px 48px -8px rgba(124, 58, 237, 0.4);
  filter: brightness(1.04);
}

.btn--generate .btn__icon {
  transition: transform 0.2s ease;
}

.btn--generate:hover:not(:disabled) .btn__icon {
  transform: scale(1.15) rotate(-8deg);
}

.btn--generate.is-loading .btn__icon {
  animation: pulse-icon 0.9s ease-in-out infinite;
}

@keyframes pulse-icon {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.6; }
}

.btn__icon {
  font-size: 1rem;
}

/* ============================================================
   PREVIEW — EMPTY STATE
   ============================================================ */
.preview-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--space-8);
}

.preview-empty__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-5);
  max-width: 420px;
  animation: fadeIn 0.4s ease;
}

/* Mini document thumbnail */
.preview-empty__thumb {
  filter: drop-shadow(0 12px 24px rgba(16,24,40,.10));
}

.thumb-doc {
  width: 150px;
  background: var(--card);
  border-radius: 10px;
  padding: 0 0 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 9px;
  border: 1px solid var(--border-soft);
  transform: rotate(-2deg);
  transition: transform 0.3s ease;
}

.preview-empty__inner:hover .thumb-doc {
  transform: rotate(0deg) translateY(-3px);
}

.thumb-doc__banner {
  height: 34px;
  background: var(--gradient-primary);
  margin-bottom: 6px;
}

.thumb-doc__line {
  height: 6px;
  background: var(--surface-deep);
  border-radius: 3px;
  margin: 0 16px;
}

.thumb-doc__line--title {
  width: 60%;
  height: 8px;
  background: var(--primary-muted);
}

.thumb-doc__line--short { width: 45%; }

.thumb-doc__block {
  height: 26px;
  background: var(--primary-light);
  border-radius: 4px;
  margin: 2px 16px;
}

.preview-empty__title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text);
  letter-spacing: -0.3px;
}

.preview-empty__text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.6;
}

.preview-empty__benefits {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}

.benefit-chip {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  background: var(--card);
  border: 1px solid var(--border);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   PREVIEW — LOADING (skeleton)
   ============================================================ */
.preview-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  height: 100%;
  padding: var(--space-8);
}

.skeleton-doc {
  width: min(480px, 100%);
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 0 0 var(--space-6);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  box-shadow: var(--shadow-md);
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-deep) 25%, #F5F6F9 50%, var(--surface-deep) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
  margin: 0 var(--space-6);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton--banner {
  height: 64px;
  margin: 0 0 var(--space-3);
  border-radius: 0;
  background: linear-gradient(90deg, var(--primary-muted) 25%, var(--primary-light) 50%, var(--primary-muted) 75%);
  background-size: 200% 100%;
}

.skeleton--line  { height: 10px; }
.skeleton--w60   { width: 60%; }
.skeleton--w80   { width: 80%; }
.skeleton--block { height: 48px; }

.preview-loading__text {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.writing-dots::after {
  content: '';
  animation: dots 1.4s steps(4, end) infinite;
}

@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
}

/* ============================================================
   PREVIEW — ERROR
   ============================================================ */
.preview-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  text-align: center;
  padding: var(--space-8);
  height: 100%;
}

.preview-error__icon { font-size: 2.5rem; }
.preview-error h3 { color: var(--error); font-size: var(--text-lg); }
.preview-error p  { color: var(--text-muted); font-size: var(--text-sm); }

/* ============================================================
   PREVIEW CONTENT
   ============================================================ */
.preview-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-6);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(16,24,40,.04);
  gap: var(--space-4);
  flex-shrink: 0;
  position: relative;
  z-index: 3;
}

.preview-toolbar__info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.preview-toolbar__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.proposal-badge {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--primary);
  background: var(--primary-light);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  letter-spacing: 0.4px;
}

.preview-document {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-8);
  background: var(--surface);
}

/* ============================================================
   DOCUMENT STYLES (rendered proposal)
   ============================================================ */
.doc-cover {
  background: var(--card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-8);
}

.doc-cover__header {
  background: var(--gradient-primary);
  padding: var(--space-10) var(--space-8);
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Subtle geometric accent on the banner */
.doc-cover__header::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -40px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}

.doc-cover__header::after {
  content: '';
  position: absolute;
  bottom: -80px;
  left: -50px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

.doc-cover__logo {
  position: absolute;
  top: var(--space-4);
  left: var(--space-5);
  max-height: 34px;
  max-width: 130px;
  object-fit: contain;
  z-index: 2;
  background: rgba(255,255,255,0.92);
  border-radius: 6px;
  padding: 3px 6px;
}

.doc-cover__title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: #fff;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-3);
  position: relative;
  z-index: 1;
}

.doc-cover__service {
  font-size: var(--text-lg);
  font-weight: var(--font-normal);
  color: rgba(255,255,255,0.85);
  position: relative;
  z-index: 1;
}

.doc-cover__info {
  padding: var(--space-6) var(--space-8);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.doc-cover__client {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.doc-cover__label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.doc-cover__value {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text);
}

.doc-cover__company {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.doc-cover__doc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.doc-cover__address {
  font-size: var(--text-xs);
  color: var(--text-light);
  line-height: 1.5;
  margin-top: var(--space-1);
}

.doc-cover__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

.doc-cover__number {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--primary);
}

.doc-cover__date {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.doc-cover__by {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.doc-cover__by-name {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.doc-cover__by-role {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.doc-cover__by-company {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--primary);
}

.doc-cover__contact-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-3) var(--space-8);
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Sections */
.doc-sections {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.doc-section {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.doc-section__title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--primary);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--primary-light);
  background: var(--primary-light);
}

.doc-section__content {
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.doc-section__content p {
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text);
  text-align: justify;
}

/* Table */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin: var(--space-1) 0;
}

.doc-table th {
  background: var(--primary);
  color: #fff;
  font-weight: var(--font-semibold);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  letter-spacing: 0.3px;
}

.doc-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.doc-table tr:last-child td { border-bottom: none; }
.doc-table tr:nth-child(even) td { background: var(--surface); }

/* List */
.doc-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-left: var(--space-2);
}

.doc-list li {
  font-size: var(--text-sm);
  color: var(--text);
  line-height: 1.6;
  padding-left: var(--space-4);
  position: relative;
}

.doc-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: var(--font-bold);
}

/* Blockquote / note */
blockquote.doc-note {
  border-left: 3px solid var(--primary);
  background: var(--primary-light);
  padding: var(--space-3) var(--space-4);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================================
   ACCEPTANCE TERM
   ============================================================ */
.doc-acceptance-term {
  border: 1.5px solid var(--primary-light);
  border-radius: var(--radius);
  background: var(--primary-light);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
}

.doc-acceptance-term strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--primary);
  margin-bottom: var(--space-2);
  letter-spacing: 0.3px;
}

.doc-acceptance-term p {
  font-size: var(--text-sm);
  color: var(--text);
  line-height: 1.6;
}

/* ============================================================
   DUAL SIGNATURE BLOCK (flat 3-row grid)
   ============================================================ */
.doc-sign {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  column-gap: var(--space-8);
  row-gap: 0;
  margin-top: var(--space-4);
}

.doc-sign__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-height: 72px;
  padding-bottom: var(--space-5);
  align-self: end;
}

.doc-sign__name {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.doc-sign__role {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.doc-sign__line {
  height: 1px;
  background: var(--text);
  opacity: 0.35;
  margin-top: var(--space-1);
  margin-bottom: var(--space-2);
  align-self: center;
}

.doc-sign__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

.doc-sign__date {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-5);
  font-style: italic;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: #fff;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast--success { background: var(--success); }
.toast--error   { background: var(--error); }
.toast--info    { background: var(--primary); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
    height: auto;
    overflow: auto;
  }

  .panel--form {
    width: 100%;
    min-width: unset;
    max-height: none;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .panel--preview {
    min-height: 600px;
    overflow: auto;
  }

  .preview-content { height: auto; }
  .preview-document { overflow: visible; }

  .form__sticky-footer {
    position: sticky;
    bottom: 0;
  }
}

@media (max-width: 480px) {
  .form__row { grid-template-columns: 1fr; }

  .preview-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .preview-toolbar__actions {
    width: 100%;
  }

  .preview-toolbar__actions .btn {
    flex: 1;
    justify-content: center;
  }

  .doc-cover__info {
    flex-direction: column;
    align-items: flex-start;
  }

  .doc-cover__meta { align-items: flex-start; }

  .preview-document { padding: var(--space-4); }
}
