/* ==========================================================
   KDF DAIRIES — Accounting Dashboard
   Bootstrap 5.3 + Bootstrap Icons
   ========================================================== */

:root {
  --primary: #7e22ce;
  --primary-2: #a855f7;
  --primary-3: #c084fc;
  --primary-glow: rgba(168, 85, 247, .55);
  --navbar-grad: linear-gradient(90deg, #6d28d9 0%, #9333ea 50%, #a855f7 100%);
  --sidebar-bg: rgba(15, 17, 26, .88);
  --sidebar-bg-2: rgba(15, 17, 26, .72);
  --sidebar-text: #e5e7eb;
  --sidebar-muted: #94a3b8;
  --sidebar-active: linear-gradient(135deg, #7e22ce 0%, #a855f7 100%);
  --content-bg: #f3f4f8;
  --card-bg: #ffffff;
  --card-border: #ececf3;
  --text: #1f2937;
  --text-muted: #6b7280;
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, .06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 40px rgba(126, 34, 206, .18);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-width: 280px;
  --navbar-height: 68px;
  --transition: all .25s ease;
}

[data-theme="dark"] {
  --content-bg: #0b0d14;
  --card-bg: #151823;
  --card-border: #232838;
  --text: #e5e7eb;
  --text-muted: #94a3b8;
  --shadow-sm: 0 2px 6px rgba(0,0,0,.4);
  --shadow-md: 0 8px 24px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--content-bg);
  color: var(--text);
  letter-spacing: .1px;
}

a { text-decoration: none; }

/* ============ LAYOUT ============ */
.app {
  display: flex;
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background-image:
    linear-gradient(var(--sidebar-bg), var(--sidebar-bg-2)),
    url('https://images.unsplash.com/photo-1483728642387-6c3bdd6c93e5?auto=format&fit=crop&w=900&q=80');
  background-size: cover;
  background-position: center;
  color: var(--sidebar-text);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform .3s ease;
  box-shadow: 4px 0 24px rgba(0,0,0,.25);
}

.sidebar-brand {
  padding: 22px 22px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--sidebar-active);
  display: grid; place-items: center;
  color: #fff; font-size: 20px;
  box-shadow: 0 0 14px var(--primary-glow);
}
.sidebar-brand h1 {
  font-size: 18px; font-weight: 700;
  margin: 0; letter-spacing: 1px; color: #fff;
}

.sidebar-user {
  padding: 16px 18px;
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.04);
  margin: 14px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,.06);
}
.sidebar-user img {
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid var(--primary-2);
}
.sidebar-user .name { font-weight: 600; font-size: 14px; color: #fff; line-height: 1.1; }
.sidebar-user .role { font-size: 12px; color: var(--sidebar-muted); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-nav .nav-item { margin: 4px 0; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 500;
  transition: var(--transition);
  position: relative;
}
.sidebar-nav .nav-link i {
  font-size: 18px; width: 22px; text-align: center;
  opacity: .9;
}
.sidebar-nav .nav-link:hover {
  background: rgba(168, 85, 247, .15);
  color: #fff;
  transform: translateX(3px);
}
.sidebar-nav .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 6px 18px var(--primary-glow);
}
.sidebar-nav .nav-link.active::before {
  content: "";
  position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 4px; border-radius: 4px;
  background: #fff;
  box-shadow: 0 0 10px #fff;
}

/* ============ MAIN ============ */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex; flex-direction: column;
  min-width: 0;
}

/* ============ TOP NAVBAR ============ */
.topbar {
  height: var(--navbar-height);
  background: var(--navbar-grad);
  position: sticky; top: 0; z-index: 1030;
  display: flex; align-items: center;
  padding: 0 22px;
  color: #fff;
  box-shadow: 0 4px 20px rgba(126, 34, 206, .25);
}
.topbar .menu-btn {
  background: rgba(255,255,255,.18);
  border: 0; color: #fff;
  width: 42px; height: 42px; border-radius: 10px;
  display: none; align-items: center; justify-content: center;
  font-size: 20px; margin-right: 12px;
}
.topbar .home-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: grid; place-items: center;
  color: #fff; font-size: 18px;
  transition: var(--transition);
}
.topbar .home-btn:hover { background: rgba(255,255,255,.32); transform: scale(1.05); }

