/* ==========================================================================
   SI ANAKODE - CORE CSS (REVISED & AUDITED)
   ========================================================================== */

:root {
    /* Default (Light Mode) Variables */
    --sidebar-bg: #f8f9fa;
    --main-bg: #f1f5f9;
    --card-bg: #ffffff;
    --accent-blue: #0d6efd;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --navbar-height: 65px;
    --sidebar-width: 80px; /* Base width for icons */
    --sidebar-collapsed-width: 80px;
    --bg-subtle: #f8fafc;
}

/* Override untuk Dark Mode */
[data-bs-theme="dark"] {
    --sidebar-bg: #1c1e23;
    --main-bg: #141619;
    --card-bg: #212529;
    --text-main: #ffffff;
    --text-muted: #adb5bd;
    --border-color: #343a40;
    --bg-subtle: #2c3036;
}

/* Base Style */
body {
    background-color: var(--main-bg);
    color: var(--text-main);
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
    transition: background 0.3s, color 0.3s;
    margin: 0;
}

/* ==========================================================================
   LAYOUT: SIDEBAR & NAVBAR
   ========================================================================== */

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 15px;
    padding-bottom: 20px;
    z-index: 1045; /* Di atas navbar */
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    transition: all 0.3s ease;
}

.sidebar::-webkit-scrollbar { display: none; }

.sidebar .nav-link {
    color: var(--text-muted);
    text-align: center;
    padding: 10px 5px;
    width: 100%;
    transition: all 0.3s;
    /* Tambahan agar simetris */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    border-left: 3px solid transparent;
}

.sidebar .nav-link i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0; /* Reset margin default */
}
/* Jika ada span di bawahnya, baru beri margin */
.sidebar .nav-link i + span {
    margin-top: 5px;
}
.sidebar .nav-link:hover, 
.sidebar .nav-link.active {
    color: var(--accent-blue) !important;
    background-color: rgba(13, 110, 253, 0.1);
    border-left: 3px solid var(--accent-blue);
}

.sidebar i {
    font-size: 1.4rem; /* Ukuran ikon sedikit diperkecil agar lebih elegan */
    line-height: 1;
    display: block;
    margin-bottom: 5px;
}
/* Wrapper di dalam link agar alignment terkontrol */
.nav-icon-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}


/* Top Navbar */
.top-navbar {
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    height: var(--navbar-height);
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 1040;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    transition: all 0.3s ease;
}
/* Label Teks (Hanya untuk yang punya sub-menu) */
.nav-label {
    font-size: 0.6rem;
    line-height: 1.1;
    text-align: center;
    word-wrap: break-word; /* Memastikan teks panjang pindah baris dengan rapi */
    margin-top: 5px;
    width: 100%;
    transition: all 0.3s ease;
}
.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    padding-top: calc(var(--navbar-height) + 20px);
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* ==========================================================================
   COMPONENTS: CARDS, TABLES, BADGES
   ========================================================================== */

.data-card, .summary-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 4px 18px rgba(0,0,0,.05);
    border: 1px solid var(--border-color);
    padding: 20px;
    transition: transform 0.2s;
}

/* Card Khusus Dashboard */
.welcome-card { background-color: var(--bg-subtle); }

