/* ==========================================================================
   PORTAL ADMIN & BENDAHARA - KAS KELAS TRPL 25A1
   High-End Cyber Dark Design System (Merah Crimson, Putih, Obsidian Dark)
   ========================================================================== */

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

:root {
  --bg-dark-base: #06080e;
  --bg-dark-surface: #0a0e18;
  --bg-dark-card: rgba(13, 19, 34, 0.82);
  --bg-dark-card-hover: rgba(19, 28, 48, 0.95);
  --bg-dark-input: rgba(8, 12, 22, 0.90);

  /* Aksen Merah Crimson & Neon Red */
  --red-glow: #ff2a5f;
  --red-primary: #ef4444;
  --red-bright: #f43f5e;
  --red-dark: #b91c1c;
  --red-soft: rgba(239, 68, 68, 0.15);
  --red-border: rgba(244, 63, 94, 0.35);

  /* Aksen Status */
  --green-glow: #10b981;
  --green-soft: rgba(16, 185, 129, 0.15);
  --green-border: rgba(16, 185, 129, 0.35);

  --amber-glow: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --amber-border: rgba(245, 158, 11, 0.35);

  /* Teks & Netral Putih */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.2);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg-dark-base);
  color: var(--text-primary);
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  position: relative;
  min-height: 100vh;
  background-color: var(--bg-dark-base);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(239, 68, 68, 0.10) 0%, transparent 45%),
    radial-gradient(circle at 90% 15%, rgba(255, 42, 95, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 50% 85%, rgba(185, 28, 28, 0.08) 0%, transparent 50%),
    linear-gradient(to bottom, rgba(6, 8, 14, 0.95), rgba(6, 8, 14, 1));
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark-base);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--red-primary), #881337);
  border-radius: 9999px;
  border: 1px solid var(--bg-dark-base);
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--red-glow), var(--red-primary));
}

/* Canvas Partikel Interaktif */
#particlesCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1;
}

/* Ambient Glow Lighting */
.cyber-ambient-light {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}
.cyber-light-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(255, 42, 95, 0.3) 0%, transparent 70%);
  top: -15%;
  left: -10%;
}
.cyber-light-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(239, 68, 68, 0.25) 0%, transparent 70%);
  bottom: 0%;
  right: -10%;
}

.cyber-grid-overlay {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  z-index: 0;
}

/* Glassmorphism Card */
.glass-panel {
  background: var(--bg-dark-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 1.25rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}
.glass-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

/* Buttons */
.btn-primary-red {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 60%, #b91c1c 100%);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.8125rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 18px rgba(239, 68, 68, 0.35);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}
.btn-primary-red:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(255, 42, 95, 0.5);
  background: linear-gradient(135deg, #f43f5e 0%, #ef4444 60%, #dc2626 100%);
  color: #ffffff;
}
.btn-primary-red:active {
  transform: translateY(0);
}

.btn-glass-subtle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.8125rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}
.btn-glass-subtle:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Sidebar Navigation Items */
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.875rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}
.sidebar-nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.04);
}
.sidebar-nav-item.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.18) 0%, rgba(255, 42, 95, 0.08) 100%);
  border-color: rgba(244, 63, 94, 0.35);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.18);
}
.sidebar-nav-item.active .nav-icon {
  color: var(--red-glow);
}

/* Input Fields */
.cyber-input {
  width: 100%;
  background: var(--bg-dark-input);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  color-scheme: dark;
}
.cyber-input:focus {
  outline: none;
  border-color: var(--red-glow);
  box-shadow: 0 0 0 3px rgba(255, 42, 95, 0.2);
  background: rgba(14, 20, 36, 0.95);
}

/* Custom Select & Option Dropdown - High Contrast Cyber Dark */
select {
  color-scheme: dark !important;
}

select option {
  background-color: #0b1120 !important;
  color: #f8fafc !important;
  padding: 0.5rem 0.75rem !important;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
}

select option:checked,
select option:hover,
select option:focus {
  background-color: #ef4444 !important;
  color: #ffffff !important;
}

/* Khusus Dropdown Filter Bulan Kas Rekap */
#rekapMonthFilterSelect {
  background-color: #0b1120 !important;
  color: #ffffff !important;
  color-scheme: dark !important;
  font-weight: 600 !important;
}

#rekapMonthFilterSelect option {
  background-color: #0c1222 !important;
  color: #f8fafc !important;
  padding: 8px 12px !important;
  font-weight: 500 !important;
}

