/* =========================
   Auth Pages - Elegant Design
   Using Your Design System Variables
========================= */

/* ===== Wrapper & Background ===== */
.auth-wrap {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
  padding: 50px 20px;
  background:
    var(--bg-linear),
    var(--bg-radial-primary),
    var(--bg-radial-secondary);
  position: relative;
  overflow: hidden;
}

.auth-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--auth-side-gradient);
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

.auth-grid {
  width: min(520px, 100%);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ===== Card ===== */
.auth-card {
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  padding: 40px 36px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
  transition: var(--transition);
}

.auth-card:hover {
  border-color: var(--border2);
  box-shadow: var(--shadow);
}

/* Subtle glow accent on top */
.auth-card-glow {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-accent);
  opacity: 0.9;
}

/* Mobile Brand (hidden on desktop) */
.auth-mobile-brand {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.auth-mobile-brand img,
.auth-mobile-brand .themed-logo {
  width: 52px;
  height: 52px;
  max-width: 52px;
  object-fit: contain;
  border-radius: 14px;
}

.auth-mobile-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ===== Header ===== */
.auth-header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.auth-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: -0.3px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
}

/* ===== Quick Links Row ===== */
.auth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
  padding: 0 4px;
}

.auth-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
  transition: var(--transition);
  font-size: 14px;
}
.auth-link:hover {
  color: var(--accent-light);
  text-decoration: none;
  filter: brightness(1.1);
}

/* ===== Form ===== */
.auth-form {
  display: grid;
  gap: 20px;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-label {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 14px;
  margin-left: 4px;
  transition: var(--transition);
}

/* ===== Input Group ===== */
.auth-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 16px;
  background: var(--panel2);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.auth-input-group:focus-within {
  border-color: var(--focus-border);
  background: var(--active-bg);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.auth-input-group:focus-within .auth-label {
  color: var(--primary);
}

.input-icon {
  color: var(--text-muted2);
  font-size: 16px;
  display: flex;
  align-items: center;
  width: 20px;
  transition: var(--transition);
}

.auth-input-group:focus-within .input-icon {
  color: var(--primary);
}

.auth-input-group input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  padding: 2px 0;
  min-width: 0; /* fix flex overflow on mobile */
}

.auth-input-group input::placeholder {
  color: var(--text-disabled);
  font-weight: 400;
}

/* Toggle Password Button */
.auth-toggle {
  border: none;
  background: transparent;
  color: var(--text-muted2);
  cursor: pointer;
  padding: 6px;
  border-radius: 10px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-toggle:hover {
  color: var(--primary);
  background: var(--hover-bg);
}
.auth-toggle:active { transform: scale(0.95); }

/* ===== Error Messages ===== */
.auth-input-group.has-error {
  border-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.05);
}

.auth-input-group.has-error .input-icon {
  color: #ff6b6b;
}

.auth-input-group.has-error:focus-within {
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.15);
}

