@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* VARIABEL TEMA */
:root {
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #334155;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --sidebar-bg: #0f172a;
  --table-header: #f8fafc;
}

body.dark-mode {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --sidebar-bg: #020617;
  --table-header: #0f172a;
}

body { 
    background-color: var(--bg-main); 
    color: var(--text-main); 
    font-family: 'Inter', sans-serif; 
    overflow-x: hidden; 
    transition: background-color 0.3s; 
}

/* CUSTOM SCROLLBAR ELEGAN */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.4); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.7); }
body.dark-mode ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); }
body.dark-mode ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }

/* SIDEBAR LAYOUT */
#sidebar { 
    height: 100vh; 
    background-color: var(--sidebar-bg); 
    color: #94a3b8; 
    width: 260px; 
    box-shadow: 4px 0 10px rgba(0,0,0,0.05); 
    z-index: 1050; 
    transition: left 0.3s ease;
    position: fixed; 
    left: 0; 
    top: 0; 
    display: flex; 
    flex-direction: column;
}

.sidebar-logo { 
    padding: 20px 20px 15px; 
    font-size: 20px; 
    font-weight: 700; 
    color: #fff; 
    border-bottom: 1px solid rgba(255,255,255,0.05); 
    margin-bottom: 10px; 
    flex-shrink: 0; 
}

.sidebar-logo i { color: #38bdf8; margin-right: 8px; }
.menu-wrapper { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: 20px; }
.footer-wrapper { flex-shrink: 0; border-top: 1px solid rgba(255,255,255,0.05); padding: 10px; }

#sidebar a { 
    color: #94a3b8; 
    text-decoration: none; 
    padding: 12px 20px; 
    display: flex; 
    align-items: center; 
    border-radius: 8px; 
    margin: 4px 15px; 
    font-size: 14.5px; 
    font-weight: 500; 
    transition: all 0.3s ease; 
    cursor: pointer;
}

#sidebar a i { width: 22px; font-size: 16px; margin-right: 12px; text-align: center; }
#sidebar a:hover { background-color: rgba(255,255,255,0.05); color: #fff; transform: translateX(4px); }
#sidebar a.active { background: linear-gradient(118deg, #3b82f6, #2563eb); color: white; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); }

