/* ============================================
   DE PLATFORM - Auth & Dashboard Styles
   Shared styles for login, register, forgot-password, dashboard
   All colors use CSS variables for theme support
============================================ */

/* ==========================================
   AUTH PAGES - Layout
========================================== */
.auth-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  position: relative;
  min-height: 100vh;
}

.auth-page::before {
  content: '';
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(ellipse at center, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.auth-container {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

/* ==========================================
   AUTH CARD
========================================== */
.auth-card {
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl, 24px);
  padding: 48px;
  box-shadow: var(--shadow-card);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

/* ==========================================
   ALERTS
========================================== */
.auth-alert {
  padding: 14px 18px;
  border-radius: var(--radius-lg, 12px);
  font-size: 14px;
  margin-bottom: 24px;
  display: none;
  align-items: center;
  gap: 12px;
  animation: authSlideIn 0.3s ease;
}

@keyframes authSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-alert.show { display: flex; }

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

.auth-alert--success {
  background: var(--success-subtle, rgba(34, 197, 94, 0.1));
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

/* ==========================================
   FORM ELEMENTS
========================================== */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.form-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg, 12px);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

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

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  background: var(--bg-input-focus);
}

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-link {
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s;
}

.form-link:hover { opacity: 0.8; }

/* ==========================================
   SUBMIT BUTTON
========================================== */
.auth-submit {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-lg, 12px);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.auth-submit:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px var(--accent-glow);
}

.auth-submit:active:not(:disabled) {
  transform: translateY(0);
}

.auth-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: authSpin 0.8s linear infinite;
  display: inline-block;
}

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

/* ==========================================
   SOCIAL & DIVIDER
========================================== */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 28px 0;
  color: var(--text-muted);
  font-size: 13px;
}

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

.auth-social {
  display: flex;
  gap: 12px;
}

.auth-social-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg, 12px);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-social-btn:hover {
  background: var(--bg-input-focus);
  border-color: var(--border-input-hover);
  transform: translateY(-1px);
}

/* ==========================================
   AUTH FOOTER & BACK LINK
========================================== */
.auth-footer {
  text-align: center;
  margin-top: 28px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

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

.auth-back {
  position: fixed;
  top: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
  z-index: 100;
}

.auth-back:hover { color: var(--text-primary); }

/* Theme toggle on auth pages - top left below back link */
.auth-theme-toggle {
  position: fixed;
  top: 60px;
  left: 24px;
  z-index: 100;
}

/* ==========================================
   PASSWORD STRENGTH
========================================== */
.password-strength {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.password-strength-bar {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.password-strength-bar.weak { width: 33%; background: var(--error); }
.password-strength-bar.medium { width: 66%; background: var(--accent); }
.password-strength-bar.strong { width: 100%; background: var(--success); }

/* Terms checkbox */
.form-checkbox--terms {
  align-items: flex-start;
  line-height: 1.5;
}

.form-checkbox--terms input {
  margin-top: 2px;
  flex-shrink: 0;
}

.form-checkbox a {
  color: var(--accent);
  text-decoration: none;
}

.form-checkbox a:hover {
  text-decoration: underline;
}

/* ==========================================
   USER MENU (Nav dropdown when logged in)
========================================== */
.de-user-menu {
  position: relative;
}

.de-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  color: var(--text-primary);
}

.de-user-btn:hover {
  background: var(--bg-input-focus);
  border-color: var(--accent);
}

.de-user-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-on-accent);
  flex-shrink: 0;
}

.de-user-name {
  font-size: 14px;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.de-user-chevron {
  opacity: 0.6;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.de-user-btn:hover .de-user-chevron {
  opacity: 1;
}

.de-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl, 16px);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-dropdown);
  z-index: 9999;
}

.de-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.de-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  transition: all 0.15s ease;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.de-dropdown-item svg {
  opacity: 0.6;
  flex-shrink: 0;
  stroke: currentColor;
}

.de-dropdown-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.de-dropdown-item:hover svg {
  opacity: 1;
}

.de-dropdown-logout {
  color: #f87171;
}

.de-dropdown-logout svg {
  stroke: #f87171;
}

.de-dropdown-logout:hover {
  background: var(--error-subtle, rgba(239, 68, 68, 0.1));
  color: #f87171;
}

.de-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 4px;
}

/* ==========================================
   DASHBOARD STYLES
========================================== */
.dashboard {
  min-height: 100vh;
  padding-top: calc(var(--nav-height) + 20px);
}

.dashboard-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px;
}

.welcome {
  margin-bottom: 48px;
}