#rekapMonthFilterSelect option:checked {
  background-color: #ef4444 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #0d1322;
  border: 1px solid rgba(244, 63, 94, 0.35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(239, 68, 68, 0.2);
  border-radius: 1.25rem;
  width: 100%;
  max-width: 36rem;
  transform: scale(0.95) translateY(12px);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

/* Table Hover & Scrollbar */
.admin-table th {
  background-color: rgba(10, 14, 26, 0.95);
}
.admin-table tr {
  transition: background-color var(--transition-fast);
}
.admin-table tbody tr:hover {
  background-color: rgba(255, 42, 95, 0.05) !important;
}

/* Pulse Live Sync Dot */
.sync-pulsing-dot {
  position: relative;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
}
.sync-pulsing-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background-color: #10b981;
  opacity: 0.75;
  animation: pulseSync 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes pulseSync {
  0% { transform: scale(1); opacity: 0.8; }
  75%, 100% { transform: scale(2.4); opacity: 0; }
}

/* Checkbox Toggle Button for Kas Matrix */
.toggle-paid-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.toggle-paid-btn.is-paid {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
}
.toggle-paid-btn.is-paid:hover {
  background: rgba(16, 185, 129, 0.28);
  transform: scale(1.08);
}
.toggle-paid-btn.is-unpaid {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}
.toggle-paid-btn.is-unpaid:hover {
  background: rgba(239, 68, 68, 0.25);
  transform: scale(1.08);
}

/* Weekly Rekap Cells & Sticky Matrix Columns */
.rekap-cell-btn {
  height: 1.75rem;
  width: 2.375rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  margin: 0 auto;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.rekap-cell-btn.is-paid {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.15);
}
.rekap-cell-btn.is-paid:hover {
  transform: scale(1.08);
  background: rgba(16, 185, 129, 0.32);
  border-color: #10b981;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}
.rekap-cell-btn.is-unpaid {
  background: rgba(255, 255, 255, 0.02);
  color: #64748b;
  border: 1px dashed rgba(100, 116, 139, 0.4);
}
.rekap-cell-btn.is-unpaid:hover {
  transform: scale(1.08);
  border-color: #94a3b8;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
}

/* Pekan Libur Kas (Tidak Perlu Bayar Kas / Disabled / Merah Samar) */
.rekap-cell-btn.is-holiday {
  background: rgba(239, 68, 68, 0.12) !important;
  color: rgba(248, 113, 113, 0.8) !important;
  border: 1px dashed rgba(239, 68, 68, 0.38) !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  transform: none !important;
  pointer-events: none !important;
}

.rekap-cell-holiday-col {
  background-color: rgba(239, 68, 68, 0.04) !important;
}

.rekap-header-holiday-col {
  background-color: rgba(239, 68, 68, 0.14) !important;
  color: #fca5a5 !important;
  border-bottom: 2px solid rgba(239, 68, 68, 0.5) !important;
}

/* Sticky Column Headers & Cells for Wide Matrix - Zero Bleed / 100% Opaque Seam */
.admin-table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

.sticky-col-no {
  position: sticky !important;
  left: 0 !important;
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  background-color: #070b14 !important;
  z-index: 25 !important;
  border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
  padding-left: 0.5rem !important;
  padding-right: 0.5rem !important;
  box-sizing: border-box !important;
  vertical-align: middle !important;
}

.sticky-col-name {
  position: sticky !important;
  left: 47px !important; /* 1px overlap eliminates any subpixel gap on Windows display scaling */
  width: 215px !important;
  min-width: 215px !important;
  max-width: 245px !important;
  background-color: #070b14 !important;
  z-index: 24 !important;
  border-right: 2px solid rgba(239, 68, 68, 0.45) !important;
  box-shadow: 8px 0 18px -2px rgba(0, 0, 0, 0.9) !important;
  padding-left: 0.875rem !important;
  padding-right: 0.875rem !important;
  box-sizing: border-box !important;
  vertical-align: middle !important;
}

/* Thead Sticky Overrides */
thead .sticky-col-no {
  position: sticky !important;
  left: 0 !important;
  top: 0 !important;
  background-color: #0d1424 !important;
  z-index: 45 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

thead .sticky-col-name {
  position: sticky !important;
  left: 47px !important;
  top: 0 !important;
  background-color: #0d1424 !important;
  z-index: 44 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 8px 0 18px -2px rgba(0, 0, 0, 0.9) !important;
}

/* Row Hover on Sticky Columns */
tbody tr:hover .sticky-col-no,
tbody tr:hover .sticky-col-name {
  background-color: #0e1629 !important;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
  animation: fadeIn 0.25s ease-out forwards;
}

/* ==========================================================================
   OPTIMASI RESPONSIVE KHUSUS MOBILE PHONE / LAYAR KECIL (MAX 768px & 640px)
   Rombak total agar nyaman di HP tanpa perlu mengaktifkan mode situs desktop
   ========================================================================== */
@media (max-width: 768px) {
  #particlesCanvas,
  .cyber-ambient-light,
  .cyber-grid-overlay {
    display: none !important;
  }

  body {
    background-color: #06080e !important;
    background-image: 
      radial-gradient(circle at 15% 15%, rgba(255, 42, 95, 0.16) 0%, transparent 45%),
      radial-gradient(circle at 85% 25%, rgba(0, 210, 255, 0.16) 0%, transparent 45%),
      radial-gradient(rgba(56, 189, 248, 0.12) 1px, transparent 1px) !important;
    background-size: 100% 100%, 100% 100%, 24px 24px !important;
    background-attachment: scroll !important;
  }

  .glass-panel {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: #0a0e18 !important;
    border: 1px solid rgba(56, 189, 248, 0.2) !important;
    border-radius: 0.875rem !important;
  }

  /* Header & Topbar bebas compositing blur */
  header {
    background: #06080e !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* Modals di Mobile */
  .modal-overlay {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(6, 8, 14, 0.95) !important;
  }
  .modal-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8) !important;
  }

  .sync-pulsing-dot::after {
    animation: none !important;
  }

  /* Smooth Touch Momentum Scrolling */
  .overflow-x-auto,
  .scrollbar-custom {
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
  }

  /* KAS REKAP MATRIX: Rampingkan Kolom Sticky agar muat di layar HP */
  .sticky-col-no {
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    padding-left: 2px !important;
    padding-right: 2px !important;
    font-size: 10px !important;
    text-align: center !important;
  }

  .sticky-col-name {
    left: 31px !important; /* Pas menutup celah dengan overlap 1px */
    width: 112px !important;
    min-width: 112px !important;
    max-width: 118px !important;
    padding-left: 5px !important;
    padding-right: 5px !important;
    box-shadow: 4px 0 12px -2px rgba(0, 0, 0, 0.85) !important;
  }

  thead .sticky-col-no {
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    padding: 3px 2px !important;
    font-size: 10px !important;
  }

  thead .sticky-col-name {
    left: 31px !important;
    width: 112px !important;
    min-width: 112px !important;
    max-width: 118px !important;
    padding: 3px 5px !important;
    font-size: 10px !important;
  }

  /* Weekly Matrix Cell Buttons: Lebih proporsional & pas di jari HP */
  .rekap-cell-btn {
    height: 1.5rem !important;
    width: 1.75rem !important;
    min-width: 1.75rem !important;
    font-size: 0.65rem !important;
    border-radius: 0.25rem !important;
    margin: 0 auto !important;
  }

  /* Th Pekan di Header Matriks */
  #adminRekapTableHead th {
    padding: 3px 1px !important;
    font-size: 9px !important;
  }

  /* Summary Columns di Matriks (Lunas, Total Kas, Tunggakan) */
  .rekap-col-summary {
    padding: 3px 5px !important;
    font-size: 10px !important;
  }

  /* Buttons & Inputs Mobile Sizing */
  .btn-primary-red,
  .btn-glass-subtle {
    padding: 0.5rem 0.875rem !important;
    font-size: 0.75rem !important;
    border-radius: 0.625rem !important;
  }

  .cyber-input {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.8125rem !important;
    border-radius: 0.625rem !important;
  }

  /* Custom Filter Tabs on Mobile */
  .filter-tab {
    padding: 0.35rem 0.625rem !important;
    font-size: 0.6875rem !important;
  }
}

/* Ergonomic Bottom Sheet Style for Mobile Modals */
@media (max-width: 640px) {
  .modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important;
  }

  .modal-card {
    max-height: 90vh !important;
    overflow-y: auto !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 1.25rem !important;
    border-top-right-radius: 1.25rem !important;
    padding: 1.125rem 1.25rem !important;
    margin: 0 !important;
    width: 100% !important;
  }
}
