/* ============================================================================
   MB ACADÉMIE — STYLES AUTH (Login, Register, Forgot/Reset Password)
   ============================================================================ */

.auth-page {
  --bg-primary: var(--gray-50);
  --bg-secondary: var(--white);
  --text-primary: var(--gray-900);
  --border: var(--gray-200);
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary, #0f172a);
  padding: 24px;
  font-family: var(--font-body);
}

.auth-card {
  background: var(--bg-secondary, #1e293b);
  border: 1px solid var(--border, rgba(255,255,255,0.06));
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
  text-decoration: none;
  color: var(--text-primary, #f1f5f9);
}

.auth-logo img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
}

.auth-logo span {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
}

.auth-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  margin: 0 0 8px;
  text-align: center;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary, #94a3b8);
  text-align: center;
  margin: 0 0 28px;
}

/* ── Form ─────────────────────────────────────────────────────── */

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.auth-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
}

.auth-field input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary, #0f172a);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 8px;
  color: var(--text-primary, #f1f5f9);
  font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.auth-field input::placeholder {
  color: var(--text-muted, #475569);
}

.auth-field .field-error {
  font-size: 12px;
  color: #ef4444;
  display: none;
}

.auth-field.has-error input {
  border-color: #ef4444;
}

.auth-field.has-error .field-error {
  display: block;
}

.auth-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Password toggle ────────────────────────────────────────────── */

.password-wrapper {
  position: relative;
}

.password-wrapper input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  padding: 10px;
  display: flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}

.password-toggle:hover {
  color: var(--text-primary, #f1f5f9);
}

/* ── Strength meter ──────────────────────────────────────────── */

.password-strength {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
  margin-top: 4px;
}

.password-strength-bar {
  height: 100%;
  border-radius: 2px;
  transition: width .3s, background .3s;
  width: 0;
}

.password-strength-text {
  font-size: 11px;
  color: var(--text-muted, #475569);
  margin-top: 2px;
}

/* ── Submit button ──────────────────────────────────────────────── */

.auth-submit {
  width: 100%;
  padding: 14px;
  background: var(--primary, #2563eb);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.auth-submit:hover {
  background: #1d4ed8;
}

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

.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-submit .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: none;
}

.auth-submit.loading .spinner {
  display: block;
}

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

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

/* ── Divider ──────────────────────────────────────────────────── */

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted, #475569);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border, rgba(255,255,255,0.06));
}

/* ── OAuth button ──────────────────────────────────────────────── */

.auth-oauth {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 8px;
  color: var(--text-primary, #f1f5f9);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .2s, border-color .2s;
}

.auth-oauth:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.15);
}

.auth-oauth svg {
  width: 20px;
  height: 20px;
}

/* ── Links & extras ──────────────────────────────────────────── */

.auth-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-top: 4px;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-links a {
  color: var(--primary, #2563eb);
  text-decoration: none;
  font-weight: 500;
}

.auth-links a:hover {
  text-decoration: underline;
}

.auth-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border, rgba(255,255,255,0.06));
}

.auth-footer a {
  color: var(--primary, #2563eb);
  text-decoration: none;
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-legal {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-secondary, #94a3b8);
}

/* ── Checkbox ─────────────────────────────────────────────────── */

.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
}

.auth-check input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--primary, #2563eb);
  width: 18px;
  height: 18px;
  min-width: 18px;
}

.auth-check a {
  color: var(--primary, #2563eb);
  text-decoration: none;
}

/* ── Alert messages ───────────────────────────────────────────── */

.auth-alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  display: none;
}

.auth-alert.visible {
  display: block;
}

.auth-alert.error {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.auth-alert.success {
  background: rgba(16, 185, 129, 0.1);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ── Wide card (pro registration) ────────────────────────────── */

.auth-card--wide {
  max-width: 560px;
}

/* ── Account Type Toggle ─────────────────────────────────────── */

.account-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--bg-primary, #0f172a);
  border-radius: 10px;
  padding: 4px;
  border: 1px solid var(--border, rgba(255,255,255,0.06));
}

.account-type-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary, #94a3b8);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
}

