/* ============================================
   CT Leonardo — Forms Design System
   Mobile-first standalone stylesheet
   ============================================ */

/* Google Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---- Tokens ---- */
:root {
  /* Brand Colors */
  --brand-primary: #2563EB;
  --brand-primary-hover: #1D4ED8;
  --brand-primary-light: rgba(37, 99, 235, 0.1);
  --brand-primary-glow: rgba(37, 99, 235, 0.25);
  --brand-secondary: #DC2626;
  --brand-success: #10B981;
  --brand-dark: #0F172A;
  --brand-light: #F8FAFC;
  --brand-muted: #64748B;

  /* Neutrals */
  --neutral-50: #F9FAFB;
  --neutral-100: #F3F4F6;
  --neutral-200: #E5E7EB;
  --neutral-300: #D1D5DB;
  --neutral-400: #9CA3AF;
  --neutral-500: #6B7280;
  --neutral-700: #374151;
  --neutral-800: #1F2937;
  --neutral-900: #111827;

  /* Semantic */
  --color-success: #16A34A;
  --color-danger: #DC2626;
  --color-info: #2563EB;

  /* Typography */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;

  /* Spacing (8pt grid) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  /* Radius */
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-3xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
  --shadow-float: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px -5px rgba(37, 99, 235, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

html {
  font-size: 16px;
  /* Prevents iOS zoom on input focus */
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--neutral-50);
  color: var(--neutral-900);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Layout ---- */
.page-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-10) + env(safe-area-inset-bottom, 0px));
}

.page-content {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* ---- Header ---- */
.form-header {
  text-align: center;
  padding: var(--space-8) 0 var(--space-4);
}

.header-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-2xl);
  background: linear-gradient(135deg, var(--brand-primary), #1D4ED8);
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(37, 99, 235, 0.12);
  margin-bottom: var(--space-4);
  animation: float-in 0.6s ease-out;
}

.header-logo svg {
  width: 32px;
  height: 32px;
  color: white;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--neutral-900);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-1);
}

.header-subtitle {
  font-size: 0.875rem;
  color: var(--brand-muted);
  font-weight: 400;
}

/* ---- Card ---- */
.form-card {
  background: white;
  border-radius: var(--radius-3xl);
  box-shadow: var(--shadow-soft);
  padding: var(--space-6);
  border: none;
  transition: box-shadow 300ms ease;
}

/* ---- Form Elements ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--neutral-700);
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-input,
.form-select {
  width: 100%;
  height: 3rem;
  /* 48px */
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--neutral-200);
  padding: 0 var(--space-4);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  color: var(--neutral-900);
  background: var(--neutral-50);
  outline: none;
  transition: all 200ms ease;
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder {
  color: var(--neutral-400);
}

.form-input:focus,
.form-select:focus {
  background: white;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-light);
}

.form-input.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-error {
  font-size: 0.75rem;
  color: var(--color-danger);
  margin-top: var(--space-1);
  display: none;
}

.form-error.visible {
  display: block;
}

/* Select wrapper for custom arrow */
.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--neutral-400);
  pointer-events: none;
}

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

.form-select option[value=""] {
  color: var(--neutral-400);
}

/* ---- Class Days Display ---- */
.class-days {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 300ms ease, opacity 200ms ease, margin 200ms ease, padding 200ms ease;
  margin-top: 0;
  background: var(--neutral-50);
  border-radius: var(--radius-xl);
  padding: 0;
}

.class-days.visible {
  max-height: 150px;
  opacity: 1;
  margin-top: var(--space-2);
  padding: var(--space-3) var(--space-4);
}

.class-info-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.class-info-icon {
  color: var(--brand-primary);
  flex-shrink: 0;
}

.class-info-text {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--neutral-700);
}

.days-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--neutral-500);
}

.day-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---- Toggle Switch ---- */
.toggle-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) 0;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--neutral-200);
  border: none;
  cursor: pointer;
  transition: background 200ms ease;
  flex-shrink: 0;
  padding: 0;
}

