/* ═══════════════════════════════════════════
   Jam3ah – Design System
   Brand Booklet: Navy #2E3192 + Red #EF4136
   Clean white/light background — professional
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=DM+Sans:wght@400;500;600&family=Noto+Kufi+Arabic:wght@300;400;500;600;700&display=swap');

:root {
  /* Brand Colors – directly from booklet */
  --navy: #2E3192;
  --navy-light: #4A4DC8;
  --navy-dark: #1F2270;
  --red: #EF4136;
  --red-light: #F4645B;
  --red-dark: #C92E24;

  /* Surface Colors */
  --bg-page: #F5F6FA;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FAFBFF;
  --bg-input: #FFFFFF;
  --bg-input-focus: #FAFAFF;

  /* Text Colors */
  --text-primary: #1A1D3B;
  --text-secondary: #4A4E6A;
  --text-muted: #8B90A8;
  --text-on-navy: #FFFFFF;
  --text-accent: #2E3192;

  /* Borders */
  --border-default: #DFE1EC;
  --border-hover: #C5C8DA;
  --border-focus: #2E3192;
  --border-error: #EF4136;

  /* Functional */
  --error-color: #EF4136;
  --error-bg: #FFF0EF;
  --success-color: #22C55E;
  --success-bg: #EDFCF2;

  /* Typography */
  --font-display: 'Outfit', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-arabic: 'Noto Kufi Arabic', sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(46, 49, 146, 0.06);
  --shadow-md: 0 4px 12px rgba(46, 49, 146, 0.08);
  --shadow-lg: 0 8px 30px rgba(46, 49, 146, 0.1);
  --shadow-focus: 0 0 0 3px rgba(46, 49, 146, 0.12);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ── Background Decoration ── */
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse at top left, rgba(46, 49, 146, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(239, 65, 54, 0.03) 0%, transparent 60%);
}

.bg-glow {
  display: none;
}

/* ── Container ── */
.container {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md) var(--space-3xl);
}

/* ── Header ── */
.form-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
  animation: fadeInDown 0.6s var(--ease-out);
}

.header-top-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-md);
}

.logo-mark {
  display: inline-flex;
  margin-bottom: var(--space-sm);
}

.logo-mark img {
  width: 160px;
  height: auto;
  object-fit: contain;
}

.form-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  line-height: 1.3;
}

.form-subtitle {
  display: none;
}

.form-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
  line-height: 1.6;
}

/* ── Language Toggle ── */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(46, 49, 146, 0.06);
  border: 1.5px solid var(--border-default);
  border-radius: 50px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--duration-normal) var(--ease-out);
  user-select: none;
}

.lang-toggle:hover {
  border-color: var(--navy);
  background: rgba(46, 49, 146, 0.1);
  color: var(--navy);
}

.lang-globe {
  display: flex;
  align-items: center;
  color: var(--navy);
}

.lang-globe svg {
  width: 16px;
  height: 16px;
}

.lang-en,
.lang-ar {
  transition: all var(--duration-fast);
  opacity: 0.5;
}

.lang-en.active,
.lang-ar.active {
  opacity: 1;
  color: var(--navy);
  font-weight: 700;
}

.lang-divider {
  opacity: 0.3;
  font-weight: 400;
}

/* ── Progress Bar ── */
.progress-container {
  width: 100%;
  height: 4px;
  background: var(--border-default);
  border-radius: 4px;
  margin-bottom: var(--space-2xl);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--navy), var(--red));
  border-radius: 4px;
  transition: width var(--duration-slow) var(--ease-out);
}

/* ── Form Card ── */
.session-form {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl) var(--space-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-default);
}

/* ── Form Groups ── */
.form-group {
  margin-bottom: var(--space-lg);
  animation: fadeInUp 0.5s var(--ease-out) both;
}

.form-group[data-field="1"] { animation-delay: 0.03s; }
.form-group[data-field="2"] { animation-delay: 0.06s; }
.form-group[data-field="3"] { animation-delay: 0.09s; }
.form-group[data-field="4"] { animation-delay: 0.12s; }
.form-group[data-field="5"] { animation-delay: 0.15s; }
.form-group[data-field="6"] { animation-delay: 0.18s; }
.form-group[data-field="7"] { animation-delay: 0.21s; }
.form-group[data-field="8"] { animation-delay: 0.24s; }
.form-group[data-field="9"] { animation-delay: 0.27s; }
.form-group[data-field="10"] { animation-delay: 0.30s; }
.form-group[data-field="11"] { animation-delay: 0.33s; }
.form-group[data-field="12"] { animation-delay: 0.36s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

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

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }

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