.account-type-btn:hover {
  color: var(--text-primary, #f1f5f9);
}

.account-type-btn.is-active {
  background: var(--primary, #2563eb);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.account-type-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ── Form Sections (fieldset) ────────────────────────────────── */

.auth-section {
  border: 1px solid var(--border, rgba(255,255,255,0.06));
  border-radius: 12px;
  padding: 20px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-section-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary, #2563eb);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px;
}

.auth-section-legend svg {
  color: var(--primary, #2563eb);
  flex-shrink: 0;
}

/* Pro sections animation */
.pro-section {
  animation: proSectionIn 0.35s ease-out;
  border-color: rgba(37, 99, 235, 0.15);
  background: rgba(37, 99, 235, 0.02);
}

@keyframes proSectionIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
    max-height: 0;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 1000px;
  }
}

/* ── Select & Textarea ───────────────────────────────────────── */

.auth-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary, #0f172a);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 8px;
  color: var(--text-primary, #f1f5f9);
  font-size: 14px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  box-sizing: border-box;
}

.auth-select:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.auth-select option {
  background: var(--bg-secondary, #1e293b);
  color: var(--text-primary, #f1f5f9);
}

.auth-textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary, #0f172a);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 8px;
  color: var(--text-primary, #f1f5f9);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
}

.auth-textarea:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.auth-textarea::placeholder {
  color: var(--text-muted, #475569);
}

/* Select/textarea error states */
.auth-field.has-error .auth-select,
.auth-field.has-error .auth-textarea {
  border-color: #ef4444;
}

/* ── 3-column row ────────────────────────────────────────────── */

.auth-row--3 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
}

/* ── Responsive ──────────────────────────────────────────────── */

/* Tablet : 481px - 768px */
@media (max-width: 768px) {
  .auth-card {
    padding: 32px 24px;
  }
  .auth-card--wide {
    max-width: 480px;
  }
  .auth-page {
    padding: 20px;
  }
  .auth-logo {
    margin-bottom: 24px;
  }
}

/* Mobile : < 480px */
@media (max-width: 480px) {
  .auth-card {
    padding: 24px 16px;
    border-radius: 12px;
  }
  .auth-card--wide {
    max-width: 100%;
  }
  .auth-row,
  .auth-row--3 {
    grid-template-columns: 1fr;
  }
  .auth-row--3 .auth-field[style*="grid-column"] {
    grid-column: span 1 !important;
  }
  .auth-title {
    font-size: 20px;
  }
  .auth-subtitle {
    font-size: 13px;
  }
  .auth-page {
    padding: 16px;
  }
  .auth-form {
    gap: 14px;
  }
  .auth-section {
    padding: 16px;
    gap: 12px;
  }
  .auth-logo span {
    font-size: 18px;
  }
  .auth-footer {
    margin-top: 16px;
    padding-top: 16px;
  }
  .auth-links {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .auth-links a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .account-type-btn {
    padding: 10px 12px;
    font-size: 13px;
    gap: 6px;
  }
  .account-type-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* Ultra-small: < 390px */
@media (max-width: 390px) {
  .auth-page {
    padding: 12px;
  }
  .auth-card {
    padding: 20px 14px;
    border-radius: 10px;
  }
  .auth-title {
    font-size: 18px;
  }
  .auth-subtitle {
    font-size: 12px;
  }
  .auth-field input,
  .auth-select,
  .auth-textarea {
    padding: 10px 12px;
    font-size: 13px;
  }
  .auth-submit {
    padding: 12px;
    font-size: 14px;
  }
  .auth-form {
    gap: 12px;
  }
  .auth-section {
    padding: 14px;
    gap: 10px;
  }
  .auth-check {
    font-size: 12px;
  }
  .auth-logo img {
    width: 40px;
    height: 40px;
  }
  .auth-logo span {
    font-size: 16px;
  }
}
