/* ═══════════════════════════════════════════════════════════
   Halo Lumineux · Clinique des Enfants
   Palette from logo: warm brown border, golden angel, orange text
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────── */
:root {
  /* Primary Brown — logo circle border */
  --navy: #6D2B15;
  --navy-dark: #4E1E0E;
  --navy-light: #8B3B20;

  /* Gold/Amber — angel body & halo glow */
  --teal: #F0A830;
  --teal-dark: #C8880A;
  --teal-light: #FFF8E8;
  --teal-glow: rgba(240, 168, 48, 0.22);

  /* Orange — "HALO LUMINEUX" text */
  --amber: #E8820C;
  --amber-dark: #C06508;
  --amber-light: #FFF3E0;

  /* Red — validation errors */
  --red: #D94040;
  --red-light: #FFF0F0;

  /* Neutral — warm cream paper */
  --paper: #FBF9F5;
  --white: #FFFFFF;
  --surface: #F7F3ED;
  --border: #E8DFD3;
  --border-focus: #F0A830;
  --text-primary: #4A2A14;
  --text-secondary: #6D4E3A;
  --text-muted: #9C8876;
  --text-placeholder: #BFA98F;

  /* Radius */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  /* Shadow */
  --shadow-sm: 0 2px 8px rgba(109, 43, 21, 0.08);
  --shadow-md: 0 4px 20px rgba(109, 43, 21, 0.12);
  --shadow-lg: 0 8px 40px rgba(109, 43, 21, 0.18);
  --shadow-teal: 0 4px 20px rgba(240, 168, 48, 0.3);
  --shadow-amber: 0 4px 20px rgba(232, 130, 12, 0.3);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset & Base ──────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background-color: var(--paper);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

/* ── Background Atmosphere ─────────────────────────────── */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(240, 168, 48, 0.14) 0%, transparent 70%);
  top: -100px;
  right: -150px;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(232, 130, 12, 0.10) 0%, transparent 70%);
  bottom: 100px;
  left: -100px;
}

/* ── App Shell ─────────────────────────────────────────── */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 60px;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  gap: 12px;
}

.clinic-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  object-fit: contain;
}

/* Fallback logo placeholder */
.logo-img[style*="display: none"]+.clinic-text {
  margin-left: 0;
}

.clinic-text {
  display: flex;
  flex-direction: column;
}

.clinic-name {
  font-family: 'Lora', serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--white);
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.clinic-sub {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--teal);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.04em;
  text-align: right;
  white-space: nowrap;
}

.header-accent-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--teal) 0%, var(--amber) 60%, transparent 100%);
}

/* ── Header Actions / Nav ──────────────────────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-family: 'Nunito', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: all 0.2s var(--ease);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.header-nav-btn svg {
  width: 16px;
  height: 16px;
}

.header-nav-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
  transform: translateY(-1px);
}

/* ── Page Intro ─────────────────────────────────────────── */
.page-intro {
  padding: 28px 20px 12px;
  animation: fadeSlideIn 0.5s var(--ease) both;
}

.page-title {
  font-family: 'Lora', serif;
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.page-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ── Form Container ─────────────────────────────────────── */
.form-container {
  padding: 0 16px;
  animation: fadeSlideIn 0.6s var(--ease) 0.1s both;
}

/* ── Form Section ───────────────────────────────────────── */
.form-section {
  background: var(--white);
  border-radius: var(--r-xl);
  padding: 24px 20px 28px;
  margin-bottom: 0;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ── Section Header ─────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--teal-light);
}

.section-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--teal-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--teal-dark);
}

.section-icon svg {
  width: 22px;
  height: 22px;
}

.doctor-icon {
  background: var(--amber-light);
  color: var(--amber-dark);
}

.section-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.section-title {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--navy);
}

.section-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--teal-dark);
  background: var(--teal-light);
  padding: 2px 8px;
  border-radius: var(--r-full);
}

.doctor-badge {
  color: var(--amber-dark);
  background: var(--amber-light);
}

/* ── Fields Grid ────────────────────────────────────────── */
.fields-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group.half {
  flex: 1 1 calc(50% - 9px);
  min-width: 140px;
}

.field-group.full {
  flex: 1 1 100%;
}

/* ── Field Label ────────────────────────────────────────── */
.field-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
}

.required-dot {
  color: var(--red);
  font-size: 1rem;
  line-height: 1;
}

.optional-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  padding: 1px 7px;
  border-radius: var(--r-full);
  letter-spacing: 0.03em;
  text-transform: none;
}

/* ── Input Wrap ─────────────────────────────────────────── */
.input-wrap {
  position: relative;
}

/* ── Field Input ────────────────────────────────────────── */
.field-input {
  width: 100%;
  height: 52px;
  padding: 0 44px 0 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
  appearance: none;
  -webkit-appearance: none;
}

.field-input::placeholder {
  color: var(--text-placeholder);
  font-weight: 400;
}

.field-input:focus {
  border-color: var(--teal);
  background: var(--white);
  box-shadow: 0 0 0 4px var(--teal-glow);
}

.field-input:focus+.input-icon {
  color: var(--teal);
}

/* Input states */
.field-input.is-valid {
  border-color: #22C55E;
}

