:root {
  --sidebar-width: 256px;
  --sidebar-collapsed-width: 76px;
  --header-height: 64px;
  
  --bs-body-bg: #0f172a;
  --bs-body-color: #e2e8f0;
  --bs-tertiary-bg: #1e293b;
  --bs-border-color: #334155;
  --bs-secondary-color: #94a3b8;
  
  --sidebar-bg: #1e293b;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-color: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
}

[data-bs-theme="light"], [data-bs-theme="dark"] {
  --bs-body-bg: #0f172a;
  --bs-body-color: #e2e8f0;
  --bs-tertiary-bg: #1e293b;
  --bs-border-color: #334155;
  --bs-secondary-color: #94a3b8;
}

body {
  font-family: 'Inter', sans-serif;
  overflow-x: hidden;
  background-color: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
}

.text-dark, .text-foreground { color: #f8fafc !important; }
.text-muted { color: #94a3b8 !important; }
.bg-light, .bg-white { background-color: #1e293b !important; color: #f8fafc !important; }
.bg-body { background-color: #0f172a !important; }

/* Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--bs-border-color);
  color: var(--sidebar-color);
}
.sidebar .sidebar-header {
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  height: var(--header-height);
  padding: 1.5rem;
}
.sidebar ul.components { padding: 1rem 0.75rem; }
.sidebar ul li a {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  margin-bottom: 0.25rem;
  border-left: none;
  color: var(--sidebar-color);
  display: flex;
  align-items: center;
  transition: all 0.2s;
  cursor: pointer;
  text-decoration: none;
}
.sidebar ul li a i { font-size: 1.25rem; min-width: 2rem; text-align: left; }
.sidebar ul li.active > a {
  background: var(--accent);
  color: #fff;
}
.sidebar ul li a:hover:not(.active > a) {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.sidebar ul ul a { padding-left: 3rem !important; }

/* Topbar */
.topbar {
  background-color: rgba(30, 41, 59, 0.5) !important;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bs-border-color);
  padding: 0 1.5rem;
  height: var(--header-height);
}

/* Base Card */
.card {
  background-color: #1e293b !important;
  border-radius: 1rem !important;
  border: 1px solid var(--bs-border-color) !important;
  box-shadow: none !important;
}
.card-header {
  border-bottom: 1px solid var(--bs-border-color) !important;
  background: transparent !important;
  color: #fff !important;
  font-weight: 700 !important;
  padding: 1.25rem 1.5rem !important;
  font-size: 0.875rem !important;
}
.card-body { padding: 1.5rem; }

/* Stat Cards override */
.stat-card {
  padding: 1rem !important;
  border-radius: 1rem !important;
  border: none !important;
  color: #fff !important;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}
.stat-card p {
  font-size: 0.75rem !important;
  font-weight: 500 !important;
  text-transform: uppercase;
  color: rgba(255,255,255,0.8) !important;
  z-index: 2;
  margin-bottom: 0.25rem;
}
.stat-card h3 {
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  margin-top: 0 !important;
  color: #fff !important;
  z-index: 2;
}
.stat-card i {
  position: absolute;
  right: 1rem;
  top: 1rem;
  bottom: auto;
  font-size: 1.5rem !important;
  background: rgba(255,255,255,0.1);
  padding: 0.5rem;
  border-radius: 0.5rem;
  opacity: 1 !important;
  transform: none !important;
  color: rgba(255,255,255,0.8);
}
.stat-card:hover i { transform: scale(1.1) !important; }

/* Convert base bootstrap colors to the theme gradients */
.stat-card.bg-primary { background: linear-gradient(to bottom right, #4f46e5, #4338ca) !important; box-shadow: 0 20px 25px -5px rgba(49, 46, 129, 0.2) !important; }
.stat-card.bg-info { background: linear-gradient(to bottom right, #3b82f6, #0891b2) !important; box-shadow: 0 20px 25px -5px rgba(30, 58, 138, 0.2) !important; }
.stat-card.bg-warning { background: linear-gradient(to bottom right, #10b981, #0d9488) !important; box-shadow: 0 20px 25px -5px rgba(6, 78, 59, 0.2) !important; }
.stat-card.bg-success { background: linear-gradient(to bottom right, #059669, #047857) !important; box-shadow: 0 20px 25px -5px rgba(4, 120, 87, 0.2) !important; }
.stat-card.bg-secondary { background: linear-gradient(to bottom right, #64748b, #475569) !important; box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.2) !important; }
.stat-card.bg-danger { background: linear-gradient(to bottom right, #f43f5e, #db2777) !important; box-shadow: 0 20px 25px -5px rgba(131, 24, 67, 0.2) !important; }

/* Dashboard Mini Cards */
.col .card[style*="linear-gradient"] { border-radius: 1rem !important; border: none !important;}

/* Tables */
.table-responsive { width: 100%; overflow-x: auto; border-radius: 0; }
.table { color: #f8fafc; border-color: #334155; margin-bottom: 0; font-size: 0.875rem; }
.table th, table.dataTable thead th, table.dataTable thead td {
  background-color: rgba(30, 41, 59, 0.5) !important; 
  color: #94a3b8 !important; 
  text-transform: uppercase;
  font-size: 11px !important;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5) !important;
}
.table td, table.dataTable tbody td {
  background-color: transparent !important;
  color: #e2e8f0 !important;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5) !important;
  padding: 0.75rem 1.5rem;
}
.table tbody tr:hover td { background-color: rgba(51, 65, 85, 0.3) !important; }

/* Forms & Inputs */
.form-control, .form-select, .input-group-text {
  background-color: #0f172a !important;
  color: #f8fafc !important;
  border-color: #334155 !important;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px var(--accent) !important;
}
.form-select option { background-color: #1e293b; color: #f8fafc; }

/* DataTables Pagination & Info */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { color: #94a3b8 !important; font-size: 0.875rem; }
.page-item .page-link { background-color: #1e293b; border-color: #334155; color: #cbd5e1; }
.page-item.active .page-link { background-color: var(--accent); border-color: var(--accent); color: #fff; }
.page-item.disabled .page-link { background-color: #0f172a; border-color: #334155; color: #64748b; }

/* Badges */
.badge { padding: 2px 8px; border-radius: 9999px; font-size: 10px; font-weight: 500; border: 1px solid transparent; }
.badge.bg-success { background-color: rgba(16, 185, 129, 0.2) !important; color: #34d399 !important; border-color: rgba(16, 185, 129, 0.3) !important; }
.badge.bg-warning { background-color: rgba(245, 158, 11, 0.2) !important; color: #fbbf24 !important; border-color: rgba(245, 158, 11, 0.3) !important; text-shadow: none !important; }
.badge.bg-info { background-color: rgba(59, 130, 246, 0.2) !important; color: #60a5fa !important; border-color: rgba(59, 130, 246, 0.3) !important; text-shadow: none !important;}
.badge.bg-primary { background-color: rgba(99, 102, 241, 0.2) !important; color: #818cf8 !important; border-color: rgba(99, 102, 241, 0.3) !important; }
.badge.bg-danger { background-color: rgba(244, 63, 94, 0.2) !important; color: #fb7185 !important; border-color: rgba(244, 63, 94, 0.3) !important; }
.badge.bg-secondary { background-color: rgba(71, 85, 105, 0.2) !important; color: #94a3b8 !important; border-color: rgba(71, 85, 105, 0.3) !important; }
.badge.bg-light.text-dark { background-color: rgba(71, 85, 105, 0.2) !important; color: #94a3b8 !important; border-color: rgba(71, 85, 105, 0.3) !important; }

/* Status Badges specific overrides */
.badge-status { padding: 4px 8px; border-radius: 9999px; font-size: 10px; font-weight: 500; display: inline-block; border: 1px solid transparent; }
.status-habis { background: rgba(225, 29, 72, 0.2); color: #fb7185; border-color: rgba(225, 29, 72, 0.3); animation: none; box-shadow: none; }
.status-warning { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border-color: rgba(245, 158, 11, 0.3); }
.status-aman { background: rgba(16, 185, 129, 0.2); color: #34d399; border-color: rgba(16, 185, 129, 0.3); }

/* Buttons */
.btn { border-radius: 0.5rem; font-weight: 600; font-size: 0.875rem; padding: 0.5rem 1rem; border: none; }
.btn-primary { background-color: var(--accent); color: white; }
.btn-primary:hover { background-color: var(--accent-hover); }
.btn-outline-primary { color: var(--accent); border: 1px solid var(--accent); background: transparent; }
.btn-outline-primary:hover { background-color: var(--accent); color: #fff; }

.swal2-popup { background: #1e293b !important; color: #f8fafc !important; border: 1px solid #334155; border-radius: 1rem !important; }
.swal2-title { color: #f8fafc !important; }

/* Timeline */
.timeline-content { background: #0f172a; border-color: #334155; }
.timeline-item::before { background: #334155; }
.timeline-icon { box-shadow: 0 0 0 4px #0f172a; }

.branding-preview-box { background: #0f172a; border-color: #334155; border-style: dashed; }

/* Loader */
#loader { background: rgba(15, 23, 42, 0.9) !important; }

.wrapper { display: flex; width: 100%; align-items: stretch; }
.content-wrapper { flex-grow: 1; transition: all 0.3s; display: flex; flex-direction: column; overflow-x: hidden; }
.content { padding: 1.5rem; flex-grow: 1; display: flex; flex-direction: column; gap: 1.5rem; }

.page-section { display: none; animation: fadeIn 0.4s ease-out forwards; }
.page-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Logo */
.logo-text {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    color: #fff;
    background: none;
    -webkit-text-fill-color: #fff;
    text-shadow: none;
    letter-spacing: -0.05em;
    -webkit-text-stroke: 0px;
    font-size: 1.5rem;
}
.logo-text span {
    font-weight: 300;
    color: #60a5fa;
}
.logo-sub { display: none; } /* Hide sub text to match sleek design */
.logo-text-sm {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    color: #fff;
    background: none;
    -webkit-text-fill-color: #fff;
    font-size: 1.25rem;
    letter-spacing: -0.025em;
}

/* Animations reset */
.shake-animation {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
  border: 1px solid #ef4444 !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.2) !important;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Login box */
#login-screen .card {
  background: #1e293b !important;
  border-radius: 1rem !important;
  border: 1px solid #334155 !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
}
#login-screen .input-group-text, #login-screen .form-control {
  background: #0f172a !important;
  border: 1px solid #334155 !important;
}
#login-screen .input-group-text { border-right: none !important; }
#login-screen .form-control { border-left: none !important; }