.toggle-switch.active {
  background: var(--brand-primary);
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: var(--shadow-sm);
  transition: transform 200ms ease;
}

.toggle-switch.active .toggle-knob {
  transform: translateX(20px);
}

.toggle-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--neutral-700);
}

/* ---- Guardian Fields (conditional) ---- */
.guardian-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 400ms ease, opacity 300ms ease, margin 300ms ease;
  margin-top: 0;
}

.guardian-fields.visible {
  max-height: 300px;
  opacity: 1;
  margin-top: var(--space-5);
}

/* ---- Section Divider ---- */
.form-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-2) 0;
}

.form-divider::before,
.form-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--neutral-200);
}

.form-divider span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--neutral-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ---- Submit Button ---- */
.btn-submit {
  width: 100%;
  height: 3.5rem;
  /* 56px — touch-optimized */
  border-radius: var(--radius-2xl);
  border: none;
  background: var(--brand-primary);
  color: white;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  box-shadow: var(--shadow-lg), 0 4px 14px -3px var(--brand-primary-glow);
  transition: all 200ms ease;
  margin-top: var(--space-4);
}

.btn-submit:hover {
  background: var(--brand-primary-hover);
}

.btn-submit:active {
  transform: scale(0.98);
}

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

/* Spinner inside button */
.btn-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: calc(100% - 2rem);
  max-width: 440px;
  pointer-events: none;
}

.toast {
  padding: var(--space-4);
  border-radius: var(--radius-2xl);
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-float);
  transform: translateY(-100%);
  opacity: 0;
  transition: all 300ms ease;
  pointer-events: auto;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

.toast.error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* ---- Success Screen ---- */
.success-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-10) var(--space-6);
  gap: var(--space-6);
}

.success-screen.visible {
  display: flex;
}

.success-icon-wrapper {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ECFDF5, #D1FAE5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-icon-wrapper svg {
  width: 40px;
  height: 40px;
  color: var(--color-success);
}

.success-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--neutral-900);
}

.success-message {
  font-size: 0.875rem;
  color: var(--brand-muted);
  line-height: 1.6;
  max-width: 300px;
}

.btn-new-register {
  width: 100%;
  max-width: 280px;
  height: 3rem;
  border-radius: var(--radius-2xl);
  border: 2px solid var(--neutral-200);
  background: transparent;
  color: var(--neutral-900);
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: all 200ms ease;
}

.btn-new-register:hover {
  background: var(--neutral-100);
}

.btn-new-register:active {
  transform: scale(0.98);
}

/* ---- Footer ---- */
.form-footer {
  text-align: center;
  padding: var(--space-6) 0 var(--space-4);
}

.footer-text {
  font-size: 0.75rem;
  color: var(--neutral-400);
}

.footer-dev {
  display: inline-block;
  margin-top: var(--space-2);
  font-size: 0.6875rem;
  color: var(--neutral-300);
  text-decoration: none;
  transition: color 200ms ease;
}

.footer-dev:hover {
  color: var(--brand-primary);
}

/* ---- Loading Skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, var(--neutral-100) 25%, var(--neutral-200) 50%, var(--neutral-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xl);
  height: 3rem;
}

/* ---- Animations ---- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
  }

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

@keyframes pop-in {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }

  50% {
    transform: scale(1.05);
  }

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

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

  100% {
    background-position: -200% 0;
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

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

.fade-up {
  animation: fade-up 0.5s ease-out forwards;
}

.fade-up-delay-1 {
  animation-delay: 0.1s;
  opacity: 0;
}

.fade-up-delay-2 {
  animation-delay: 0.2s;
  opacity: 0;
}

.fade-up-delay-3 {
  animation-delay: 0.3s;
  opacity: 0;
}

/* ---- Scrollbar (WebKit) ---- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--neutral-300);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-400);
}