/* =========================================
   GOOGLE FONTS IMPORT
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* =========================================
   CSS VARIABLES
   ========================================= */
:root {
  --sidebar-w: 260px;
  --sidebar-bg: #0f1117;
  --sidebar-border: #1e2230;
  --sidebar-text: #8b90a0;
  --sidebar-text-active: #ffffff;
  --sidebar-hover-bg: #1a1f2e;
  --sidebar-accent: #3b82f6;

  --bg-page: #f0f2f8;
  --bg-card: #ffffff;
  --bg-card-alt: #f8fafc;

  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --border-color: #e2e8f0;
  --border-light: #f1f5f9;

  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --blue-light: #eff6ff;
  --green: #10b981;
  --green-light: #ecfdf5;
  --yellow: #f59e0b;
  --yellow-light: #fffbeb;
  --red: #ef4444;
  --red-light: #fef2f2;
  --purple: #8b5cf6;
  --purple-light: #f5f3ff;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.1), 0 4px 10px rgba(0,0,0,.06);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font-body: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --transition: all 0.2s ease;
}

/* =========================================
   RESET & BASE
   ========================================= */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =========================================
   LAYOUT WRAPPER
   ========================================= */
#wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* =========================================
   SIDEBAR
   ========================================= */
#sidebar-wrapper {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background-color: var(--sidebar-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin .25s ease, min-width .25s ease, width .25s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #2a3040 transparent;
  flex-shrink: 0;
  z-index: 100;
}

#sidebar-wrapper::-webkit-scrollbar { width: 4px; }
#sidebar-wrapper::-webkit-scrollbar-track { background: transparent; }
#sidebar-wrapper::-webkit-scrollbar-thumb { background: #2a3040; border-radius: 4px; }

.sidebar-heading {
  padding: 1.5rem 1.25rem 1.25rem;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #3d4458;
  padding: 1rem 1.25rem 0.35rem;
}

.sidebar-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 0.5rem 1.25rem;
}

.list-group-item-custom {
  background: transparent;
  color: var(--sidebar-text);
  border: none;
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--radius-sm);
  margin: 1px 0.75rem;
  transition: var(--transition);
  text-decoration: none;
  width: calc(100% - 1.5rem);
}

.list-group-item-custom:hover {
  background: var(--sidebar-hover-bg);
  color: #e2e8f0;
  text-decoration: none;
}

.list-group-item-custom.active-nav {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border-left: 3px solid var(--sidebar-accent);
}

/* Server clock widget */
.sidebar-clock-widget {
  margin: 0.75rem;
  padding: 0.85rem 1rem;
  background: #1a1f2e;
  border-radius: var(--radius-md);
  border: 1px solid #1e2230;
}

.sidebar-clock-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #3d4458;
  margin-bottom: 0.15rem;
}

.sidebar-clock-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #e2e8f0;
  font-weight: 500;
}

#clock-wib { color: #60a5fa; }

/* =========================================
   PAGE CONTENT
   ========================================= */
#page-content-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* =========================================
   TOPBAR NAVBAR
   ========================================= */
.app-topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 99;
  box-shadow: var(--shadow-sm);
}

.topbar-toggle {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.topbar-toggle:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.topbar-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-logout {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #fecaca;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
}

.btn-logout:hover {
  background: var(--red);
  color: white;
  text-decoration: none;
}

/* =========================================
   MAIN CONTENT AREA
   ========================================= */
.app-content {
  flex: 1;
  padding: 1.75rem;
}

/* =========================================
   PAGE HEADER
   ========================================= */
.page-header {
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  letter-spacing: -0.3px;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* =========================================
   CARDS
   ========================================= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.card-header.dark {
  background: var(--text-primary);
  color: white;
  border-bottom: none;
}

.card-body { padding: 1.25rem; }

/* Stat cards */
.stat-card {
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  border: none;
  box-shadow: var(--shadow-md);
}

.stat-card .stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 0.4rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
}

.stat-card .stat-icon {
  position: absolute;
  right: 1rem;
  bottom: 0.75rem;
  font-size: 2.5rem;
  opacity: 0.2;
}

.stat-blue  { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); color: white; }
.stat-amber { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); color: white; }
.stat-green { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; }
.stat-red   { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); color: white; }