/* ── Labels ── */
.form-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.field-number {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-on-navy);
  background: var(--navy);
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.label-hint {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* ── Inputs ── */
.form-input {
  width: 100%;
  padding: 13px 16px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--duration-normal) var(--ease-out);
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:hover {
  border-color: var(--border-hover);
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  background: var(--bg-input-focus);
}

.form-input.error {
  border-color: var(--border-error);
  background: var(--error-bg);
}

/* ── Textarea ── */
.form-textarea {
  width: 100%;
  padding: 13px 16px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  resize: vertical;
  min-height: 100px;
  max-height: 200px;
  transition: all var(--duration-normal) var(--ease-out);
}

.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-textarea:hover {
  border-color: var(--border-hover);
}

.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  background: var(--bg-input-focus);
}

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

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

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

.form-select option {
  background: #fff;
  color: var(--text-primary);
}

/* ── Phone Input Group ── */
.phone-input-group {
  display: flex;
  gap: 0;
}

.phone-prefix {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 13px 14px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  background: rgba(46, 49, 146, 0.06);
  border: 1.5px solid var(--border-default);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  white-space: nowrap;
  user-select: none;
}

.phone-prefix .flag-emoji {
  font-size: 1.15rem;
}

.phone-input-group .form-input {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  flex: 1;
}

/* ── Radio Cards ── */
.radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.radio-group-2 {
  grid-template-columns: 1fr 1fr;
}

.radio-card {
  cursor: pointer;
}

.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-visual {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 13px 16px;
  background: #FFFFFF;
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--duration-normal) var(--ease-out);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.radio-visual svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  opacity: 0.4;
  transition: all var(--duration-normal) var(--ease-out);
}

.radio-card:hover .radio-visual {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.radio-card input:checked+.radio-visual {
  background: rgba(46, 49, 146, 0.05);
  border-color: var(--navy);
  color: var(--navy);
  box-shadow: 0 0 0 1px var(--navy);
}

.radio-card input:checked+.radio-visual svg {
  opacity: 1;
  color: var(--navy);
}

.radio-card input:focus-visible+.radio-visual {
  box-shadow: var(--shadow-focus);
}

/* ── Checkbox Cards (Referral Source) ── */
.checkbox-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.checkbox-card {
  cursor: pointer;
}

.checkbox-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-visual {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 13px 16px;
  background: #FFFFFF;
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--duration-normal) var(--ease-out);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.checkbox-visual svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  opacity: 0.4;
  transition: all var(--duration-normal) var(--ease-out);
}

.checkbox-card:hover .checkbox-visual {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.checkbox-card input:checked+.checkbox-visual {
  background: rgba(46, 49, 146, 0.05);
  border-color: var(--navy);
  color: var(--navy);
  box-shadow: 0 0 0 1px var(--navy);
}

.checkbox-card input:checked+.checkbox-visual svg {
  opacity: 1;
  color: var(--navy);
}

.checkbox-card input:focus-visible+.checkbox-visual {
  box-shadow: var(--shadow-focus);
}

.referral-other-input {
  margin-top: var(--space-sm);
  animation: fadeInUp 0.3s var(--ease-out);
}

/* ── File Upload ── */
.upload-zone {
  position: relative;
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  background: #FAFBFF;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--navy);
  background: rgba(46, 49, 146, 0.03);
}

.upload-zone.drag-over {
  transform: scale(1.01);
  box-shadow: var(--shadow-lg);
}

.file-input-hidden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-content {
  pointer-events: none;
}

.upload-content svg {
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.upload-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.upload-link {
  color: var(--navy);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* File list */
.file-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #FAFBFF;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  animation: fadeInUp 0.2s var(--ease-out);
}

.file-item-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  overflow: hidden;
}

.file-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-size {
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--duration-fast);
  flex-shrink: 0;
}

.file-remove:hover {
  color: var(--error-color);
}

/* ── Date/Time Conditional ── */
.datetime-group {
  overflow: hidden;
  animation: slideDown var(--duration-slow) var(--ease-out) !important;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
  }

  to {
    opacity: 1;
    max-height: 200px;
    margin-bottom: var(--space-lg);
  }
}

