/* ============================================
   Accounts Manager - Main Stylesheet
   ============================================ */

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1a2332;
  --sidebar-hover: #2c3e50;
  --primary-color: #0d6efd;
  --topbar-height: 64px;
  --content-bg: #f5f7fa;
  --card-bg: #ffffff;
  --text-color: #212529;
  --border-color: #e5e7eb;
}

[data-bs-theme="dark"] {
  --sidebar-bg: #0d1117;
  --sidebar-hover: #161b22;
  --content-bg: #0d1117;
  --card-bg: #161b22;
  --text-color: #e6edf3;
  --border-color: #30363d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--content-bg);
  color: var(--text-color);
  min-height: 100vh;
}

[data-bs-theme="dark"] body {
  background: var(--content-bg);
}

[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .table {
  background-color: var(--card-bg);
  color: var(--text-color);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #1c2128;
  border-color: var(--border-color);
  color: var(--text-color);
}

[data-bs-theme="dark"] .modal-content {
  background-color: var(--card-bg);
  color: var(--text-color);
}

/* ===== App Layout ===== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #d1d5db;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1050;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand img {
  max-height: 36px;
  max-width: 36px;
  border-radius: 6px;
}
.sidebar-brand i { font-size: 1.6rem; color: var(--primary-color); }

.btn-close-sidebar {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 1.25rem;
}

.sidebar-nav {
  list-style: none;
  padding: 1rem 0;
  margin: 0;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 1.5rem;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--primary-color);
}

.sidebar-nav a.text-danger { color: #fca5a5 !important; }
.sidebar-nav a.text-danger:hover { background: rgba(239,68,68,.15); color: #ff6b6b !important; }

.sidebar-nav i { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1040;
}
.sidebar-overlay.show { display: block; }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
}

.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 999;
}

.content-area {
  padding: 1.5rem;
  flex: 1;
}

/* ===== Mobile Navbar ===== */
.mobile-navbar { z-index: 1030; }

/* ===== Cards ===== */
.card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.stat-card {
  border-left: 4px solid var(--primary-color);
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: #fff;
}
.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}
.stat-card .stat-label {
  font-size: 0.85rem;
  color: #6b7280;
  margin: 0;
}

.bg-revenue   { background: linear-gradient(135deg,#10b981,#059669); }
.bg-classes   { background: linear-gradient(135deg,#3b82f6,#1d4ed8); }
.bg-clients   { background: linear-gradient(135deg,#8b5cf6,#6d28d9); }
.bg-profit    { background: linear-gradient(135deg,#f59e0b,#d97706); }
.bg-payout    { background: linear-gradient(135deg,#ef4444,#b91c1c); }
.bg-investment{ background: linear-gradient(135deg,#06b6d4,#0891b2); }
.bg-expense   { background: linear-gradient(135deg,#f43f5e,#be123c); }

.stat-card.border-revenue { border-left-color: #10b981; }
.stat-card.border-classes { border-left-color: #3b82f6; }
.stat-card.border-clients { border-left-color: #8b5cf6; }
.stat-card.border-profit  { border-left-color: #f59e0b; }
.stat-card.border-payout  { border-left-color: #ef4444; }
.stat-card.border-investment { border-left-color: #06b6d4; }

/* ===== Global Search Dropdown ===== */
.global-search { padding-right: 2.5rem; }
.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  display: none;
  z-index: 1100;
}
.search-results-dropdown.show { display: block; }
.search-result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  display: block;
  text-decoration: none;
  color: var(--text-color);
}
.search-result-item:last-child { border-bottom: 0; }
.search-result-item:hover { background: rgba(13,110,253,.08); }
.search-result-item .badge { font-size: .7rem; }

/* ===== Tables ===== */
.table-responsive { border-radius: 10px; overflow: hidden; }
.table thead th {
  background: #f8fafc;
  border-bottom: 2px solid var(--border-color);
  font-weight: 600;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #475569;
}
[data-bs-theme="dark"] .table thead th { background: #21262d; color: #c9d1d9; }

/* ===== Forms ===== */
.form-label { font-weight: 500; font-size: .9rem; }

/* ===== Buttons ===== */
.btn { font-weight: 500; }
.btn i { margin-right: 4px; }

/* ===== Login ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea, #764ba2);
  padding: 1rem;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-card .logo {
  width: 80px; height: 80px;
  border-radius: 16px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 2rem;
  margin: 0 auto 1.5rem;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    width: 100%;
    padding-top: 56px; /* mobile navbar height */
  }
  .content-area { padding: 1rem; }
  .stat-card .stat-value { font-size: 1.25rem; }
}

/* ===== Print ===== */
@media print {
  .sidebar, .topbar, .mobile-navbar, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
}

/* ===== Misc ===== */
.cursor-pointer { cursor: pointer; }
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.badge-soft-success { background: rgba(16,185,129,.15); color: #047857; }
.badge-soft-warning { background: rgba(245,158,11,.15); color: #b45309; }
.badge-soft-danger  { background: rgba(239,68,68,.15);  color: #b91c1c; }
.badge-soft-info    { background: rgba(6,182,212,.15);  color: #0e7490; }
