/* ===== CSS Variables - Light Theme ===== */
:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  --bg-hover: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #eff6ff;
  --success: #22c55e;
  --success-light: #f0fdf4;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: .2s ease;
  --navbar-h: 64px;
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --bg-hover: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --primary-light: #1e3a5f;
  --success-light: #052e16;
  --danger-light: #450a0a;
  --warning-light: #451a03;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }

/* ===== Container ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 640px; margin: 0 auto; padding: 0 20px; }

/* ===== Navbar ===== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--navbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}
.navbar-inner {
  display: flex; align-items: center; gap: 24px;
  height: 100%;
}
.navbar-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.1rem; color: var(--text);
}
.brand-icon { font-size: 1.4rem; }
.navbar-nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 6px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: .9rem; font-weight: 500;
  transition: all var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: var(--bg-hover); color: var(--text);
}
.navbar-actions { display: flex; align-items: center; gap: 10px; margin-right: auto; }

/* ===== Theme Toggle ===== */
.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-input);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all var(--transition);
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; border: none;
  transition: all var(--transition); white-space: nowrap;
}
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,.35); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost:hover { background: var(--primary-light); color: var(--primary); }
[data-theme="dark"] .btn-ghost { background: transparent; color: #60a5fa; border-color: #60a5fa; }
[data-theme="dark"] .btn-ghost:hover { background: rgba(96,165,250,.12); color: #93c5fd; border-color: #93c5fd; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Cards ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden; transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-body { padding: 20px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.card-footer { padding: 16px 20px; border-top: 1px solid var(--border); background: var(--bg-input); }

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .875rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: inherit; font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
.form-hint { font-size: .8rem; color: var(--text-light); margin-top: 4px; }
.form-error { font-size: .8rem; color: var(--danger); margin-top: 4px; }

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .9rem; margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.alert-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }
[data-theme="dark"] .alert-success { color: #86efac; }
[data-theme="dark"] .alert-error { color: #fca5a5; }
[data-theme="dark"] .alert-warning { color: #fcd34d; }
[data-theme="dark"] .alert-info { color: #93c5fd; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.badge-sale { background: #dcfce7; color: #166534; }
.badge-buy { background: #dbeafe; color: #1e40af; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .badge-sale { background: #052e16; color: #86efac; }
[data-theme="dark"] .badge-buy { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-approved { background: #052e16; color: #86efac; }
[data-theme="dark"] .badge-pending { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge-cancelled { background: #450a0a; color: #fca5a5; }

/* ===== Ad Card ===== */
.ad-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: all var(--transition); position: relative;
}
.ad-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--primary); }
.ad-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.ad-card-id { font-size: .8rem; color: var(--text-light); }
.ad-card-type { font-size: 1.1rem; font-weight: 700; }
.ad-card-type.sale { color: var(--success); }
.ad-card-type.buy { color: var(--primary); }
.ad-card-body { display: grid; gap: 10px; }
.ad-row { display: flex; justify-content: space-between; align-items: center; }
.ad-label { font-size: .8rem; color: var(--text-muted); }
.ad-value { font-size: .9rem; font-weight: 600; }
.ad-price { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.ad-card-footer { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.ad-card-footer .btn { flex: 1; }

/* ===== Grid ===== */
.ads-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 50%, #3b82f6 100%);
  color: #fff; padding: 80px 0 60px; text-align: center; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-content { position: relative; z-index: 1; }
.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 16px; line-height: 1.3; }
.hero p { font-size: 1.1rem; opacity: .85; margin-bottom: 32px; max-width: 500px; margin-left: auto; margin-right: auto; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-actions .btn-primary { background: #fff; color: var(--primary-dark); }
.hero-actions .btn-primary:hover { background: #f0f9ff; }
.hero-actions .btn-outline { border-color: rgba(255,255,255,.6); color: #fff; }
.hero-actions .btn-outline:hover { background: rgba(255,255,255,.1); }

/* ===== Stats Bar ===== */
.stats-bar { background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 16px 0; }
.stats-inner {
  display: flex;
  gap: 32px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.stat-item { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.stat-icon { font-size: 1.4rem; }
.stat-label { font-size: .8rem; color: var(--text-muted); }
.stat-value { font-size: 1rem; font-weight: 700; }

@media (max-width: 600px) {
  .stats-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    justify-items: center;
  }
  .stat-item { flex-direction: column; text-align: center; gap: 4px; }
}

/* ===== Section ===== */
.section { padding: 48px 0; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.section-title { font-size: 1.4rem; font-weight: 700; }
.section-subtitle { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }

/* ===== Rates Table ===== */
.rates-table { width: 100%; border-collapse: collapse; }
.rates-table th { padding: 12px 16px; text-align: right; font-size: .8rem; color: var(--text-muted); font-weight: 500; border-bottom: 2px solid var(--border); }
.rates-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.rates-table tr:last-child td { border-bottom: none; }
.rates-table tr:hover td { background: var(--bg-hover); }
.rate-change.up { color: var(--success); }
.rate-change.down { color: var(--danger); }

/* ===== Filter Bar ===== */
.filter-bar { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 24px; }
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-group { flex: 1; min-width: 140px; }
.filter-group label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: 6px; }

/* ===== Pagination ===== */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 32px; }
.page-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-muted); font-size: .875rem; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Auth Pages ===== */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); }
.auth-logo { text-align: center; font-size: 2rem; margin-bottom: 8px; }
.auth-title { text-align: center; font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: .9rem; margin-bottom: 28px; }
.auth-divider { text-align: center; color: var(--text-light); font-size: .85rem; margin: 20px 0; position: relative; }
.auth-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.auth-divider span { background: var(--bg-card); padding: 0 12px; position: relative; }
.auth-footer { text-align: center; margin-top: 20px; font-size: .875rem; color: var(--text-muted); }

/* ===== Dashboard ===== */
.dashboard-layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - var(--navbar-h)); }
.sidebar { background: var(--bg-card); border-left: 1px solid var(--border); padding: 24px 0; position: sticky; top: var(--navbar-h); height: calc(100vh - var(--navbar-h)); overflow-y: auto; }
.sidebar-section { margin-bottom: 8px; }
.sidebar-label { font-size: .75rem; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: .05em; padding: 8px 20px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--text-muted); font-size: .9rem;
  transition: all var(--transition); border-right: 3px solid transparent;
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-link.active { background: var(--primary-light); color: var(--primary); border-right-color: var(--primary); font-weight: 600; }
.sidebar-icon { font-size: 1rem; width: 20px; text-align: center; }
.dashboard-main { padding: 28px; overflow-y: auto; }
.dashboard-header { margin-bottom: 28px; }
.dashboard-title { font-size: 1.5rem; font-weight: 700; }
.dashboard-subtitle { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }

/* ===== Stat Cards ===== */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card-icon { font-size: 1.8rem; margin-bottom: 12px; }
.stat-card-value { font-size: 1.6rem; font-weight: 800; }
.stat-card-label { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { padding: 12px 16px; text-align: right; font-weight: 600; color: var(--text-muted); background: var(--bg-input); border-bottom: 2px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-hover); }

/* ===== User Menu ===== */
.nav-user { position: relative; }
.nav-user-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: .875rem; font-weight: 500;
  transition: all var(--transition);
}
.nav-user-btn:hover { background: var(--bg-hover); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
}
.nav-user-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 180px; padding: 6px; z-index: 200;
  display: none;
}
.nav-user-dropdown.open { display: block; }
.nav-user-dropdown a {
  display: block; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-size: .875rem;
  transition: background var(--transition);
}
.nav-user-dropdown a:hover { background: var(--bg-hover); }
.nav-user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.text-danger { color: var(--danger) !important; }

/* ===== Mobile Nav ===== */
.nav-hamburger { display: none; flex-direction: column; gap: 5px; padding: 6px; background: none; border: none; }
.nav-hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: all var(--transition); }
.nav-mobile { position: fixed; top: 0; right: -280px; width: 280px; height: 100vh; background: var(--bg-card); border-left: 1px solid var(--border); padding: 0; z-index: 300; transition: right var(--transition); display: flex; flex-direction: column; overflow: hidden; }
.nav-mobile.open { right: 0; }
.nav-mobile-header { background: linear-gradient(135deg, #1e3a5f, #3b82f6); padding: 28px 20px 20px; display: flex; align-items: center; gap: 12px; color: #fff; flex-shrink: 0; border-bottom: 1px solid rgba(255,255,255,.15); }
.nav-mobile-links { flex: 1; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; }
.nav-mobile-links a { display: flex; align-items: center; gap: 12px; padding: 13px 20px; color: var(--text); font-size: .95rem; text-decoration: none; transition: background var(--transition); }
.nav-mobile-links a:hover { background: var(--bg-hover); }
.nav-mobile-links a span:first-child { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-mobile-links hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.nav-mobile-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 299; display: none; }
.nav-mobile-overlay.open { display: block; }

/* ===== Footer ===== */
.footer { background: var(--bg-card); border-top: 1px solid var(--border); padding: 48px 0 24px; margin-top: 60px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; margin-bottom: 32px; }
.footer-brand .brand-logo { font-size: 1.2rem; font-weight: 700; margin-bottom: 10px; }
.footer-brand p { color: var(--text-muted); font-size: .875rem; line-height: 1.7; }
.footer-social { display: flex; gap: 8px; margin-top: 16px; }
.social-btn { padding: 6px 14px; border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text-muted); font-size: .8rem; border: 1px solid var(--border); transition: all var(--transition); }
.social-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.footer-links h4 { font-size: .9rem; font-weight: 600; margin-bottom: 14px; }
.footer-links a { display: block; color: var(--text-muted); font-size: .875rem; padding: 4px 0; transition: color var(--transition); }
.footer-links a:hover { color: var(--primary); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 20px; text-align: center; color: var(--text-light); font-size: .8rem; }

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 16px; } .d-flex { display: flex; } .align-center { align-items: center; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .navbar-nav { display: none; }
  .nav-hamburger { display: flex; }
  .hero h1 { font-size: 1.8rem; }
  .ads-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .dashboard-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .stats-inner { gap: 20px; }
  .filter-row { flex-direction: column; }
  .filter-group { min-width: 100%; }
}
@media (max-width: 480px) {
  .auth-card { padding: 24px 20px; }
  .hero { padding: 48px 0 40px; }
}

/* ===== Contact Page ===== */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
@media (max-width: 768px) { .contact-grid { grid-template-columns: 1fr !important; } }