.sidebar-header { font-size: 11px; font-weight: 700; color: #475569; letter-spacing: 1.5px; padding: 15px 20px 5px; text-transform: uppercase; margin-top: 5px;}
.sub-menu { padding-left: 20px !important; font-size: 13.5px !important; }

/* CONTENT WRAPPER */
.content-wrapper { 
    padding: 1.5rem; 
    width: calc(100% - 260px); 
    margin-left: 260px; 
    transition: margin-left 0.3s, width 0.3s; 
    min-height: 100vh; 
}

.sec-target { display: none !important; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* TABLES FIX UI OVERFLOW */
.table-responsive { border-radius: 8px; border: 1px solid var(--border-color); overflow-x: auto; width: 100%; -webkit-overflow-scrolling: touch; }
.table { margin-bottom: 0; color: var(--text-main); width: 100%; }
.table thead { background-color: var(--table-header); border-bottom: 2px solid var(--border-color);}
.table thead th { border-bottom: none; color: var(--text-muted); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; padding: 16px; white-space: nowrap; }
.table tbody td { padding: 16px; vertical-align: middle; border-bottom: 1px solid var(--border-color); font-size: 14px; }

body.dark-mode .table tbody tr:hover { background-color: rgba(255,255,255,0.02) !important; }
body:not(.dark-mode) .table tbody tr:hover { background-color: #f8fafc; }

/* =======================================================
   DARK MODE FIX UNTUK MODAL, INPUT, & TEXT OVERRIDES
   ======================================================= */
body.dark-mode .modal-content { background-color: #0f172a !important; color: #f8fafc !important; border: 1px solid #334155;}
body.dark-mode input.form-control, body.dark-mode select.form-select, body.dark-mode textarea.form-control { background-color: #1e293b !important; color: #f8fafc !important; border-color: #334155 !important; }
body.dark-mode select option { background-color: #1e293b; color: #f8fafc; }
body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator, body.dark-mode input[type="datetime-local"]::-webkit-calendar-picker-indicator, body.dark-mode input[type="month"]::-webkit-calendar-picker-indicator { filter: invert(1); }
body.dark-mode input[type="color"] { border: 1px solid #334155 !important; }

body.dark-mode .text-primary { color: #60a5fa !important; }
body.dark-mode .text-success { color: #4ade80 !important; }
body.dark-mode .text-danger { color: #f87171 !important; }
body.dark-mode .text-warning { color: #fbbf24 !important; }
body.dark-mode .text-info { color: #38bdf8 !important; }
body.dark-mode .text-secondary { color: #cbd5e1 !important; }
body.dark-mode .text-dark { color: #f8fafc !important; }
body.dark-mode .text-muted { color: #94a3b8 !important; } 

body.dark-mode label, body.dark-mode .form-label { color: #f8fafc !important; } 
body.dark-mode .bg-light { background-color: #1e293b !important; color: #f8fafc !important; } 
body.dark-mode #user-info { color: #cbd5e1 !important; }

body.dark-mode .table,
body.dark-mode .table > :not(caption) > * > * {
    background-color: transparent !important;
    color: #f8fafc !important;
    border-bottom-color: #334155 !important;
}
body.dark-mode .table-light th {
    background-color: #1e293b !important;
}

body.dark-mode .alert { background-color: rgba(255,255,255,0.05); color: #f8fafc; border-color: #334155; } 
body.dark-mode .alert-info { background-color: rgba(14, 165, 233, 0.15); color: #bae6fd; border-color: #0284c7; }
body.dark-mode .alert-warning { background-color: rgba(245, 158, 11, 0.15); color: #fde68a !important; border-color: #d97706; }
body.dark-mode .alert-success { background-color: rgba(16, 185, 129, 0.15); color: #a7f3d0; border-color: #059669; }
body.dark-mode .alert-danger { background-color: rgba(239, 68, 68, 0.15); color: #fecaca; border-color: #dc2626; }

body.dark-mode .modal-header { border-bottom: 1px solid #334155; }
body.dark-mode .modal-footer { border-top: 1px solid #334155; }
body.dark-mode .list-group-item { background-color: #1e293b; color: #f8fafc; border-color: #334155; }
body.dark-mode .card-header { background-color: #0f172a; color: #f8fafc; border-bottom: 1px solid #334155; }

/* MOBILE LAYOUT */
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1040; cursor: pointer; }
.mobile-header { display: none; }
.mobile-bottom-nav { display: none; }

@media (max-width: 768px) {
  #sidebar { left: -260px; padding-bottom: 0; }
  #sidebar.open { left: 0; }
  .mobile-overlay.open { display: block; }
  .content-wrapper { margin-left: 0; width: 100%; padding: 1.2rem !important; padding-top: 85px !important; padding-bottom: 90px !important; }
  .mobile-header { display: flex !important; position: fixed; top: 0; left: 0; right: 0; z-index: 1020; background: var(--bg-card); box-shadow: 0 2px 10px rgba(0,0,0,0.05); height: 65px; border-bottom: 1px solid var(--border-color); }
  .mobile-bottom-nav { display: flex !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1020; background: var(--bg-card); box-shadow: 0 -4px 15px rgba(0,0,0,0.05); height: calc(65px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); justify-content: space-around; align-items: center; border-top: 1px solid var(--border-color);}
  .mobile-bottom-nav a { display: flex; flex-direction: column; align-items: center; color: var(--text-muted); text-decoration: none; font-size: 10px; font-weight: 600; gap: 4px; padding: 5px 15px;}
  .mobile-bottom-nav a.active { color: #3b82f6; }
  .d-md-none-custom { display: none !important; } 
}
@media (min-width: 769px) { .d-md-none-custom { display: block !important; } }

/* ROLE DISPLAY RULES */
.admin-only, .super-admin-only { display: none !important; }
body.is-admin .admin-only { display: inline-block !important; }
body.is-admin div.admin-only, body.is-admin #sidebar a.admin-only, body.is-admin .mobile-bottom-nav a.admin-only { display: flex !important; }
body.is-admin th.admin-only, body.is-admin td.admin-only { display: table-cell !important; }
body.is-super-admin .super-admin-only { display: inline-block !important; }
body.is-super-admin div.super-admin-only, body.is-super-admin #sidebar a.super-admin-only { display: flex !important; }
body.is-super-admin th.super-admin-only, body.is-super-admin td.super-admin-only { display: table-cell !important; }
body.is-user .user-hidden { display: none !important; }

/* COMPONENTS */
#login-screen-outer { background: radial-gradient(circle at center, #1e3a8a 0%, #0f172a 100%); position: fixed; inset:0; z-index: 2000; }
.login-card { background: var(--bg-card) !important; border-radius: 20px; width: 420px; max-width: 90%; z-index: 2; position: relative;}
.login-icon { width: 65px; height: 65px; font-size: 28px; background: linear-gradient(118deg, #3b82f6, #2563eb) !important; color: white !important; }
.badge-ikan { background-color: #dbeafe; color: #0369a1; border: 1px solid #bae6fd; font-weight: 600;}
.badge-kosong { background-color: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; font-weight: 600;}

/* KARTU KAS & GLOW */
.card-saldo { background: linear-gradient(135deg, var(--grad1, #10b981), var(--grad2, #059669)); color: white; border-radius: 15px; padding: 25px; position: relative; overflow: hidden;}
.card-saldo h3 { font-size: clamp(1.5rem, 4vw, 2.2rem); margin: 0; margin-top: 10px; }
.card-saldo::after { content: ''; position: absolute; top: -50%; right: -20%; width: 200px; height: 200px; background: rgba(255,255,255,0.1); border-radius: 50%; pointer-events: none;}

/* ANIMASI GLOW UNTUK KARTU KAS */
.card-saldo-glow {
    border: 3px solid transparent !important;
    background-image: 
        linear-gradient(135deg, var(--grad1), var(--grad2)), 
        conic-gradient(from var(--angle), 
            transparent 20%, var(--warna-glow) 48%, #ffffff 50%, 
            transparent 50%, transparent 70%, var(--warna-glow) 98%, #ffffff 100%);
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
    box-shadow: 0 0 15px var(--warna-glow) !important;
    animation: spinOutline 6s linear infinite; /* PERBAIKAN: Diperlambat jadi 6 detik */
    cursor: pointer;
    transition: transform 0.2s ease;
}
.card-saldo-glow:active { transform: scale(0.96); transition: transform 0.1s ease; }

.text-saldo-responsive {
    white-space: normal !important;
    word-break: break-word !important;
    font-size: clamp(16px, 3vw, 24px) !important;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.bank-logo-box i { color: #0f172a !important; }
.bank-logo-box {
    display: inline-flex; align-items: center; justify-content: center;
    width: 35px; height: 35px; border-radius: 8px; margin-right: 10px;
    font-size: 18px; font-weight: bold; color: white; box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.status-batal { text-decoration: line-through; opacity: 0.5; color: #ef4444 !important; }
.card-box { border-radius: 12px; border: 1px solid var(--border-color); background: var(--bg-card); padding: 20px; margin-bottom: 20px;}

/* =======================================================
   DYNAMIC GRID BUILDER & ANIMASI RUNNING OUTLINE 2 GARIS
   ======================================================= */
.denah-container { background: var(--sidebar-bg); padding: 30px; border-radius: 12px; position: relative; margin-bottom: 20px; overflow-x: auto;}
.denah-grid { display: grid; gap: 12px; margin: 0 auto; justify-content: center; }

@property --angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes spinOutline {
  to { --angle: 360deg; }
}

.petak { 
    background: #1e293b; 
    border: 3px solid #334155; 
    border-radius: 8px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: white; 
    font-weight: bold; 
    font-size: 14px; 
    cursor: pointer; 
    transition: transform 0.2s ease; 
    position: relative; 
    width: 100%; 
    height: 100%; 
    min-width: 110px; 
    min-height: 80px; 
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.petak::after { content: 'Kosong'; font-size: 10px; position: absolute; bottom: 5px; opacity: 0.5; color: #cbd5e1; }

.petak:hover { transform: scale(0.97); z-index: 10; }
.petak:active { transform: scale(0.92) !important; transition: transform 0.1s ease; }

.petak.terisi { 
    --warna-ikan: #38bdf8; 
    border: 3px solid transparent !important;
    background-image: 
        linear-gradient(#0ea5e9, #0ea5e9), 
        conic-gradient(from var(--angle), 
            transparent 20%, var(--warna-ikan) 48%, #ffffff 50%, 
            transparent 50%, transparent 70%, var(--warna-ikan) 98%, #ffffff 100%);
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
    box-shadow: 0 0 15px var(--warna-ikan) !important;
    animation: spinOutline 6s linear infinite; /* PERBAIKAN: Diperlambat jadi 6 detik */
}

.petak.terisi::after { content: 'Terisi'; color: #ffffff; opacity: 1; font-weight: bold;}

.petak.fasilitas { 
    --warna-ikan: #8b5cf6; 
    border: 3px solid transparent !important;
    background-image: 
        linear-gradient(var(--warna-ikan), var(--warna-ikan)), 
        conic-gradient(from var(--angle), 
            transparent 20%, #ffffff 48%, #ffffff 50%, 
            transparent 50%, transparent 70%, #ffffff 98%, #ffffff 100%);
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
    box-shadow: 0 0 15px var(--warna-ikan) !important;
    animation: spinOutline 6s linear infinite;
}
.petak.fasilitas::after { content: 'Fasilitas'; color: #ffffff; opacity: 1; font-weight: bold;}


.petak-tambah {
    background: rgba(255,255,255,0.05); 
    border: 3px dashed #475569; 
    border-radius: 8px;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: #475569; 
    font-size: 28px; 
    cursor: pointer; 
    transition: transform 0.2s ease, background 0.3s, border-color 0.3s;
    min-width: 110px; 
    min-height: 80px;
}

.petak-tambah:hover { background: rgba(56,189,248,0.2); border-color: #38bdf8; color: #38bdf8; transform: scale(0.97); }
.petak-tambah:active { transform: scale(0.92) !important; transition: transform 0.1s ease; }

.petak-hapus-btn {
    position: absolute; top: -8px; right: -8px; background: #ef4444; color: white; border-radius: 50%;
    width: 24px; height: 24px; font-size: 12px; display: flex; align-items: center; justify-content: center;
    border: 2px solid white; cursor: pointer; z-index: 20; box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.petak-hapus-btn:hover { background: #b91c1c; transform: scale(1.1); }

.tooltip-inner { background-color: #0f172a; border: 2px solid #38bdf8; text-align: left; padding: 12px; max-width: 250px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.5);}

.color-legend { display: flex; flex-wrap: wrap; gap: 15px; justify-content: center; margin-top: 20px;}
.legend-item { display: flex; align-items: center; gap: 8px; color: #f8fafc; font-size: 13px; font-weight: 500;}
.legend-color { width: 16px; height: 16px; border-radius: 4px; border: 2px solid rgba(255,255,255,0.2); }

/* UTILITIES */
.filter-wrap { background: var(--bg-main); padding: 10px; border-radius: 8px; border: 1px solid var(--border-color); }

/* SMART FEED PANEL */
.smart-feed-panel { background: linear-gradient(135deg, #1e293b, #0f172a); border: 1px solid #334155; border-radius: 12px; color: #f8fafc; overflow: hidden; }
.sfp-header { background: rgba(56, 189, 248, 0.1); padding: 15px 20px; border-bottom: 1px solid #334155; display: flex; justify-content: space-between; align-items: center;}
.sfp-item { padding: 15px 20px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.sfp-item:last-child { border-bottom: none; }
.sfp-time-badge { font-size: 11px; padding: 4px 8px; background: rgba(255,255,255,0.1); border-radius: 4px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px;}
.sfp-time-badge.done { background: rgba(16, 185, 129, 0.2); color: #34d399; }

body:not(.dark-mode) .smart-feed-panel { background: #ffffff; color: #334155; border-color: #e2e8f0; }
body:not(.dark-mode) .sfp-header { background: #f0f9ff; border-color: #e0f2fe; }
body:not(.dark-mode) .sfp-item { border-color: #f1f5f9; }
body:not(.dark-mode) .sfp-time-badge { background: #f1f5f9; color: #475569; }
body:not(.dark-mode) .sfp-time-badge.done { background: #d1fae5; color: #059669; }

/* NOTA PREVIEW MOBILE SCROLLER */
.preview-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 15px;
}

#nota-preview-wrapper { 
    font-family: Arial, sans-serif; 
    color: #000; 
    background: #fff; 
    padding: 20px; 
    border: 1px dashed #ccc; 
    width: 100%; 
    max-width: 600px; 
    margin: 0 auto; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); 
}

/* NOTIFIKASI PENDING APPROVE */
.notif-badge-wrapper { margin-left: auto; display: flex; align-items: center; }
.notif-angka { background: #ef4444; color: white; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; box-shadow: 0 2px 5px rgba(239, 68, 68, 0.4); animation: pulseNotif 2s infinite; }
.notif-titik { background: #ef4444; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 2px 5px rgba(239, 68, 68, 0.4); animation: pulseNotif 2s infinite; }
@keyframes pulseNotif { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* =======================================================
   DARK MODE FIX KHUSUS TABEL REKAP & SAMPLING
   ======================================================= */
body.dark-mode .table-fix-darkmode th,
body.dark-mode .table-fix-darkmode td {
    color: #f8fafc !important;
    border-color: #334155 !important;
}
body.dark-mode .table-fix-darkmode .table-light th {
    background-color: #0f172a !important; 
    color: #94a3b8 !important;
}
body.dark-mode .table-fix-darkmode .table-success th,
body.dark-mode .table-fix-darkmode .table-success td {
    background-color: rgba(16, 185, 129, 0.2) !important;
    color: #4ade80 !important;
    border-color: #059669 !important;
}.petak.pondok::after, .petak.gudang::after { display: none !important; }
.petak.pondok { box-shadow: 0 0 15px rgba(139, 69, 19, 0.4); border: 2px solid #cd853f !important; }
.petak.gudang { box-shadow: 0 0 15px rgba(71, 85, 105, 0.4); border: 2px solid #94a3b8 !important; }
