/* =============================================
   ExpireX - Main Stylesheet
   Smart Expiry Monitoring & Prediction System
   ============================================= */

/* ---------- CSS Variables ---------- */
:root {
  --primary: #0D9488;
  --primary-dark: #0F766E;
  --primary-light: #14B8A6;
  --secondary: #0F172A;
  --secondary-light: #1E293B;
  --accent: #8B5CF6;
  --surface: #FFFFFF;
  --surface-dark: #F8FAFC;
  --text: #0F172A; /* Lebih gelap & tajam */
  --text-muted: #64748B;
  --border: #E2E8F0;
  --aman: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --expired: #6B7280;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition: all .25s cubic-bezier(.4,0,.2,1);
  --sidebar-bg: #FFFFFF; /* Default Terang */
  --sidebar-text: #475569;
}

/* ---------- Dark Mode Colors ---------- */
.dark-mode {
  --surface: #1E293B;      
  --surface-dark: #0F172A; 
  --text: #FFFFFF;         
  --text-muted: #CBD5E1;   /* Lebih terang agar deskripsi terbaca */
  --border: #3F4E65;       /* Garis lebih tegas */
  --topbar-bg: rgba(15, 23, 42, 0.95);
  --sidebar-bg: #1E293B; 
  --sidebar-text: #E2E8F0; /* Menu sidebar lebih terang */
}

:root {
    --topbar-bg: rgba(255, 255, 255, 0.85);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--surface-dark);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  z-index: 1040;
  transition: transform .3s ease, background .3s ease;
  display: flex; flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.sidebar-brand {
  padding: 20px 24px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand img { width: 36px; height: 36px; border-radius: 8px; }
.sidebar-brand h5 {
  margin: 0; font-size: 1.15rem; font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), #34D399);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.sidebar-nav { padding: 16px 12px; flex: 1; }
.sidebar-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: 1.2px;
  color: #475569; padding: 12px 12px 6px; font-weight: 600;
}
.nav-item { margin-bottom: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-size: .875rem; font-weight: 500;
  transition: var(--transition);
}
.nav-link i { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #E2E8F0; }
.nav-link.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-weight: 600;
  box-shadow: 0 4px 12px rgba(13,148,136,.35);
}