.auth-error {
  color: #ff6b6b;
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== Password Strength Meter ===== */
.pw-meter {
  margin-top: 14px;
  padding-left: 4px;
}
.pw-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
  width: 100%;
}
.pw-fill {
  height: 100%;
  width: 0;
  background: transparent;
  transition: width 0.4s ease-out, background-color 0.4s ease-out;
  border-radius: 3px;
}
.pw-fill.weak { background: #ff4d4d; }
.pw-fill.medium { background: #ffb84d; }
.pw-fill.strong { background: #00cc66; }

.pw-text {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  transition: color 0.3s ease;
}
.pw-text.weak { color: #ff4d4d; }
.pw-text.medium { color: #ffb84d; }
.pw-text.strong { color: #00cc66; }

/* ===== Checkbox ===== */
.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.auth-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
}
.checkbox-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
}
.auth-checkbox:hover .checkbox-label {
  color: var(--text);
}

/* ===== Elegant Auth Button ===== */
.btn-auth {
  background: var(--gradient-accent);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  padding: 14px 20px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 8px 25px var(--shadow-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.btn-auth::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.btn-auth:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 35px var(--shadow-primary);
  filter: brightness(1.05);
}

.btn-auth:hover::before {
  transform: translateX(100%);
}

.btn-auth:active {
  transform: translateY(-1px);
  filter: brightness(0.98);
}

/* ===== Footer ===== */
.auth-foot {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted2);
  font-weight: 500;
  font-size: 13px;
  text-align: center;
  line-height: 1.8;
}
.auth-foot .auth-link {
  font-weight: 700;
  color: var(--primary);
}

/* ===== Animation Entry ===== */
.enter {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes fadeInUp {
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Divider (Optional) ===== */
.auth-or {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 10px 0;
  color: var(--text-muted2);
  font-weight: 600;
  font-size: 13px;
}
.auth-or::before,
.auth-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== Social Buttons ===== */
.auth-social {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}
.btn-social {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  padding: 12px 16px;
  border-radius: 14px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-social:hover {
  border-color: var(--primary);
  background: var(--primary-accent-bg);
  transform: translateY(-2px);
  color: var(--text);
}

/* ===== Light Theme Overrides ===== */
[data-theme="light"] .auth-wrap {
  background:
    linear-gradient(180deg, #f8f9fc 0%, #eef1f7 100%),
    radial-gradient(900px 460px at 80% -10%, rgba(64, 123, 110, 0.15), transparent 60%),
    radial-gradient(700px 420px at 15% 10%, rgba(33, 130, 223, 0.12), transparent 60%);
}

[data-theme="light"] .auth-card {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 20px 50px rgba(33, 130, 223, 0.12);
}

[data-theme="light"] .auth-card-glow {
  background: var(--gradient-accent);
  opacity: 1;
}

[data-theme="light"] .auth-title { color: #1a1a1a; }
[data-theme="light"] .auth-subtitle { color: #555; }
[data-theme="light"] .auth-label { color: #444; }

[data-theme="light"] .auth-input-group {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .auth-input-group input { color: #222; }
[data-theme="light"] .auth-input-group input::placeholder { color: #999; }

[data-theme="light"] .input-icon { color: #888; }
[data-theme="light"] .auth-input-group:focus-within .input-icon { color: var(--primary); }

[data-theme="light"] .checkbox-label { color: #444; }
[data-theme="light"] .auth-foot {
  border-top-color: rgba(0,0,0,0.08);
  color: #666;
}

[data-theme="light"] .auth-or { color: #888; }
[data-theme="light"] .auth-or::before,
[data-theme="light"] .auth-or::after {
  background: rgba(0,0,0,0.12);
}

[data-theme="light"] .btn-social {
  background: #fff;
  border-color: rgba(0,0,0,0.12);
  color: #333;
}
[data-theme="light"] .btn-social:hover {
  border-color: var(--primary);
  background: var(--primary-accent-bg);
}

[data-theme="light"] .auth-mobile-brand-name {
  color: rgba(13, 21, 32, 0.6);
}

/* ===== Autofill Override ===== */
.auth-input-group input:-webkit-autofill,
.auth-input-group input:-webkit-autofill:hover,
.auth-input-group input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--panel2) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}

[data-theme="light"] .auth-input-group input:-webkit-autofill,
[data-theme="light"] .auth-input-group input:-webkit-autofill:hover,
[data-theme="light"] .auth-input-group input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px rgba(248, 249, 252, 1) inset !important;
  -webkit-text-fill-color: #222 !important;
  caret-color: #222;
}

/* ===== Responsive — Mobile First ===== */
@media (max-width: 576px) {

  /* إخفاء الهيدر الخارجي في صفحات Auth على الجوال */
  body:has(.auth-wrap) .header {
    display: none !important;
  }

  /* إخفاء الفوتر الخارجي في صفحات Auth على الجوال */
  body:has(.auth-wrap) footer {
    display: none !important;
  }

  /* الـ auth-wrap يملأ كامل الشاشة */
  .auth-wrap {
    min-height: 100dvh;
    padding: 0;
    display: flex;
    align-items: stretch;
    border-radius: 0;
  }

  .auth-wrap > .container {
    width: 100%;
    max-width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .auth-grid {
    width: 100%;
    max-width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  /* الكارت يملأ كامل الشاشة */
  .auth-card {
    border-radius: 0;
    border: none;
    min-height: 100dvh;
    padding: 32px 24px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    backdrop-filter: none;
    box-shadow: none;
  }

  .auth-card:hover {
    border-color: transparent;
    box-shadow: none;
    transform: none;
  }

  /* إظهار شعار الموبايل داخل الكارت */
  .auth-mobile-brand {
    display: flex;
  }

  /* العنوان */
  .auth-title {
    font-size: 26px;
    margin-bottom: 8px;
  }

  .auth-subtitle {
    font-size: 13.5px;
  }

  /* الهيدر داخل الكارت */
  .auth-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
  }

  /* الروابط السريعة */
  .auth-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 20px;
  }

  /* حقول الإدخال */
  .auth-input-group {
    padding: 13px 16px;
    gap: 10px;
    border-radius: 14px;
  }

  .auth-input-group input {
    font-size: 14px;
  }

  /* الزر الرئيسي */
  .btn-auth {
    font-size: 15px;
    padding: 15px 20px;
    border-radius: 14px;
  }

  /* الفوتر داخل الكارد */
  .auth-foot {
    margin-top: 20px;
    padding-top: 16px;
    font-size: 12.5px;
  }

  /* إخفاء الـ glow في الجوال لأن الكارد بلا حواف */
  .auth-card-glow {
    display: none;
  }

  /* شريط ملون في أعلى الشاشة بدلاً من الـ glow */
  .auth-wrap::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-accent);
    z-index: 10;
  }

  /* تحسين الـ form gap */
  .auth-form {
    gap: 16px;
  }

  /* تحسين الـ checkbox label wrap */
  .checkbox-label {
    font-size: 13px;
    line-height: 1.5;
  }
}

/* أجهزة صغيرة جداً */
@media (max-width: 380px) {
  .auth-card {
    padding: 28px 20px 36px;
  }

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

  .auth-mobile-brand img,
  .auth-mobile-brand .themed-logo {
    width: 46px;
    height: 46px;
    max-width: 46px;
    max-height: 46px;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
