/* ===================================================================
   auth.css — ملک بازار - صفحه ورود
   Mobile-First, Premium, Optimized for Real Devices
   No frameworks, pure CSS
=================================================================== */

/* ============ CSS Custom Properties ============ */
:root {
  /* Colors */
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-active: #1E40AF;
  --primary-light: #EFF4FF;
  --bg: #FFFFFF;
  --text: #1F2937;
  --text-secondary: #6B7280;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --danger: #EF4444;
  --white: #FFFFFF;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.1);
  --shadow-primary: 0 8px 22px rgba(37, 99, 235, 0.22);
  --shadow-dropdown: 0 12px 35px rgba(0, 0, 0, 0.1);

  /* Border Radius */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.46, 0.64, 1);
  --transition-fast: 150ms;
  --transition-base: 250ms;
  --transition-slow: 400ms;

  /* Typography */
  --font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 14px;
  --font-size-md: 15px;
  --font-size-lg: 30px;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  /* Layout */
  --max-width: 420px;
  --header-height: 56px;
}

/* ============ Reset ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

a {
  text-decoration: none;
  color: inherit;
}

input {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
}

/* ============ Focus States ============ */
:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============ Page Loader ============ */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.page-loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============ Main Container ============ */
.auth-container {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: relative;
  background: var(--bg);
  opacity: 0;
  animation: fadeIn 0.6s var(--ease-out) forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ Top Navigation Bar ============ */
.auth-header {
  flex-shrink: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
}

.top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
}

/* Icon Buttons */
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast) var(--ease-out);
  position: relative;
  background: transparent;
}

.icon-btn:hover {
  background: var(--border-light);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.93);
  background: var(--border);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ============ Settings Dropdown ============ */
.settings-wrapper {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 190px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  border: 1px solid var(--border);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all var(--transition-base) var(--ease-out);
  z-index: 100;
  pointer-events: none;
}

.dropdown-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast) var(--ease-out);
  cursor: pointer;
  text-align: right;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.dropdown-item:active {
  background: var(--border);
  transform: scale(0.98);
}

.dropdown-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.dropdown-item:hover svg {
  color: var(--primary);
}

/* ============ Main Content ============ */
.auth-content {
  /* flex: 1; */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px 0;
}

/* ============ Logo Section ============ */
.logo-section {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.logo-wrapper img {
  width: 250px;
  height: auto;
  filter: drop-shadow(0 8px 14px rgba(37, 99, 235, 0.12));
}

/* ============ Title Section ============ */
.title-section {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.main-description {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.8;
  max-width: 280px;
  text-align: center;
}

/* ============ Phone Input Section ============ */
.phone-input-section {
  width: 100%;
  max-width: 320px;
}

.phone-input-wrapper {
  position: relative;
}

.phone-input {
  width: 100%;
  height: 50px;
  background: var(--border-light);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0 16px;
  font-size: 16px; /* Prevents iOS auto-zoom */
  font-weight: 500;
  color: var(--text);
  text-align: center;
  direction: ltr;
  transition: all var(--transition-fast) var(--ease-out);
}

.phone-input::placeholder {
  color: #9CA3AF;
  font-size: var(--font-size-sm);
  font-weight: 400;
}

.phone-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: var(--white);
}
.code-input {
  width: 100%;
  height: 50px;
  background: var(--border-light);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0 16px;
  font-size: 16px; /* Prevents iOS auto-zoom */
  font-weight: 500;
  color: var(--text);
  text-align: center;
  direction: ltr;
  transition: all var(--transition-fast) var(--ease-out);
}

.code-input::placeholder {
  color: #9CA3AF;
  font-size: var(--font-size-sm);
  font-weight: 400;
}

.code-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: var(--white);
}
.name-input {
  width: 100%;
  height: 50px;
  background: var(--border-light);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0 16px;
  font-size: 16px; /* Prevents iOS auto-zoom */
  font-weight: 500;
  color: var(--text);
  text-align: center;
  direction: ltr;
  transition: all var(--transition-fast) var(--ease-out);
}
.code2-input {
  width: 100%;
  height: 50px;
  background: var(--border-light);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0 16px;
  font-size: 16px; /* Prevents iOS auto-zoom */
  font-weight: 500;
  color: var(--text);
  text-align: center;
  direction: ltr;
  transition: all var(--transition-fast) var(--ease-out);
}

.code2-input::placeholder {
  color: #9CA3AF;
  font-size: var(--font-size-sm);
  font-weight: 400;
}

.code2-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: var(--white);
}
.name-input {
  width: 100%;
  height: 50px;
  background: var(--border-light);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0 16px;
  font-size: 16px; /* Prevents iOS auto-zoom */
  font-weight: 500;
  color: var(--text);
  text-align: center;
  direction: ltr;
  transition: all var(--transition-fast) var(--ease-out);
}

.name-input::placeholder {
  color: #9CA3AF;
  font-size: var(--font-size-sm);
  font-weight: 400;
}

.name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: var(--white);
}

