/* -------------------- Reset & Base -------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  touch-action: manipulation;
}

body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f5f6fa;
  color: #333;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a {
  text-decoration: none;
  color: #007bff;
}
a:hover { text-decoration: underline; }

/* -------------------- App Shell -------------------- */
.auth-container {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background-color: #f5f6fa;
}

/* -------------------- Form Sections -------------------- */
.form-section {
  display: none;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  flex-direction: column;
}

.form-section.active {
  display: flex;
  animation: slideFadeIn 0.35s ease forwards;
}

/* -------------------- Scrollable inner content -------------------- */
.section-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 24px 0;
  scrollbar-width: none;
}
.section-body::-webkit-scrollbar { display: none; }

.welcome-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 24px 0;
  scrollbar-width: none;
}
.welcome-content::-webkit-scrollbar { display: none; }

/* -------------------- Animate inner elements -------------------- */
.form-section.active h1,
.form-section.active h2,
.form-section.active h3,
.form-section.active h4,
.form-section.active p,
.form-section.active label,
.form-section.active input,
.form-section.active select,
.form-section.active small,
.form-section.active .btn,
.form-section.active .intent-card,
.form-section.active .feature-item,
.form-section.active .auth-links {
  opacity: 0;
  transform: translateY(16px);
  animation: fadeInUp 0.5s ease forwards;
}
.form-section.active *:nth-child(1)  { animation-delay: 0.05s; }
.form-section.active *:nth-child(2)  { animation-delay: 0.10s; }
.form-section.active *:nth-child(3)  { animation-delay: 0.15s; }
.form-section.active *:nth-child(4)  { animation-delay: 0.20s; }
.form-section.active *:nth-child(5)  { animation-delay: 0.25s; }
.form-section.active *:nth-child(6)  { animation-delay: 0.30s; }
.form-section.active *:nth-child(7)  { animation-delay: 0.35s; }
.form-section.active *:nth-child(8)  { animation-delay: 0.40s; }
.form-section.active *:nth-child(9)  { animation-delay: 0.45s; }
.form-section.active *:nth-child(10) { animation-delay: 0.50s; }

/* -------------------- Section Headers -------------------- */
.section-header {
  margin-bottom: 18px;
}
.section-header h2 {
  font-size: 1.5rem;
  color: #222;
  margin-bottom: 5px;
}
.section-header p {
  font-size: 0.88rem;
  color: #666;
}

.welcome-content h2 {
  font-size: 1.55rem;
  color: #222;
  margin-bottom: 6px;
  text-align: center;
}
.welcome-content > p {
  font-size: 0.88rem;
  color: #666;
  text-align: center;
}

/* -------------------- Inputs -------------------- */
.form-group {
  text-align: left;
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  /* 16px prevents iOS auto-zoom on focus */
  font-size: 16px;
  color: #333;
  background: #fafafa;
  transition: border-color 0.2s, background 0.2s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: #007bff;
  background: #fff;
  outline: none;
}
.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: #888;
}

/* -------------------- Password Toggle -------------------- */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrapper input {
  padding-right: 46px;
}
.eye-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  z-index: 1;
}
.eye-toggle:hover,
.eye-toggle:focus {
  color: #007bff;
  outline: none;
}
.eye-toggle svg {
  width: 18px;
  height: 18px;
}