.welcome__eyebrow {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.welcome__eyebrow span {
  color: var(--success);
}

.welcome__title {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.2;
  color: var(--text-primary);
}

.welcome__subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  max-width: 500px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 48px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl, 16px);
  padding: 24px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-card);
}

.stat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.stat-card__icon {
  width: 48px;
  height: 48px;
  background: var(--accent-subtle);
  border-radius: var(--radius-lg, 12px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--accent);
}

.stat-card__icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.5;
}

.stat-card__value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.stat-card__label {
  color: var(--text-muted);
  font-size: 14px;
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s;
}

.section-link:hover { opacity: 0.8; }

/* Quick Actions */
.quick-actions {
  display: flex;
  gap: 16px;
  margin-bottom: 48px;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-lg, 12px);
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.action-btn--primary {
  background: var(--accent);
  color: var(--text-on-accent);
}

.action-btn--primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px var(--accent-glow);
}

.action-btn--secondary {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}

.action-btn--secondary:hover {
  background: var(--bg-input-focus);
  border-color: var(--border-input-hover);
}

.action-btn__icon {
  display: flex;
  align-items: center;
}

.action-btn__icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

/* Dashboard Gate Cards */
.dashboard .gate-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl, 16px);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  display: block;
  overflow: visible;
  box-shadow: var(--shadow-card);
}

.dashboard .gate-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}

.dashboard .gate-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  height: auto;
  background: none;
}

.dashboard .gate-card__header::before {
  display: none;
}

.dashboard .gate-card__number {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: var(--text-on-accent);
  border-radius: var(--radius-lg, 12px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  opacity: 1;
}

.dashboard .gate-card__badge {
  position: static;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: none;
}

.gate-card__badge--progress {
  background: var(--accent-subtle) !important;
  color: var(--accent) !important;
}

.gate-card__badge--completed {
  background: var(--success-subtle) !important;
  color: var(--success) !important;
}

.gate-card__badge--locked {
  background: var(--bg-tertiary) !important;
  color: var(--text-muted) !important;
}

.dashboard .gate-card__title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.gate-card__desc {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.gate-card__progress {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.gate-card__progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.dashboard .gate-card__meta {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ==========================================
   RESPONSIVE - Auth pages
========================================== */
@media (max-width: 480px) {
  .auth-page {
    padding: 24px 16px;
    align-items: flex-start;
    padding-top: 60px;
  }

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

  .auth-title {
    font-size: 24px;
  }

  .auth-social {
    flex-direction: column;
  }

  .auth-back {
    top: 16px;
    left: 16px;
  }

  .auth-theme-toggle {
    top: 52px;
    left: 16px;
  }

  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

/* ==========================================
   RESPONSIVE - Dashboard
========================================== */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .dashboard-container {
    padding: 24px 16px;
  }

  .welcome__title {
    font-size: 28px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 20px;
  }

  .stat-card__value {
    font-size: 24px;
  }

  .dashboard .gates-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    flex-direction: column;
  }

  .action-btn {
    justify-content: center;
  }

  .de-user-name {
    display: none;
  }

  .de-user-btn {
    padding: 4px;
  }

  .de-dropdown {
    right: -10px;
    width: 220px;
  }
}

@media (max-width: 480px) {
  .de-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 16px;
    transform: translateY(100%);
  }

  .de-dropdown.show {
    transform: translateY(0);
  }
}

/* ==========================================
   RESPONSIVE - Large screens
========================================== */
@media (min-width: 1920px) {
  .auth-card {
    padding: 56px;
  }

  .auth-container {
    max-width: 480px;
  }
}

/* Ensure dropdown items are always clickable */
.de-dropdown { pointer-events: auto !important; }
.de-dropdown-item { pointer-events: auto !important; }
.de-user-btn { pointer-events: auto !important; }
.de-user-menu { pointer-events: auto !important; }



/* ==========================================
   COMPACT THEME TOGGLE (Auth Pages)
   Small, unobtrusive single-button toggle
========================================== */
.theme-compact-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--text-muted, #666);
  cursor: pointer;
  transition: all 0.25s ease;
  padding: 0;
}

.theme-compact-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(92, 182, 249, 0.3);
  color: var(--accent, #5CB6F9);
  transform: scale(1.05);
}

.theme-compact-btn:active {
  transform: scale(0.95);
}

.theme-compact-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-compact-icon svg {
  width: 16px;
  height: 16px;
}

[data-theme="light"] .theme-compact-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .theme-compact-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(61, 160, 232, 0.3);
}

@media (max-width: 480px) {
  .theme-compact-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }
  .theme-compact-icon svg {
    width: 14px;
    height: 14px;
  }
}
