/* ==========================================================================
   CERFA 11527*03 Form Filler - Modern French Administration Stylesheet
   ========================================================================== */

:root {
  /* French Republic Palette */
  --color-marianne-blue: #000091;
  --color-marianne-blue-hover: #1212ff;
  --color-marianne-blue-dark: #000074;
  --color-marianne-red: #e1000f;
  --color-republic-navy: #0f1e36;
  --color-republic-accent: #2b5797;
  
  /* Neutral Slate Palette */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-light: #e2e8f0;
  --border-focus: #000091;
  
  /* Text Colors */
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --text-inverse: #ffffff;

  /* State Colors */
  --success: #059669;
  --success-hover: #047857;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fef3c7;
  --danger: #dc2626;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-handwriting: 'Caveat', cursive, sans-serif;

  /* Shadows & Elevation */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-card: 0 12px 32px -4px rgba(15, 30, 54, 0.08);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Tricolor Top Bar */
.french-banner {
  height: 4px;
  background: linear-gradient(to right, #0026e9 0%, #0026e9 33.33%, #ffffff 33.33%, #ffffff 66.66%, #ed2939 66.66%, #ed2939 100%);
  width: 100%;
}

/* App Header */
.app-header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.marianne-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.marianne-flag {
  display: inline-block;
  width: 16px;
  height: 28px;
  background: linear-gradient(to right, #000091 33%, #ffffff 33%, #ffffff 66%, #e1000f 66%);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 2px;
}

.marianne-text {
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--republic-navy);
}

.marianne-text strong {
  font-weight: 800;
  letter-spacing: 0.04em;
  display: block;
}

.marianne-text small {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.brand-divider {
  width: 1px;
  height: 36px;
  background-color: var(--border-light);
}

.brand-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--republic-navy);
  letter-spacing: -0.01em;
}

.cerfa-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  margin-top: 0.125rem;
}

.cerfa-number {
  background: #eff6ff;
  color: var(--color-marianne-blue);
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid #bfdbfe;
}

.legal-articles {
  color: var(--text-subtle);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Privacy Notice Banner */
.privacy-notice {
  background: linear-gradient(90deg, #f0fdf4 0%, #ecfdf5 100%);
  border-bottom: 1px solid #bbf7d0;
  padding: 0.625rem 1.5rem;
}

.notice-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: #166534;
}

.notice-content svg {
  flex-shrink: 0;
  color: var(--success);
}

/* Main Layout Grid */
.app-main {
  max-width: 1400px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr 490px;
  gap: 1.75rem;
  flex: 1;
}

/* Form Container */
.form-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-card);
  padding: 1.75rem 2rem;
}

/* Step Navigation Bar */
.step-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 2rem;
  background-color: var(--bg-subtle);
  padding: 0.375rem;
  border-radius: var(--radius-md);
}

.step-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.step-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.7);
}

.step-btn.active {
  background: var(--bg-card);
  color: var(--color-marianne-blue);
  box-shadow: var(--shadow-sm);
}

.step-num {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--border-light);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.step-btn.active .step-num {
  background: var(--color-marianne-blue);
  color: var(--text-inverse);
}

/* Step Fieldset */
.form-step {
  display: none;
  border: none;
  animation: fadeIn 0.3s ease;
}

.form-step.active {
  display: block;
}

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

.step-title {
  margin-bottom: 1.5rem;
  width: 100%;
}

.badge-step {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-marianne-blue);
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.375rem;
}

.step-title h2 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--republic-navy);
}

.step-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Form Groups & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-row.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label, .group-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.375rem;
}

.required {
  color: var(--color-marianne-red);
}

input[type="text"],
input[type="date"],
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  background-color: var(--bg-input);
  color: var(--text-main);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"]:hover,
input[type="date"]:hover,
textarea:hover {
  border-color: #cbd5e1;
}

input[type="text"]:focus,
input[type="date"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0, 0, 145, 0.12);
}

input[uppercase] {
  text-transform: uppercase;
}

.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-top: 0.25rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.375rem;
}

.char-counter {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* Radio Custom Cards */
.radio-inline {
  display: flex;
  gap: 1rem;
}

.radio-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-card);
  font-size: 0.875rem;
  font-weight: 500;
}

.radio-card:hover {
  border-color: #94a3b8;
  background: var(--bg-subtle);
}

.radio-card input[type="radio"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #94a3b8;
  border-radius: 50%;
  margin: 0;
  display: grid;
  place-content: center;
  transition: all var(--transition-fast);
}

.radio-card input[type="radio"]::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: scale(0);
  transition: transform var(--transition-fast);
  box-shadow: inset 1em 1em var(--color-marianne-blue);
}

.radio-card input[type="radio"]:checked {
  border-color: var(--color-marianne-blue);
}

.radio-card input[type="radio"]:checked::before {
  transform: scale(1);
}