/* ============ Buttons Section ============ */
.buttons-section {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-top: 4px;
}

.btn {
  width: 100%;
  height: 50px;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast) var(--ease-out);
  cursor: pointer;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-text {
  position: relative;
  z-index: 2;
  pointer-events: none;
}

/* Primary Button */
.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: var(--primary-active);
  transform: scale(0.97);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

/* Secondary Button */
.btn-secondary {
  background: var(--white);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border-light);
  border-color: #D1D5DB;
}

.btn-secondary:active {
  background: var(--border);
  transform: scale(0.97);
}

/* ============ Ripple Effect ============ */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0);
  animation: rippleEffect 0.6s ease-out;
  pointer-events: none;
  z-index: 1;
}

.btn-secondary .ripple {
  background: rgba(0, 0, 0, 0.08);
}

@keyframes rippleEffect {
  to { transform: scale(4); opacity: 0; }
}

/* ============ Footer Section ============ */
.auth-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 20px 0 8px;
}

.footer-text {
  font-size: var(--font-size-xs);
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.9;
  max-width: 300px;
  margin: 0 auto;
}

.footer-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
}

.footer-link:hover {
  color: var(--primary-hover);
  background: var(--primary-light);
}

.footer-link:active {
  color: var(--primary-active);
}

/* ============ Toast Notification ============ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1F2937;
  color: var(--white);
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all var(--transition-base) var(--ease-spring);
  z-index: 1000;
  white-space: nowrap;
  max-width: calc(100% - 32px);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ============ Responsive Design ============ */

/* 320px - Small devices */
@media (max-width: 320px) {
  .auth-container {
    padding: 16px 12px;
  }
  
  .logo-wrapper img {
    width: 250px !important;
  }
  
  .main-description {
    font-size: 11px;
    max-width: 240px;
  }
  
  .btn {
    height: 46px;
    font-size: 12px;
  }
  
  .phone-input {
    height: 46px;
    font-size: 15px;
  }
}

/* 360px */
@media (min-width: 360px) {
  .logo-wrapper img {
    width: 250px;
  }
  
  .main-description {
    max-width: 300px;
  }
}

/* 390px - iPhone 14 */
@media (min-width: 390px) {
  .auth-content {
    gap: 32px;
  }
  
  .logo-wrapper img {
    width: 250px;
  }
}

/* 412px */
@media (min-width: 412px) {
  .auth-content {
    gap: 36px;
  }
  
  .btn {
    height: 52px;
    font-size: var(--font-size-base);
  }
  
  .phone-input {
    height: 52px;
    font-size: 16px;
  }
}

/* 768px - Tablet */
@media (min-width: 768px) {
  .auth-container {
    padding: 32px 24px;
  }
  
  .logo-wrapper img {
    width: 250px;
  }
  
  .main-description {
    font-size: var(--font-size-base);
    max-width: 340px;
  }
  
  .btn {
    height: 54px;
    font-size: var(--font-size-md);
  }
  
  .phone-input {
    height: 54px;
    font-size: 17px;
  }
  
  .icon-btn {
    width: 46px;
    height: 46px;
  }
  
  .icon-btn svg {
    width: 24px;
    height: 24px;
  }
}
[data-theme="dark"] {
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-active: #1D4ED8;
  --primary-light: #1E293B;
  --bg: #0F172A;
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --border: #334155;
  --border-light: #1E293B;
  --danger: #EF4444;
  --white: #FFFFFF;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --shadow-primary: 0 8px 22px rgba(59, 130, 246, 0.25);
  --shadow-dropdown: 0 12px 35px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .page-loader {
  background: var(--bg);
}

[data-theme="dark"] .loader-spinner {
  border-color: var(--border);
  border-top-color: var(--primary);
}

[data-theme="dark"] .auth-container {
  background: var(--bg);
}

[data-theme="dark"] .icon-btn:hover {
  background: var(--border-light);
  color: var(--text);
}

[data-theme="dark"] .icon-btn:active {
  background: var(--border);
}

[data-theme="dark"] .dropdown-menu {
  background: #1E293B;
  border-color: var(--border);
}

[data-theme="dark"] .dropdown-item {
  color: var(--text);
}

[data-theme="dark"] .dropdown-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

[data-theme="dark"] .dropdown-item:active {
  background: var(--border);
}

[data-theme="dark"] .dropdown-item svg {
  color: var(--text-secondary);
}

[data-theme="dark"] .dropdown-item:hover svg {
  color: var(--primary);
}

[data-theme="dark"] .phone-input {
  background: var(--border-light);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .phone-input::placeholder {
  color: #64748B;
}

[data-theme="dark"] .phone-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: var(--bg);
}

[data-theme="dark"] .btn-secondary {
  background: #1E293B;
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .btn-secondary:hover {
  background: var(--border-light);
  border-color: #475569;
}

[data-theme="dark"] .btn-secondary:active {
  background: var(--border);
}

[data-theme="dark"] .btn-secondary .ripple {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .toast {
  background: #F1F5F9;
  color: #0F172A;
}