:root {
  --bg: #07070f;
  --bg2: #0d0d1a;
  --card: #12122a;
  --border: #1e1e3a;
  --text: #e8e8f5;
  --muted: #8a8aa8;
  --primary: #6366f1;
  --primary2: #8b5cf6;
  --cyan: #06b6d4;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 14px;
  --glow: 0 0 30px rgba(99, 102, 241, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  line-height: 1.7;
}

a { color: var(--primary2); text-decoration: none; }
a:hover { color: var(--cyan); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Starfield background */
.stars {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(99,102,241,0.06), transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(6,182,212,0.06), transparent 50%),
    radial-gradient(ellipse at 60% 30%, rgba(139,92,246,0.05), transparent 50%),
    var(--bg);
}

/* ─── Navbar ─── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 28px;
  background: rgba(13, 13, 26, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; flex-shrink: 0; }
.nav-brand .logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  box-shadow: var(--glow);
  flex-shrink: 0;
}
.nav-links { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.nav-links a { color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap; }
.nav-links a:hover { color: var(--text); }

@media (max-width: 560px) {
  .nav { padding: 12px 14px; }
  .nav-brand { font-size: 16px; }
  .nav-links { gap: 12px; width: 100%; justify-content: center; }
  .nav-links a { font-size: 13px; }
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: #fff;
  box-shadow: var(--glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 0 40px rgba(99,102,241,0.3); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--text); }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }
.btn-green { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.btn-green:hover { background: rgba(16, 185, 129, 0.25); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Cards ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.2s ease;
}
.card:hover { border-color: rgba(99,102,241,0.4); box-shadow: var(--glow); }
.card h3 { margin-bottom: 12px; font-size: 16px; }
.card .price { font-size: 32px; font-weight: 900; color: var(--primary2); }
.card .price span { font-size: 14px; color: var(--muted); font-weight: 400; }
.card ul { list-style: none; margin: 16px 0; }
.card ul li { padding: 6px 0; color: var(--muted); font-size: 14px; }
.card ul li::before { content: '✓ '; color: var(--green); }

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.form-group input::placeholder { color: #4a4a6a; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: right;
  padding: 12px 14px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
}
td { padding: 12px 14px; border-bottom: 1px solid rgba(30,30,58,0.5); white-space: nowrap; }
tr:hover td { background: rgba(99,102,241,0.04); }

/* ─── Badges ─── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge-green { background: rgba(16,185,129,0.15); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-blue { background: rgba(6,182,212,0.15); color: var(--cyan); }
.badge-purple { background: rgba(139,92,246,0.15); color: var(--primary2); }

/* ─── Layout ─── */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
@media (max-width: 560px) { .container { padding: 16px 14px; } }
.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }

/* Stat cards */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card .label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 900; }
.stat-card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 4px; height: 100%;
  background: linear-gradient(180deg, var(--primary), var(--cyan));
}

/* Hero */
.hero { text-align: center; padding: 70px 20px 40px; }
.hero h1 { font-size: 42px; font-weight: 900; background: linear-gradient(135deg, #fff, #a5b4fc, #67e8f9); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 16px; }
.hero p { color: var(--muted); font-size: 17px; max-width: 620px; margin: 0 auto 28px; }

/* Section titles */
.section-title { text-align: center; font-size: 26px; font-weight: 800; margin: 50px 0 24px; }
.section-title span { background: linear-gradient(135deg, var(--primary), var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 36px; box-shadow: var(--glow); }
.auth-card h2 { text-align: center; margin-bottom: 24px; font-size: 22px; }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-question {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary2);
  min-width: 90px;
  text-align: center;
  white-space: nowrap;
}
.captcha-refresh { cursor: pointer; color: var(--muted); font-size: 13px; }
.captcha-refresh:hover { color: var(--cyan); }

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 24px;
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 90vw;
  text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.success { border-color: var(--green); color: var(--green); }
#toast.error { border-color: var(--red); color: var(--red); }

/* Sidebar layout for dashboards */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 14px; display: flex; align-items: center; gap: 10px; font-weight: 800; }
.sidebar a.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: var(--muted);
  font-size: 14px;
  border-right: 3px solid transparent;
  transition: all 0.2s;
}
.sidebar a.side-link:hover { color: var(--text); background: rgba(99,102,241,0.06); }
.sidebar a.side-link.active { color: var(--primary2); border-right-color: var(--primary2); background: rgba(99,102,241,0.1); }
.sidebar .side-footer { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.main-content { flex: 1; min-width: 0; margin-right: 240px; padding: 28px; }
.main-content h2 { margin-bottom: 20px; font-size: 22px; }

/* Progress bar for quota */
.progress { background: var(--bg2); border-radius: 20px; height: 10px; overflow: hidden; margin: 8px 0; }
.progress .bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--cyan)); border-radius: 20px; transition: width 0.4s ease; }
.quota-text { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h3 { margin-bottom: 16px; }
.modal .modal-close { float: left; cursor: pointer; color: var(--muted); font-size: 18px; }
.modal .modal-close:hover { color: var(--text); }

/* Key display */
.key-display {
  background: var(--bg2);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  direction: ltr;
  text-align: center;
  word-break: break-all;
  color: var(--cyan);
  margin: 12px 0;
}

/* Code snippet for API usage */
.code-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: #9d9dc9;
  line-height: 1.6;
}
.code-block .c-key { color: var(--primary2); }
.code-block .c-str { color: var(--green); }
.code-block .c-com { color: #4a4a6a; }

/* Toggle switch */
.toggle { position: relative; width: 44px; height: 24px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; inset: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.3s;
}
.toggle .slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--muted);
  top: 3px; right: 3px;
  transition: 0.3s;
}
.toggle input:checked + .slider { background: linear-gradient(135deg, var(--primary), var(--primary2)); border-color: transparent; }
.toggle input:checked + .slider::before { transform: translateX(-20px); background: #fff; }

/* Empty state */
.empty { text-align: center; padding: 40px; color: var(--muted); }
.empty .icon { font-size: 40px; margin-bottom: 10px; }

/* Footer */
.footer { text-align: center; padding: 30px; color: #4a4a6a; font-size: 13px; border-top: 1px solid var(--border); margin-top: 50px; }

/* Health page status dots */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; }
.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 8px var(--red); }
.status-dot.unknown { background: var(--muted); }