.topbar-nav {
  display: flex; align-items: center; gap: 4px;
  margin-left: 18px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar-nav::-webkit-scrollbar { display: none; }
.topbar-nav .nav-link {
  color: rgba(255,255,255,.92);
  font-weight: 500; font-size: 15px;
  padding: 8px 16px; border-radius: 8px;
  white-space: nowrap;
  transition: var(--transition);
}
.topbar-nav .nav-link:hover, .topbar-nav .nav-link.active {
  background: rgba(255,255,255,.18);
  color: #fff;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-actions .icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 0; color: #fff; font-size: 18px;
  display: grid; place-items: center;
  position: relative; cursor: pointer;
  transition: var(--transition);
}
.topbar-actions .icon-btn:hover { background: rgba(255,255,255,.3); transform: translateY(-2px); }
.topbar-actions .badge-dot {
  position: absolute; top: 6px; right: 6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid #9333ea;
}
.topbar-actions .avatar {
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid #fff;
  object-fit: cover;
}

/* ============ CONTENT ============ */
.content {
  padding: 26px;
  flex: 1;
}

.page-title {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 22px;
}
.page-title h2 { font-size: 24px; font-weight: 700; margin: 0; }
.page-title p { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }

/* ============ STAT CARDS ============ */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  height: 100%;
}
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.stat-card .stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 24px; color: #fff;
  margin-bottom: 14px;
  box-shadow: 0 8px 18px rgba(0,0,0,.12);
}
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin: 4px 0; }
.stat-card .stat-change { font-size: 12px; font-weight: 600; }
.stat-change.up { color: #16a34a; }
.stat-change.down { color: #dc2626; }

.bg-grad-violet { background: linear-gradient(135deg, #7e22ce, #c084fc); }
.bg-grad-blue   { background: linear-gradient(135deg, #2563eb, #60a5fa); }
.bg-grad-green  { background: linear-gradient(135deg, #15803d, #4ade80); }
.bg-grad-orange { background: linear-gradient(135deg, #ea580c, #fbbf24); }
.bg-grad-pink   { background: linear-gradient(135deg, #db2777, #f472b6); }
.bg-grad-teal   { background: linear-gradient(135deg, #0f766e, #2dd4bf); }

/* ============ PANELS ============ */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  height: 100%;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.panel-title { font-size: 16px; font-weight: 700; margin: 0; }

/* ============ TABLE ============ */
.table-modern {
  width: 100%;
  border-collapse: separate; border-spacing: 0;
  font-size: 14px;
}
.table-modern thead th {
  text-align: left; padding: 12px 14px;
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--card-border);
  letter-spacing: .5px;
}
.table-modern tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text);
}
.table-modern tbody tr:last-child td { border-bottom: 0; }
.table-modern tbody tr { transition: var(--transition); }
.table-modern tbody tr:hover { background: rgba(168, 85, 247, .06); }

.pill {
  padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  display: inline-block;
}
.pill-success { background: rgba(34,197,94,.12); color: #16a34a; }
.pill-warn    { background: rgba(245,158,11,.14); color: #d97706; }
.pill-danger  { background: rgba(239,68,68,.12); color: #dc2626; }
.pill-info    { background: rgba(59,130,246,.12); color: #2563eb; }

/* ============ CHART ============ */
.chart-wrap { height: 280px; position: relative; }

/* ============ QUICK ACTIONS ============ */
.quick-action {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-weight: 600; font-size: 14px;
  transition: var(--transition);
  cursor: pointer;
  width: 100%;
}
.quick-action:hover {
  border-color: var(--primary-2);
  box-shadow: 0 6px 18px var(--primary-glow);
  transform: translateY(-2px);
  color: var(--primary);
}
.quick-action i {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--sidebar-active); color: #fff;
  font-size: 18px;
}

/* ============ THEME TOGGLE ============ */
.theme-toggle {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 0; color: #fff; font-size: 18px;
  display: grid; place-items: center;
  cursor: pointer; transition: var(--transition);
}
.theme-toggle:hover { background: rgba(255,255,255,.3); transform: rotate(15deg); }

/* ============ LOADING ============ */
.page-loader {
  position: fixed; inset: 0;
  background: var(--navbar-grad);
  display: grid; place-items: center;
  z-index: 9999;
  transition: opacity .4s ease;
}
.page-loader.hide { opacity: 0; pointer-events: none; }
.loader-ring {
  width: 56px; height: 56px;
  border: 4px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ MOBILE BACKDROP ============ */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1035;
}
.sidebar-backdrop.show { display: block; }

/* ============ DROPDOWN ============ */
.dropdown-menu {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  background: var(--card-bg);
  color: var(--text);
}
.dropdown-item { color: var(--text); padding: 9px 14px; font-size: 14px; }
.dropdown-item:hover { background: rgba(168,85,247,.1); color: var(--primary); }

/* ============ ANIMATIONS ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp .5s ease both; }
.delay-1 { animation-delay: .05s; }
.delay-2 { animation-delay: .1s; }
.delay-3 { animation-delay: .15s; }
.delay-4 { animation-delay: .2s; }
.delay-5 { animation-delay: .25s; }
.delay-6 { animation-delay: .3s; }

/* ============ RESPONSIVE ============ */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: grid; }
  .topbar-nav { display: none; }
}

@media (max-width: 575.98px) {
  .content { padding: 16px; }
  .topbar { padding: 0 14px; }
  .topbar-actions .icon-btn,
  .topbar-actions .avatar,
  .topbar .home-btn { width: 38px; height: 38px; }
  .stat-card .stat-value { font-size: 22px; }
}