/* ── Error Messages ── */
.field-error {
  display: block;
  font-size: 0.8rem;
  color: var(--error-color);
  margin-top: var(--space-xs);
  min-height: 0;
  transition: all var(--duration-fast);
}

.field-error:not(:empty) {
  min-height: 1.2em;
}

/* ── Submit Button ── */
.submit-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 15px 32px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--navy);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
  margin-top: var(--space-lg);
}

.submit-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.1) 100%);
  opacity: 0;
  transition: opacity var(--duration-normal);
}

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

.submit-btn:hover {
  background: var(--navy-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(46, 49, 146, 0.25);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-arrow {
  transition: transform var(--duration-normal) var(--ease-out);
}

.submit-btn:hover .btn-arrow {
  transform: translateX(4px);
}

.btn-loader {
  display: none;
  animation: spin 1s linear infinite;
}

.submit-btn.loading .btn-text,
.submit-btn.loading .btn-arrow {
  display: none;
}

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

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

/* ── Privacy Note ── */
.form-privacy {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-md);
}

/* ── Success Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 29, 59, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-out);
  padding: var(--space-md);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #FFFFFF;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9) translateY(20px);
  transition: transform var(--duration-slow) var(--ease-out);
}

.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-icon {
  margin-bottom: var(--space-lg);
}

.check-path {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
}

.modal-overlay.active .check-path {
  animation: drawCheck 0.5s 0.3s var(--ease-out) forwards;
}

@keyframes drawCheck {
  to {
    stroke-dashoffset: 0;
  }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.modal-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-text strong {
  color: var(--navy);
}

.modal-footer {
  margin-top: var(--space-lg);
}

.modal-btn {
  padding: 12px 28px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 500;
  color: #FFFFFF;
  background: var(--navy);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.modal-btn:hover {
  background: var(--navy-dark);
  box-shadow: 0 4px 12px rgba(46, 49, 146, 0.2);
}

/* ═══════════════════════════════════════════
   RTL Support (Arabic)
   ═══════════════════════════════════════════ */

[dir="rtl"] body,
[dir="rtl"] .form-input,
[dir="rtl"] .form-textarea,
[dir="rtl"] .form-select {
  font-family: var(--font-arabic), var(--font-body);
}

[dir="rtl"] .form-title,
[dir="rtl"] .form-label,
[dir="rtl"] .submit-btn,
[dir="rtl"] .modal-title,
[dir="rtl"] .modal-btn,
[dir="rtl"] .lang-toggle {
  font-family: var(--font-arabic), var(--font-display);
}

[dir="rtl"] .header-top-row {
  justify-content: flex-start;
}

[dir="rtl"] .form-label {
  flex-direction: row;
}

/* Phone prefix: flip border radii */
[dir="rtl"] .phone-prefix {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-right: 1.5px solid var(--border-default);
  border-left: none;
}

[dir="rtl"] .phone-input-group .form-input {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

/* Select arrow: flip to left */
[dir="rtl"] .select-arrow {
  right: auto;
  left: 14px;
}

[dir="rtl"] .form-select {
  padding-right: 16px;
  padding-left: 44px;
}

/* Progress bar gradient: flip */
[dir="rtl"] .progress-bar {
  background: linear-gradient(270deg, var(--navy), var(--red));
}

/* Submit button arrow: flip */
[dir="rtl"] .submit-btn:hover .btn-arrow {
  transform: translateX(-4px);
}

[dir="rtl"] .btn-arrow {
  transform: scaleX(-1);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .container {
    padding: var(--space-lg) var(--space-sm) var(--space-2xl);
  }

  .session-form {
    padding: var(--space-lg) var(--space-md);
    border-radius: var(--radius-lg);
  }

  .form-title {
    font-size: 1.1rem;
  }

  .logo-mark img {
    width: 130px;
  }

  .radio-group {
    grid-template-columns: 1fr;
  }

  .radio-group-2 {
    grid-template-columns: 1fr 1fr;
  }

  .checkbox-group {
    grid-template-columns: 1fr;
  }

  .form-input,
  .form-textarea {
    font-size: 16px;
    /* Prevents iOS zoom */
  }
}

@media (max-width: 380px) {
  .radio-group-2 {
    grid-template-columns: 1fr;
  }
}

/* ── Focus Visible ── */
*:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}