.field-input.is-invalid {
  border-color: var(--red);
  background: var(--red-light);
}

/* Input icon */
.input-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  transition: color 0.2s var(--ease);
  pointer-events: none;
}

.input-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.cost-icon {
  color: var(--teal-dark);
}

/* ── Select ─────────────────────────────────────────────── */
.select-wrap {
  position: relative;
}

.field-select {
  padding-right: 44px;
  cursor: pointer;
}

.field-select option {
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--white);
}

.select-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-secondary);
}

.select-arrow svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ── Date Input ─────────────────────────────────────────── */
.date-input {
  cursor: pointer;
}

.date-input::-webkit-calendar-picker-indicator {
  opacity: 0;
  position: absolute;
  right: 0;
  width: 44px;
  height: 52px;
  cursor: pointer;
}

/* ── Textarea ───────────────────────────────────────────── */
.field-textarea {
  height: auto;
  padding: 14px 16px;
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* ── Quick Amount Buttons ───────────────────────────────── */
.quick-amounts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.quick-btn {
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--teal-dark);
  background: var(--teal-light);
  border: 1.5px solid rgba(0, 180, 200, 0.25);
  border-radius: var(--r-full);
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  letter-spacing: 0.02em;
  -webkit-user-select: none;
  user-select: none;
}

.quick-btn:hover,
.quick-btn:active {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
  transform: translateY(-1px);
  box-shadow: var(--shadow-teal);
}

/* ── Field Error ────────────────────────────────────────── */
.field-error {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--red);
  padding-top: 4px;
  min-height: 1.2em;
  padding-left: 4px;
  transition: opacity 0.2s var(--ease);
}

/* ── Section Divider ────────────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 4px;
}

.divider-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.divider-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.divider-icon svg {
  width: 18px;
  height: 18px;
}

/* ── Submit Zone ────────────────────────────────────────── */
.submit-zone {
  padding: 24px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ── Submit Button ──────────────────────────────────────── */
.btn-submit {
  width: 100%;
  height: 60px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--white);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: none;
  border-radius: var(--r-xl);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s var(--ease-bounce), box-shadow 0.2s var(--ease);
  box-shadow: var(--shadow-md), 0 2px 0 rgba(0, 0, 0, 0.2) inset;
  -webkit-user-select: none;
  user-select: none;
}

.btn-submit::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 50%, rgba(255, 255, 255, 0.06));
  border-radius: inherit;
}

.btn-submit::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--r-xl) + 2px);
  background: linear-gradient(135deg, var(--teal), var(--amber));
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-submit:hover::after {
  opacity: 1;
}

.btn-submit:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-sm);
}

.btn-submit:disabled {
  opacity: 0.7;
  pointer-events: none;
}

.btn-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.2s var(--ease);
}

.btn-icon {
  width: 20px;
  height: 20px;
}

.btn-loader {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-submit.loading .btn-text {
  opacity: 0;
}

.btn-submit.loading .btn-loader {
  display: flex;
}

.loader-dot {
  width: 8px;
  height: 8px;
  background: var(--white);
  border-radius: 50%;
  animation: dotPulse 1.2s var(--ease) infinite;
}

.loader-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loader-dot:nth-child(3) {
  animation-delay: 0.4s;
}

.submit-note {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.lock-icon {
  width: 13px;
  height: 13px;
}

/* ── Modals ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 27, 74, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: var(--white);
  border-radius: var(--r-xl);
  padding: 40px 32px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  transform: scale(0.92) translateY(16px);
  transition: transform 0.35s var(--ease-bounce);
  box-shadow: var(--shadow-lg);
}

.modal-backdrop.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon svg {
  width: 32px;
  height: 32px;
}

.success-icon {
  background: linear-gradient(135deg, #F0A830, #E8820C);
  color: var(--white);
  box-shadow: 0 8px 24px rgba(240, 168, 48, 0.4);
}

.error-icon {
  background: linear-gradient(135deg, var(--red), #B91C1C);
  color: var(--white);
  box-shadow: 0 8px 24px rgba(217, 64, 64, 0.4);
}

.modal-title {
  font-family: 'Lora', serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--navy);
  margin-bottom: 10px;
}

.modal-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 28px;
}

.btn-modal-action {
  width: 100%;
  height: 50px;
  background: var(--navy);
  color: var(--white);
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  border: none;
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  letter-spacing: 0.02em;
}

.btn-modal-action:hover {
  background: var(--navy-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-retry {
  background: var(--red);
}

.btn-retry:hover {
  background: #B91C1C;
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dotPulse {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Responsive Adjustments ─────────────────────────────── */
@media (max-width: 400px) {
  .field-group.half {
    flex: 1 1 100%;
  }

  .clinic-name {
    font-size: 0.95rem;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .form-container {
    padding: 0 12px;
  }

  .form-section {
    padding: 20px 16px 24px;
  }

  .modal-card {
    padding: 32px 24px;
  }
}

@media (min-width: 600px) {
  .app-shell {
    padding: 0 16px 60px;
  }

  .form-container {
    padding: 0;
  }

  .btn-submit {
    height: 64px;
    font-size: 1.05rem;
  }
}

/* ── Utility: visually-hidden (a11y) ────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Input number: hide arrows ──────────────────────────── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
}