/* -------------------- Buttons -------------------- */
.btn {
  cursor: pointer;
  padding: 13px 18px;
  border-radius: 10px;
  font-size: 0.97rem;
  font-weight: 600;
  border: none;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  white-space: nowrap;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn:active { transform: scale(0.97); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background-color: #007bff;
  color: #fff;
}
.btn.primary:hover:not(:disabled) {
  background-color: #0069d9;
}
.btn.secondary {
  background-color: #f1f3f5;
  color: #444;
  border: 1.5px solid #ddd;
}
.btn.secondary:hover:not(:disabled) {
  background-color: #e2e6ea;
}
.btn.ghost {
  background: transparent;
  color: #007bff;
  border: 1.5px solid #007bff;
}
.btn.ghost:hover:not(:disabled) {
  background-color: #007bff;
  color: #fff;
}

/* -------------------- Button Spinner -------------------- */
.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
}
.btn.primary.loading::after   { border-top-color: #fff; }
.btn.secondary.loading::after,
.btn.ghost.loading::after     { border-top-color: #007bff; }

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* -------------------- Auth Button Area -------------------- */
/* Pinned to the bottom of the card — never scrolls */
.auth-buttons {
  flex-shrink: 0;
  padding: 14px 20px 18px;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  display: flex;
  gap: 10px;
}

/* Default: buttons share the row equally */
.auth-buttons .btn {
  flex: 1;
}

/* Three-button layout:
     Row 1: [Back]  [Primary action]
     Row 2: [Ghost / skip]  full width  */
.auth-buttons.three-btn {
  flex-wrap: wrap;
}
.auth-buttons.three-btn .btn:nth-child(1),
.auth-buttons.three-btn .btn:nth-child(2) {
  flex: 1;
}
.auth-buttons.three-btn .btn:nth-child(3) {
  flex: 0 0 100%;
}

/* -------------------- Intent Options -------------------- */
.intent-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.intent-card {
  background-color: #f8f9fa;
  padding: 14px 10px;
  border-radius: 12px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  text-align: center;
}
.intent-card:hover { border-color: #007bff; }
.intent-card.selected {
  background-color: #007bff;
  color: #fff;
  border-color: #007bff;
}
.intent-icon { font-size: 1.5rem; line-height: 1; }
.intent-card h3 {
  margin-top: 7px;
  font-size: 0.88rem;
  font-weight: 700;
}
.intent-card p {
  font-size: 0.75rem;
  margin-top: 3px;
  opacity: 0.7;
}
.intent-card.selected p { opacity: 0.9; }

/* -------------------- Feature Grid -------------------- */
.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.feature-item {
  background-color: #f1f3f5;
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
}
.feature-item .icon { font-size: 1.5rem; line-height: 1; }
.feature-item h4 {
  margin-top: 7px;
  font-size: 0.85rem;
  font-weight: 700;
}
.feature-item p {
  font-size: 0.75rem;
  margin-top: 3px;
  color: #666;
}

/* -------------------- Error & Success -------------------- */
.error-message {
  display: none;
  color: #c0392b;
  background: #fdf0ef;
  border: 1px solid #f5c6c2;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.84rem;
  text-align: left;
}
.success-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 24px 0;
  text-align: center;
  scrollbar-width: none;
}
.success-content::-webkit-scrollbar { display: none; }
.success-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 10px;
}
.success-content h2 {
  font-size: 1.45rem;
  margin-bottom: 6px;
}
.next-steps {
  margin-top: 16px;
  text-align: left;
  background: #f8f9fa;
  border-radius: 12px;
  padding: 14px 16px;
}
.next-steps h4 {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 10px;
}
.next-steps ul { list-style: none; }
.next-steps ul li {
  padding: 6px 0;
  font-size: 0.88rem;
  border-bottom: 1px solid #eee;
}
.next-steps ul li:last-child { border-bottom: none; }

/* -------------------- Checkbox -------------------- */
.checkbox-group {
  text-align: left;
  margin-bottom: 10px;
}
.checkbox-group label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.86rem;
  color: #555;
  cursor: pointer;
  line-height: 1.4;
}
.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: #007bff;
  cursor: pointer;
}

/* -------------------- Progress Bar -------------------- */
.progress-container {
  flex-shrink: 0;
  padding: 16px 20px 0;
}
.progress-bar {
  width: 100%;
  background-color: #e9ecef;
  height: 6px;
  border-radius: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background-color: #007bff;
  border-radius: 10px;
  transition: width 0.4s ease;
}
.step-indicators {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}
.step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: #e9ecef;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #999;
  transition: background 0.3s, color 0.3s;
}
.step-dot.active {
  background-color: #007bff;
  color: #fff;
}

/* -------------------- Auth Links -------------------- */
.auth-links {
  flex-shrink: 0;
  padding: 10px 20px 0;
  font-size: 0.84rem;
  text-align: center;
}
.auth-links a { font-weight: 600; }
.auth-links .divider {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #888;
}

/* -------------------- Animations -------------------- */
@keyframes slideFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* -------------------- Very small phones (< 360px) -------------------- */
@media (max-width: 359px) {
  .auth-container { padding: 10px; }
  .section-body,
  .welcome-content,
  .success-content { padding-left: 16px; padding-right: 16px; }
  .auth-buttons,
  .progress-container { padding-left: 14px; padding-right: 14px; }
  .btn { font-size: 0.88rem; }
  .intent-card h3,
  .feature-item h4 { font-size: 0.8rem; }
}

/* -------------------- Landscape phones -------------------- */
@media (max-height: 560px) and (orientation: landscape) {
  .auth-container {
    align-items: flex-start;
    padding: 8px;
    overflow-y: auto;
  }
  .form-section {
    max-height: none;
  }
  .section-header h2,
  .welcome-content h2 { font-size: 1.2rem; }
  .feature-grid,
  .intent-options { gap: 7px; }
  .feature-item,
  .intent-card { padding: 10px 8px; }
  .progress-container { padding-top: 10px; }
}

/* -------------------- Tablets / larger -------------------- */
@media (min-width: 540px) {
  .auth-container { padding: 24px; }
  .form-section { border-radius: 20px; }
}
