/* ==========================================================================
   KELASKAS — PREMIUM DESIGN SYSTEM (Vanilla CSS)
   Target: Blade Templating + DirectAdmin Shared Hosting (No Node.js needed)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Color Palette - Vibrant Dark-mode Ready Indigo & Slate */
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-200: #c7d2fe;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;

  /* Financial Colors */
  --income-bg: rgba(16, 185, 129, 0.1);
  --income-text: #059669;
  --income-border: #a7f3d0;
  
  --expense-bg: rgba(244, 63, 94, 0.1);
  --expense-text: #e11d48;
  --expense-border: #fecdd3;

  --warning-bg: rgba(245, 158, 11, 0.1);
  --warning-text: #d97706;
  --warning-border: #fde68a;

  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;

  /* Surfaces & Glassmorphism */
  --bg-app: #f4f6fb;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.4);

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Geometry & Typography */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables Override */
[data-theme="dark"] {
  --bg-app: #0b0f19;
  --card-bg: #151c2c;
  --card-border: #222e45;
  --glass-bg: rgba(21, 28, 44, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);

  --neutral-50: #1e293b;
  --neutral-100: #334155;
  --neutral-200: #475569;
  --neutral-300: #64748b;
  --neutral-400: #94a3b8;
  --neutral-500: #cbd5e1;
  --neutral-600: #e2e8f0;
  --neutral-700: #f1f5f9;
  --neutral-800: #f8fafc;
  --neutral-900: #ffffff;
}

/* ==========================================================================
   GLOBAL RESET & BASE STYLES
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--neutral-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-700);
}

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

.sidebar {
  width: 260px;
  background: var(--card-bg);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--card-border);
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--neutral-900);
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  background: var(--primary-50);
  color: var(--primary-600);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 1.25rem 1rem;
  flex: 1;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--neutral-400);
  margin: 1.25rem 0.75rem 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--neutral-600);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  margin-bottom: 0.25rem;
}

.nav-link:hover {
  background: var(--neutral-100);
  color: var(--neutral-900);
}

.nav-link.active {
  background: var(--primary-500);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.nav-link .icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.main-wrapper {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 64px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-search {
  position: relative;
  width: 280px;
}

.topbar-search input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  font-family: inherit;
  font-size: 0.85rem;
  background: var(--neutral-100);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--neutral-900);
  transition: all var(--transition-fast);
}

.topbar-search input:focus {
  outline: none;
  background: var(--card-bg);
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.topbar-search .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--neutral-400);
  pointer-events: none;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary-100);
  color: var(--primary-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.main-content {
  padding: 1.75rem;
  flex: 1;
}

/* ==========================================================================
   CARDS & WIDGETS
   ========================================================================== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--neutral-900);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-500);
}

.stat-card.income::before { background: var(--income-text); }
.stat-card.expense::before { background: var(--expense-text); }
.stat-card.warning::before { background: var(--warning-text); }

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--neutral-500);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--neutral-900);
  letter-spacing: -0.02em;
}

.stat-desc {
  font-size: 0.75rem;
  color: var(--neutral-400);
  margin-top: 0.35rem;
}

/* ==========================================================================
   BADGES & BUTTONS
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-paid, .badge-active, .badge-income {
  background: var(--income-bg);
  color: var(--income-text);
  border: 1px solid var(--income-border);
}

.badge-unpaid, .badge-expense, .badge-overdue {
  background: var(--expense-bg);
  color: var(--expense-text);
  border: 1px solid var(--expense-border);
}

.badge-partial, .badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.badge-void, .badge-archived {
  background: var(--neutral-100);
  color: var(--neutral-500);
  border: 1px solid var(--neutral-300);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--primary-600);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  background: var(--primary-700);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--neutral-100);
  color: var(--neutral-700);
  border-color: var(--neutral-200);
}

.btn-secondary:hover {
  background: var(--neutral-200);
  color: var(--neutral-900);
}

.btn-success {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-danger {
  background: #f43f5e;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.25);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.775rem;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   DATA TABLES
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
  background: var(--card-bg);
}

.table th {
  background: var(--neutral-50);
  padding: 0.85rem 1rem;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--neutral-500);
  border-bottom: 1px solid var(--card-border);
}

.table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--card-border);
  color: var(--neutral-700);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--neutral-50);
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE FRIENDS)
   ========================================================================== */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 1rem;
  }

  .topbar-search {
    display: none;
  }

  .main-content {
    padding: 1rem;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }
}