/* =========================================
   BUTTONS
   ========================================= */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.btn-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.btn-outline-primary {
  background: var(--blue-light);
  border-color: #bfdbfe;
  color: var(--blue-dark);
}

.btn-outline-primary:hover {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.btn-outline-danger {
  background: var(--red-light);
  border-color: #fecaca;
  color: var(--red);
}

.btn-outline-danger:hover {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.btn-outline-secondary {
  background: var(--bg-card-alt);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-outline-secondary:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

/* =========================================
   FORM CONTROLS
   ========================================= */
.form-control, .form-select {
  font-family: var(--font-body);
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  color: var(--text-primary);
  background-color: var(--bg-card-alt);
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  background-color: var(--bg-card);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  color: var(--text-primary);
}

.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* =========================================
   TABLES
   ========================================= */
.table {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.table thead th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--bg-card-alt);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover td { background: #f8fbff; }

/* =========================================
   BADGES
   ========================================= */
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.3em 0.65em;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

.badge.bg-success { background: #dcfce7 !important; color: #166534 !important; }
.badge.bg-warning { background: #fef9c3 !important; color: #92400e !important; }
.badge.bg-danger  { background: #fee2e2 !important; color: #991b1b !important; }
.badge.bg-info    { background: #e0f2fe !important; color: #075985 !important; }
.badge.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }
.badge.bg-primary { background: var(--blue-light) !important; color: var(--blue-dark) !important; }
.badge.bg-dark    { background: #1e293b !important; color: #e2e8f0 !important; }

/* =========================================
   NAV TABS
   ========================================= */
.nav-tabs {
  border-bottom: 1px solid var(--border-color);
  gap: 0.25rem;
}

.nav-tabs .nav-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 0.6rem 1rem;
  background: transparent;
  transition: var(--transition);
}

.nav-tabs .nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-page);
}

.nav-tabs .nav-link.active {
  background: var(--bg-card);
  color: var(--blue);
  border-bottom: 2px solid var(--blue);
  font-weight: 700;
}

/* =========================================
   ALERTS
   ========================================= */
.alert {
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid;
  padding: 0.85rem 1rem;
}

.alert-success { background: var(--green-light); border-color: #6ee7b7; color: #065f46; }
.alert-danger  { background: var(--red-light); border-color: #fca5a5; color: #7f1d1d; }
.alert-warning { background: var(--yellow-light); border-color: #fcd34d; color: #78350f; }
.alert-info    { background: #e0f2fe; border-color: #7dd3fc; color: #0c4a6e; }

/* =========================================
   DATATABLES OVERRIDES
   ========================================= */
.dataTables_wrapper .row:first-child {
  padding: 1rem 1rem 0.75rem;
  background: var(--bg-card-alt);
  border-bottom: 1px solid var(--border-color);
  margin: 0;
}

.dataTables_wrapper .row:last-child {
  padding: 0.75rem 1rem;
  background: var(--bg-card-alt);
  border-top: 1px solid var(--border-color);
  margin: 0;
}

.dataTables_filter label,
.dataTables_length label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.dataTables_filter input {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-family: var(--font-body);
  background: var(--bg-card);
  transition: var(--transition);
}

.dataTables_filter input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  outline: none;
}

.dataTables_length select {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  background: var(--bg-card);
}

.dataTables_info, .dataTables_paginate {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.page-item .page-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-color: var(--border-color);
  border-radius: var(--radius-sm) !important;
  margin: 0 2px;
  transition: var(--transition);
}

.page-item.active .page-link {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

table.dataTable { margin-top: 0 !important; margin-bottom: 0 !important; }

/* =========================================
   PROGRESS BAR
   ========================================= */
.progress {
  height: 6px;
  border-radius: 99px;
  background: var(--border-light);
  overflow: hidden;
}

.progress-bar { border-radius: 99px; }

/* =========================================
   CHOICES.JS
   ========================================= */
.choices { margin-bottom: 0; }
.choices__inner {
  min-height: 38px;
  padding: 4px 8px 2px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-color: var(--border-color);
  background: var(--bg-card-alt);
  font-size: 0.85rem;
  font-family: var(--font-body);
}
.choices__list--multiple .choices__item {
  background: var(--blue);
  border: none;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 600;
}
.choices__list--dropdown { z-index: 9999 !important; border-radius: var(--radius-sm); border-color: var(--border-color); }
.table-responsive { overflow: visible !important; }

/* =========================================
   LOGIN PAGE
   ========================================= */
.login-body {
  background: linear-gradient(135deg, #0f1117 0%, #1a1f2e 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.login-logo {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
}

/* =========================================
   LOG CONSOLE
   ========================================= */
.log-console {
  background: #0d1117;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  max-height: 550px;
  overflow-y: auto;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: #2a3040 transparent;
}

.log-console::-webkit-scrollbar { width: 6px; }
.log-console::-webkit-scrollbar-thumb { background: #2a3040; border-radius: 3px; }

/* =========================================
   QUICK ACTION BUTTONS
   ========================================= */
.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: var(--transition);
}

.quick-action-btn:hover {
  background: var(--bg-page);
  border-color: var(--blue);
  color: var(--blue);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* =========================================
   GALLERY / MEDIA LIBRARY
   ========================================= */
.media-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: var(--transition);
  background: var(--bg-card);
}

.media-card:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

/* =========================================
   SIDEBAR TOGGLED (DESKTOP)
   ========================================= */
#wrapper.toggled #sidebar-wrapper {
  margin-left: 0;
  min-width: 0;
  width: 0;
  overflow: hidden;
}

/* =========================================
   MOBILE RESPONSIVE
   ========================================= */
@media (max-width: 767.98px) {
  :root { --sidebar-w: 260px; }

  #sidebar-wrapper {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1050;
    margin-left: calc(-1 * var(--sidebar-w));
    transition: margin .25s ease;
    box-shadow: none;
  }

  #wrapper.toggled #sidebar-wrapper {
    margin-left: 0;
    box-shadow: 4px 0 20px rgba(0,0,0,.35);
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1040;
    backdrop-filter: blur(2px);
  }

  #wrapper.toggled .sidebar-overlay { display: block; }

  .app-content {
    padding: 1rem;
  }

  .stat-card .stat-value { font-size: 1.5rem; }

  .topbar-title { display: none; }

  .page-title { font-size: 1.1rem; }

  /* Stack action buttons vertically on mobile */
  .page-header-actions {
    flex-wrap: wrap;
    gap: 0.5rem !important;
  }

  /* Make tables horizontally scrollable */
  .table-responsive { overflow-x: auto !important; }

  /* Full-width buttons on mobile */
  .mobile-full { width: 100% !important; }

  /* Nav tabs scroll on mobile */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-link { white-space: nowrap; }

  /* Modal sizing */
  .modal-dialog { margin: 0.75rem; }
  .modal-content { border-radius: var(--radius-lg); }
}

@media (max-width: 575.98px) {
  .app-content { padding: 0.75rem; }

  .card { border-radius: var(--radius-md); }

  .card-body { padding: 1rem; }

  .stat-card { padding: 1rem; }
}

/* =========================================
   SECTION CARDS (form groups)
   ========================================= */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.section-card-title {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-card-title.blue  { color: var(--blue); }
.section-card-title.green { color: var(--green); }
.section-card-title.info  { color: #0ea5e9; }