/* ---------- Topbar ---------- */
.topbar {
  position: fixed; top: 0; right: 0;
  left: var(--sidebar-w);
  height: var(--topbar-h);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px; z-index: 1030;
  transition: all .3s ease;
}
.topbar-title { font-weight: 600; font-size: 1.05rem; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Main Content ---------- */
.main-content {
  margin-left: var(--sidebar-w);
  padding-top: calc(var(--topbar-h) + 24px);
  padding-bottom: 40px;
  padding-left: 24px; padding-right: 24px;
  min-height: 100vh;
  transition: margin-left .3s ease;
}

/* ---------- Cards ---------- */
.card-ex {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: var(--transition);
  overflow: hidden;
}
.dark-mode .card-ex {
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.05);
}
.card-ex:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-ex .card-body { padding: 20px; }
.card-ex .card-header {
  padding: 16px 20px;
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

/* ---------- Stat Cards ---------- */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 4px; height: 100%; border-radius: 4px 0 0 4px;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff; flex-shrink: 0;
}
.stat-info h3 { margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-info p { margin: 0; font-size: .8rem; color: var(--text-muted); }

.stat-card.aman::before { background: var(--aman); }
.stat-card.aman .stat-icon { background: linear-gradient(135deg, var(--aman), #059669); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.warning .stat-icon { background: linear-gradient(135deg, var(--warning), #D97706); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.danger .stat-icon { background: linear-gradient(135deg, var(--danger), #DC2626); }
.stat-card.expired::before { background: var(--expired); }
.stat-card.expired .stat-icon { background: linear-gradient(135deg, var(--expired), #4B5563); }
.stat-card.total::before { background: var(--primary); }
.stat-card.total .stat-icon { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }

/* ---------- Status Badges ---------- */
.badge-status {
  padding: 4px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.badge-status.aman { background: #D1FAE5; color: #065F46; }
.badge-status.warning { background: #FEF3C7; color: #92400E; }
.badge-status.danger { background: #FEE2E2; color: #991B1B; }
.badge-status.expired { background: #F3F4F6; color: #374151; }
.badge-status::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; display: inline-block;
}

/* ---------- Tables ---------- */
.table-ex { width: 100%; border-collapse: collapse; }
.table-ex thead th {
  background: var(--surface-dark);
  padding: 12px 16px; font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table-ex tbody td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: .875rem; vertical-align: middle;
}
.table-ex tbody tr { transition: var(--transition); }
.table-ex tbody tr:hover { background: rgba(13,148,136,.04); }

/* ---------- Buttons ---------- */
.btn-ex {
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500;
  border: none; cursor: pointer; display: inline-flex;
  align-items: center; gap: 6px; transition: var(--transition);
}
.btn-primary-ex {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}
.btn-primary-ex:hover { box-shadow: 0 4px 12px rgba(13,148,136,.4); transform: translateY(-1px); color: #fff; }
.btn-danger-ex { background: linear-gradient(135deg, var(--danger), #DC2626); color: #fff; }
.btn-danger-ex:hover { box-shadow: 0 4px 12px rgba(239,68,68,.4); transform: translateY(-1px); color: #fff; }
.btn-warning-ex { background: linear-gradient(135deg, var(--warning), #D97706); color: #fff; }
.btn-outline-ex {
  background: transparent; border: 1.5px solid var(--border);
  color: var(--text); 
}
.btn-outline-ex:hover { border-color: var(--primary); color: var(--primary); background: rgba(13,148,136,.04); }
.btn-sm-ex { padding: 5px 12px; font-size: .8rem; }

/* ---------- Form Controls ---------- */
.form-control-ex {
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); font-size: .875rem;
  transition: var(--transition); width: 100%;
  background: var(--surface); color: var(--text);
}
.form-control-ex:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}
.form-label-ex { font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: 6px; display: block; }

/* ---------- Toast Notification ---------- */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast-ex {
  padding: 14px 20px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); min-width: 320px; max-width: 420px;
  display: flex; align-items: flex-start; gap: 12px;
  animation: toastIn .4s cubic-bezier(.4,0,.2,1);
  transition: var(--transition);
}
.toast-ex.hide { animation: toastOut .3s ease forwards; }
.toast-ex.success { border-left: 4px solid var(--aman); }
.toast-ex.error { border-left: 4px solid var(--danger); }
.toast-ex.warning { border-left: 4px solid var(--warning); }
.toast-ex.info { border-left: 4px solid var(--primary); }
.toast-icon { font-size: 1.2rem; margin-top: 1px; }
.toast-body h6 { margin: 0 0 2px; font-size: .875rem; font-weight: 600; }
.toast-body p { margin: 0; font-size: .8rem; color: var(--text-muted); }
.toast-close { margin-left: auto; cursor: pointer; color: var(--text-muted); background: none; border: none; font-size: 1.1rem; }

@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateX(120%); opacity: 0; } }

/* ---------- Custom Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px); z-index: 1050;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: all .3s ease;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-ex {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 90%; max-width: 540px;
  max-height: 85vh; overflow-y: auto;
  transform: scale(.9) translateY(20px); transition: all .3s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.show .modal-ex { transform: scale(1) translateY(0); }
.modal-ex-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-ex-header h5 { margin: 0; font-weight: 600; }
.modal-ex-body { padding: 24px; }
.modal-ex-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Notification Bell ---------- */
.notif-bell { position: relative; cursor: pointer; padding: 8px; border-radius: 50%; transition: var(--transition); background: none; border: none; }
.notif-bell:hover { background: rgba(13,148,136,.08); }
.notif-bell .badge-count {
  position: absolute; top: 2px; right: 2px;
  background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 360px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); z-index: 1060;
  max-height: 400px; overflow-y: auto;
}

/* ---------- Login Page ---------- */
.login-wrapper {
  min-height: 100vh; display: flex;
  background: linear-gradient(135deg, var(--secondary) 0%, #162033 50%, var(--primary-dark) 100%);
}
.login-card {
  background: var(--surface); border-radius: 16px;
  padding: 40px; width: 100%; max-width: 420px;
  margin: auto; box-shadow: 0 25px 50px rgba(0,0,0,.25);
}
.login-card h2 { font-weight: 700; margin-bottom: 8px; }

/* ---------- Pagination ---------- */
.pagination-ex { display: flex; gap: 4px; list-style: none; padding: 0; margin: 20px 0 0; justify-content: center; }
.pagination-ex li a, .pagination-ex li span {
  padding: 6px 12px; border-radius: 6px; font-size: .82rem;
  border: 1px solid var(--border); color: var(--text);
  transition: var(--transition); display: block;
}
.pagination-ex li a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-ex li.active span { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Toggle Switch ---------- */
.toggle-switch { position: relative; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #CBD5E1; border-radius: 24px; transition: var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; left: 3px; bottom: 3px;
  transition: var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .topbar { left: 0; }
  .main-content { margin-left: 0; }
}
@media (max-width: 576px) {
  .main-content { padding-left: 16px; padding-right: 16px; }
  .stat-card { padding: 14px; }
  .notif-dropdown { width: 300px; right: -40px; }
}