/* Responsive */
@media (max-width: 768px) {
  .hero h1 { font-size: 28px; }
  .nav { padding: 12px 16px; }
  .nav-links { gap: 12px; }
  .sidebar { width: 200px; }
  .main-content { margin-right: 200px; padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ─── Mobile drawer nav (admin + dashboard sidebars) ─── */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 640px) {
  /* Keep the admin shell centered and full-width on narrow phones. */
  .app-layout {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  /* Top bar with hamburger */
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(13, 13, 26, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 120;
  }
  .mobile-topbar .mt-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; }
  .mobile-topbar .mt-brand .logo {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, var(--primary), var(--cyan));
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
  }
  .hamburger {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    padding: 6px 12px;
    cursor: pointer;
  }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    display: flex;
    flex-direction: column;
    transform: translateX(100%);   /* off-screen to the right (RTL) */
    transition: transform 0.28s ease;
    width: 260px;
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: -8px 0 30px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }

  .main-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 16px;
    box-sizing: border-box;
    align-self: stretch;
  }
  .main-content > .section,
  .main-content > .section.active,
  .main-content .card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .main-content .grid,
  .main-content .grid-2,
  .main-content .grid-4 {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* Dim backdrop when drawer is open */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
}

/* ─── Hamburger Navbar (public pages) ──────────────────────── */
.nav-hamburger { display: none; }
.nav-mobile-menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  position: absolute;
  top: 100%;
  right: 0; left: 0;
  background: rgba(13,13,26,0.98);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px 16px;
  z-index: 99;
}
.nav-mobile-menu.open { display: flex; }
.nav-mobile-menu a {
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.nav-mobile-menu a:last-child { border-bottom: none; }
.nav-mobile-menu a:hover { color: var(--text); }
.nav-mobile-menu .nav-mob-btns {
  display: flex; gap: 8px; margin-top: 12px;
}
.nav-mobile-menu .nav-mob-btns a {
  border-bottom: none;
  padding: 10px 12px;
  flex: 1;
  text-align: center;
  justify-content: center;
  font-weight: 700;
  border-radius: 10px;
  font-size: 14px;
  text-decoration: none;
}
.nav-mobile-menu .nav-mob-btns a.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.nav-mobile-menu .nav-mob-btns a.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--text);
}
.nav-mobile-menu .nav-mob-btns a.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
}

@media (max-width: 640px) {
  .nav-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-size: 20px;
    width: 38px; height: 38px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .nav-links { display: none !important; }
}


/* ─── Pricing Cards ─────────────────────────────── */
.pricing-card {
  position: relative;
}
.pricing-card .plan-badge {
  position: absolute;
  top: -12px;
  right: 50%;
  transform: translateX(50%);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  padding: 4px 16px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pricing-card .plan-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: -8px;
  margin-bottom: 16px;
}
.pricing-card .price-usd {
  font-size: 48px;
  font-weight: 900;
  color: var(--text);
  margin: 16px 0 8px;
}
.pricing-card .price-tooman {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 20px;
}