.firewall-card {
    background: linear-gradient(135deg, #1c1e23 0%, #3a0ca3 100%) !important;
    color: #ffffff !important;
    border: none;
}
.firewall-card p { opacity: 0.85; color: #ffffff !important; }
.firewall-card i, .firewall-card h5 { color: #ffffff !important; }

/* Table Styling */
.table { color: var(--text-main); }
.table thead th {
    font-size: .75rem;
    text-transform: uppercase;
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding: 12px;
}
.table-hover tbody tr:hover { background-color: rgba(13, 110, 253, 0.02); }

/* Badges */
.badge-soft {
    padding: 6px 12px;
    border-radius: 50px;
    font-weight: 600;
    font-size: .7rem;
}
.badge-membaik { background:#dcfce7; color:#166534; }
.badge-tetap { background:#fef3c7; color:#92400e; }
.badge-buruk { background:#fee2e2; color:#991b1b; }

/* Submenu Side Flyout */
/* Styling untuk submenu yang muncul dari samping */
.submenu-flyout {
    position: fixed;
    left: 80px; 
    top: var(--navbar-height);
    width: 250px;
    height: calc(100vh - 65px);
    /* Gunakan variabel agar warna berubah otomatis */
    background-color: var(--sidebar-bg); 
    border-right: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    z-index: 1005;
    padding: 20px;
    display: none;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.submenu-flyout h5 {
    font-size: 0.9rem;
    color: var(--accent-blue);
    text-transform: uppercase;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

/* Pastikan judul dan link di dalam submenu tajam */
#submenuTitle {
    font-size: 0.9rem;
    color: var(--accent-blue);
    text-transform: uppercase;
    margin-bottom: 20px;
    letter-spacing: 1px;
    font-weight: bold;
}

.submenu-link {
    display: block;
    color: var(--text-muted);
    text-decoration: none;
    padding: 10px 0;
    font-size: 0.9rem;
    transition: 0.2s;
}

.submenu-link:hover {
    color: var(--accent-blue);
    padding-left: 8px;
}

/* Forms (Tambahan Audit) */
.form-control, .form-select {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 0.8rem;
}
.form-control:focus, .form-select:focus {
    background-color: var(--card-bg);
    color: var(--text-main);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1);
    border-color: #0d6efd;
}

/* custom */
.card-app { border: none; box-shadow: 0 10px 30px rgba(0,0,0,0.05); border-radius: 1.5rem; background: #fff; }
.app-label { font-size: 0.75rem; font-weight: 700; color: #6c757d; margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.5px; }
.section-title { color: #0d6efd; font-weight: 700; margin-bottom: 1rem; display: flex; align-items: center; border-bottom: 2px solid #f1f5f9; padding-bottom: 0.5rem; }
.section-title i { margin-right: 0.5rem; }
.section-box { background: #ffffff; border: 1px solid #edf2f7; border-radius: 1.2rem; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.bg-analysis { background: #f0f7ff; border: 1px dashed #0d6efd; }
.border-dashed-primary { border: 2px dashed #cbd5e1; cursor: pointer; border-radius: 1rem; transition: all 0.2s; }
.border-dashed-primary:hover { border-color: #0d6efd; background: #f8faff; }
.input-group-text-custom { background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 0.8rem 0 0 0.8rem; font-weight: 600; font-size: 0.8rem; }

/* Memastikan seluruh input, select, dan select2 memiliki tinggi yang persis sama */
.form-control-sm, 
.form-select-sm, 
.select2-container--bootstrap-5 .select2-selection {
    min-height: 31px !important;
    height: 31px !important;
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    font-size: 0.875rem !important;
    display: flex !important;
    align-items: center !important;
}

/* Penyesuaian panah dan teks di dalam Select2 Bootstrap 5 agar center secara vertikal */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: normal !important;
    padding-left: 0.5rem !important;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    top: 50% !important;
    transform: translateY(-50%);
    right: 0.5rem !important;
}

/* Menyamakan tinggi input group agar elemen di dalamnya ikut seragam */
.input-group-sm > .form-control,
.input-group-sm > .input-group-text {
    height: 31px !important;
}
/* Overlay harus menutupi seluruh layar */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Warna gelap transparan */
    z-index: 998; /* Di bawah sidebar (1000) */
}
/* ==========================================================================
   RESPONSIVE SCENARIO (HP & TABLET)
   ========================================================================== */

/* HP / Mobile (< 768px) */
@media (max-width: 767.98px) {
    .sidebar {
        left: -100%; /* Sembunyikan total */
        transition: all 0.3s ease;
        z-index: 1000;
    }
    .sidebar.show {
        left: 0;
        width: 80px;
    }
    .top-navbar {
        left: 0 !important;
        width: 100%;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 15px;
        padding-top: calc(var(--navbar-height) + 15px);
    }
    .brand-logo {
        max-width: 160px;
        font-size: 1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .sidebar { width: 70px; }
    .nav-label { display: none; } /* Hanya ikon agar lega */
    .top-navbar { left: 70px; }
    .main-content { margin-left: 70px; }
}

@media print {
    /* 1. Sembunyikan elemen yang tidak penting di kertas */
    .navbar, 
    .sidebar, 
    #sidebar, 
    .d-print-none, 
    .btn-group,
    header,
    footer {
        display: none !important;
    }

    /* 2. Opsional: Maksimalkan lebar konten utama agar penuh seukuran kertas A4/F4 */
    .main-content, 
    .container-fluid, 
    body {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        background-color: #fff !important;
    }
    
    /* 3. Menghilangkan shadow/bayangan card agar hemat tinta printer */
    .card {
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
    }
}