.radio-card:has(input:checked) {
  border-color: var(--color-marianne-blue);
  background: #f8faff;
  box-shadow: 0 0 0 1px var(--color-marianne-blue);
}

/* Callouts & Notices */
.info-box, .warning-box, .penal-notice, .attachment-reminder {
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  font-size: 0.875rem;
  line-height: 1.45;
}

.info-box {
  background: #f0f7ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
}

.warning-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.penal-notice {
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  color: #991b1b;
  flex-direction: column;
  gap: 0.5rem;
}

.penal-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
}

.penal-notice blockquote {
  font-style: italic;
  font-weight: 600;
  background: #ffffff;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--color-marianne-red);
  border-radius: var(--radius-sm);
  color: #7f1d1d;
}

.attachment-reminder {
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  color: var(--text-muted);
}

.attachment-reminder strong {
  color: var(--republic-navy);
}

/* Choice Cards (Signature Mode) */
.choice-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.choice-card {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1rem;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--bg-card);
  transition: all var(--transition-fast);
}

.choice-card input[type="radio"] {
  margin-top: 0.25rem;
}

.choice-card:hover {
  border-color: #94a3b8;
}

.choice-card:has(input:checked) {
  border-color: var(--color-marianne-blue);
  background: #f8faff;
  box-shadow: 0 0 0 1px var(--color-marianne-blue);
}

.choice-card .card-body strong {
  display: block;
  font-size: 0.9375rem;
  color: var(--republic-navy);
  margin-bottom: 0.25rem;
}

.choice-card .card-body p {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Signature Canvas */
.signature-section {
  margin-top: 1.25rem;
  margin-bottom: 1.5rem;
}

.canvas-wrapper {
  position: relative;
  background: #ffffff;
  border: 1.5px dashed #94a3b8;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
}

#signatureCanvas {
  display: block;
  width: 100%;
  height: 140px;
  cursor: crosshair;
  background: #ffffff;
}

.btn-clear-sig {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-light);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-clear-sig:hover {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

/* Attestation Honor Box */
.attestation-honor-box {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-light);
}

.attestation-honor-box h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--republic-navy);
  margin-bottom: 0.5rem;
}

.attestation-honor-box p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Step Navigation Buttons */
.step-nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-light);
  gap: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
}

.btn-lg {
  font-size: 0.9375rem;
  padding: 0.75rem 1.375rem;
  font-weight: 700;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--color-marianne-blue);
  color: var(--text-inverse);
  box-shadow: 0 2px 4px rgba(0, 0, 145, 0.2);
}

.btn-primary:hover {
  background-color: var(--color-marianne-blue-hover);
  box-shadow: 0 4px 8px rgba(0, 0, 145, 0.25);
  transform: translateY(-1px);
}

.btn-success {
  background-color: var(--success);
  color: var(--text-inverse);
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
  background-color: var(--success-hover);
  box-shadow: 0 4px 8px rgba(5, 150, 105, 0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-card);
  border-color: var(--border-light);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: #cbd5e1;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

/* Right Column: Preview Sticky Panel */
.preview-panel {
  position: relative;
}

.preview-sticky-card {
  position: sticky;
  top: 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-card);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.preview-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--republic-navy);
}

.preview-title h3 {
  font-size: 0.9375rem;
  font-weight: 700;
}

.page-pills {
  display: flex;
  gap: 0.25rem;
}

.page-pill {
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-pill:hover {
  border-color: #cbd5e1;
  color: var(--text-main);
}

.page-pill.active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--color-marianne-blue);
  font-weight: 700;
}

.preview-frame-container {
  position: relative;
  width: 100%;
  height: 520px;
  background: #f1f5f9;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

#pdfFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: #f8fafc;
}

.preview-loader {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  transition: opacity var(--transition-fast);
  pointer-events: none;
  opacity: 0;
}

.preview-loader.loading {
  opacity: 1;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 0, 145, 0.15);
  border-top-color: var(--color-marianne-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.preview-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.progress-footer {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.progress-bar-bg {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 0.375rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-marianne-blue), #2563eb);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-subtle);
  font-weight: 500;
}

/* Footer */
.app-footer {
  margin-top: auto;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  padding: 1.5rem;
  font-size: 0.8125rem;
  color: var(--text-subtle);
  text-align: center;
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
}

.footer-sub {
  font-size: 0.75rem;
  margin-top: 0.375rem;
  color: #94a3b8;
}

/* Responsive Breakpoints */
@media (max-width: 1100px) {
  .app-main {
    grid-template-columns: 1fr 420px;
    gap: 1.25rem;
  }
  .preview-frame-container {
    height: 440px;
  }
}

@media (max-width: 920px) {
  .app-main {
    grid-template-columns: 1fr;
  }

  .preview-sticky-card {
    position: static;
  }

  .preview-frame-container {
    height: 480px;
  }

  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .step-nav {
    overflow-x: auto;
  }

  .form-row.two-cols {
    grid-template-columns: 1fr;
  }
}
