/* ═══════════════════════════════════════════════════════════
   VPN Accounting — Design System Tokens & Base Styles
═══════════════════════════════════════════════════════════ */

:root {
  /* Dark theme (default) */
  --bg-base:      #070d1a;
  --bg-surface:   #0d1528;
  --bg-card:      #111e38;
  --bg-card-hover:#162544;
  --bg-input:     #0a1020;
  --bg-modal:     rgba(7,13,26,0.92);
  --border:       rgba(255,255,255,0.07);
  --border-focus: #4361ee;

  --text-1:  #f0f2f8;
  --text-2:  #8b93b0;
  --text-3:  #4a5068;

  /* Brand colors */
  --blue:    #4361ee;
  --blue-lt: #6b84f5;
  --cyan:    #06d6a0;
  --green:   #2ecc71;
  --red:     #ef476f;
  --amber:   #f4a261;
  --purple:  #7b2d8b;

  /* Semantic */
  --income-color:  var(--cyan);
  --expense-color: var(--red);
  --profit-color:  var(--blue);
  --debt-color:    var(--amber);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);

  /* Transitions */
  --t-fast: 150ms ease;
  --t-med:  250ms ease;

  /* Radius */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  24px;

  /* Sidebar */
  --sidebar-w: 240px;
}

[data-theme="light"] {
  --bg-base:      #f0f4ff;
  --bg-surface:   #ffffff;
  --bg-card:      #ffffff;
  --bg-card-hover:#f5f7ff;
  --bg-input:     #f8f9ff;
  --bg-modal:     rgba(240,244,255,0.95);
  --border:       rgba(0,0,0,0.08);
  --border-focus: #4361ee;
  --text-1:  #111827;
  --text-2:  #4b5563;
  --text-3:  #9ca3af;
  --blue:    #3b54df;
  --cyan:    #059669;
  --red:     #dc2626;
  --amber:   #d97706;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; direction: rtl; }

body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-1);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--t-med), color var(--t-med);
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-1);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.55rem 0.85rem;
  width: 100%;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(67,97,238,0.15);
}
textarea { resize: vertical; min-height: 70px; }

/* ── Utility ── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

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

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--r-sm);
  font-size: 0.875rem; font-weight: 500;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 12px rgba(67,97,238,0.35);
}
.btn-primary:hover { background: var(--blue-lt); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(67,97,238,0.45); }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-ghost   { background: var(--bg-card); color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-1); }
.btn-sm      { padding: 0.35rem 0.85rem; font-size: 0.8rem; }
.btn-full    { width: 100%; justify-content: center; }
.btn-icon    { padding: 0.4rem; border-radius: var(--r-sm); }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.card:hover { background: var(--bg-card-hover); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.card-title { font-size: 0.9rem; font-weight: 600; color: var(--text-2); }

/* KPI Cards */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
  position: relative; overflow: hidden;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-card::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 4px; height: 100%;
  background: var(--kpi-color, var(--blue));
}
.kpi-label { font-size: 0.8rem; color: var(--text-2); margin-bottom: 0.5rem; }
.kpi-value {
  font-size: 1.6rem; font-weight: 700;
  color: var(--kpi-color, var(--text-1));
  letter-spacing: -0.5px;
}
.kpi-sub { font-size: 0.75rem; color: var(--text-3); margin-top: 0.25rem; }
.kpi-icon {
  position: absolute; left: 1rem; top: 50%;
  transform: translateY(-50%);
  font-size: 2rem; opacity: 0.15;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: right; padding: 0.75rem 1rem;
  font-size: 0.78rem; font-weight: 600;
  color: var(--text-3); text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-hover); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem; font-weight: 600;
  white-space: nowrap;
}
.badge-income  { background: rgba(6,214,160,0.15); color: var(--cyan); }
.badge-expense { background: rgba(239,71,111,0.15); color: var(--red); }
.badge-transfer{ background: rgba(67,97,238,0.15);  color: var(--blue); }
.badge-debt    { background: rgba(244,162,97,0.15); color: var(--amber); }
.badge-active  { background: rgba(6,214,160,0.12); color: var(--cyan); }
.badge-inactive{ background: rgba(139,147,176,0.15); color: var(--text-2); }
.badge-bot     { background: rgba(123,45,139,0.15); color: #c084fc; }

/* ── Spinner ── */
.loading-spinner {
  display: flex; align-items: center; justify-content: center;
  min-height: 300px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toasts ── */
#toast-container {
  position: fixed; bottom: 1.5rem; left: 1.5rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.75rem 1.25rem;
  min-width: 280px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}
.toast-success { border-right: 4px solid var(--cyan); }
.toast-error   { border-right: 4px solid var(--red); }
.toast-info    { border-right: 4px solid var(--blue); }
@keyframes slideUp { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(67,97,238,0.15) 0%, transparent 70%);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 2.5rem;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center; margin-bottom: 2rem;
}
.login-logo .logo-icon { font-size: 3rem; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; margin-top: 0.5rem; }
.login-logo p { color: var(--text-2); font-size: 0.875rem; }
.login-error {
  color: var(--red); font-size: 0.85rem;
  text-align: center; margin-top: 0.5rem;
}

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: 3rem;
  color: var(--text-3);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: 0.875rem; }

/* ── Debt Highlight ── */
.debt-amount {
  font-size: 1.1rem; font-weight: 700;
  color: var(--red);
}
.debt-zero { color: var(--cyan); }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 0.25rem;
  background: var(--bg-input);
  border-radius: var(--r-sm);
  padding: 0.25rem;
  margin-bottom: 1.5rem;
}
.tab-btn {
  flex: 1; padding: 0.5rem 1rem;
  border-radius: calc(var(--r-sm) - 2px);
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-2);
  transition: all var(--t-fast);
}
.tab-btn.active {
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Print ── */
@media print {
  .sidebar, .topbar, .btn, .tabs, .filter-bar { display: none !important; }
  .main-content { margin: 0 !important; padding: 0.5rem !important; }
  .card { border: none !important; box-shadow: none !important; page-break-inside: avoid; }
  body { background: #fff !important; color: #000 !important; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .kpi-value { font-size: 1.3rem; }
  th, td { padding: 0.6rem 0.5rem; font-size: 0.8rem; }
}
