/* --- Global Styles & Modern Variables --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --text-color: #212529;      /* Darker text for better contrast */
    --text-color-light: #6c757d; /* Softer secondary text */
    --bg-color: #f8f9fa;        /* Lighter background */
    --bg-light: #ffffff;
    --border-color: #dee2e6;    /* Lighter borders */
    --shadow-color: rgba(0, 0, 0, 0.05); /* Softer shadow */
}
[data-theme="dark"] {
    --primary-color: #4dabff;
    --primary-hover: #79c0ff;
    --text-color: #e6edf3;
    --text-color-light: #8b949e;
    --bg-color: #0d1117;
    --bg-light: #161b22;
    --border-color: #30363d;
    --shadow-color: rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .search-results-overlay {
    background: #161b22;
    border-color: #30363d;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

[data-theme="dark"] .search-results-overlay li {
    color: #e6edf3;
}

[data-theme="dark"] .search-results-overlay li:hover {
    background-color: #1f2937;
    color: #4dabff;
}

[data-theme="dark"] .search-results-overlay li.keyboard-active {
    background-color: #1f2937;
    color: #4dabff;
}

[data-theme="dark"] .header .search-container input {
    background: #161b22;
    color: #e6edf3;
    border-color: #30363d;
}

[data-theme="dark"] .header .search-container input::placeholder {
    color: #8b949e;
}
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

/* --- Main Layout --- */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* --- Modern Header --- */
.header {
    height: 70px;
    background: var(--bg-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    z-index: 100;
}

.header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
}

.header .logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header .search-container {
    position: relative;
    width: 40%;
}

.header .search-container i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-color-light);
}

.header .search-container input {
    width: 100%;
    height: 44px;
    padding: 10px 20px 10px 45px;
    border: 1px solid var(--border-color);
    border-radius: 22px; /* Pill shape */
    font-size: 1rem;
    color: var(--text-color);
    transition: all 0.2s ease-in-out;
}

.header .search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.15);
}

/* --- Modern Sidebar --- */
.sidebar {
    width: 280px;
    background: var(--bg-light);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 15px;
}

.sidebar-logo {
    display: none; /* ← TAMBAHKAN INI */
}

/* Custom Scrollbar */
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #aaa; }

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: var(--text-color-light);
    font-weight: 500;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
}
.menu-item:hover {
    background-color: var(--bg-color);
    color: var(--text-color);
    transform: translateX(3px);
}
/* --- Perbaikan Warna Aktif Sidebar --- */

/* 1. Warna Biru Pekat HANYA untuk item yang benar-benar aktif (Sub-menu atau Home) */
.sub-menu li.active, 
#home-btn.active {
    background-color: var(--primary-color) !important;
    color: #fff !important;
    font-weight: 600;
}

/* 2. Gaya untuk Tombol Utama (Class, Tables, dll) saat sedang terbuka/expanded */
/* Kita buat teksnya saja yang biru, tapi background tetap transparan agar tidak double biru */
.menu-item.active {
    background-color: rgba(0, 123, 255, 0.1); /* Biru sangat muda (transparan) */
    color: var(--primary-color);
    font-weight: 600;
}

/* 3. Pastikan Hover pada item aktif tidak merusak warna */
.sub-menu li.active:hover, 
#home-btn.active:hover {
    background-color: var(--primary-hover) !important;
}
.menu-item.active:hover {
    background: var(--primary-hover);
    color: #fff;
}
.menu-item i { margin-right: 15px; }
.menu-group .arrow { margin-left: auto; transition: transform 0.3s ease; }
.menu-item.expanded .arrow { transform: rotate(180deg); }

.sub-menu { list-style: none; padding-left: 25px; display: none; margin-top: 5px; }
.sub-menu.show { display: block; }
.sub-menu li {
    padding: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 5px;
    color: var(--text-color-light);
    transition: background-color 0.2s ease, color 0.2s ease;
}
.sub-menu li:hover { background-color: var(--bg-color); color: var(--text-color); }
.sub-menu li.active:hover { background: var(--primary-hover); color: #fff; }

/* --- Dark Mode Button --- */
.sidebar-divider {
    height: 1px;
    background: var(--border-color);
    margin: 10px 0;
    margin-top: auto;
}

.dark-mode-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text-color-light);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    padding: 12px 15px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    text-align: left;
}

.dark-mode-btn:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.dark-mode-btn i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.dark-mode-btn {
    margin-top: 0;
}

/* --- Modern Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-color);
    min-height: 0;
}

.viewer-header {
    padding: 15px 25px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-light);
    font-size: 1.1rem;
    font-weight: 600;
    position: sticky; /* ← TAMBAHKAN */
    top: 0;           /* ← TAMBAHKAN */
    z-index: 10;  
}
/* --- Breadcrumb --- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.88rem;
    color: var(--text-color-light);
}

.breadcrumb-home {
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
}

.breadcrumb-home:hover {
    text-decoration: underline;
}

.breadcrumb-sep {
    color: var(--text-color-light);
    font-size: 0.8rem;
}

.breadcrumb-item {
    color: var(--text-color-light);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.breadcrumb-item.active {
    color: var(--text-color);
    font-weight: 600;
}

@media (max-width: 768px) {
    .breadcrumb-item {
        max-width: 150px;
    }
}

#contentViewer {
    flex: 1;
    width: 100%;
    border: none;
    background: #fff;
    min-height: 0;
}

/* --- Modern Search Results --- */
.search-results-overlay {
    position: absolute; /* Position will be set by app.js */
    background: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
    border-radius: 8px; /* Adjusted as per request */
    z-index: 1001;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    list-style: none;
    padding: 8px;
}

.search-results-overlay li {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
    color: var(--text-color);
    font-weight: 500;
}

.search-results-overlay li:hover {
    background-color: #e9f4ff; /* Light blue */
    color: var(--primary-color);
}

/* --- Responsive Design --- */
.menu-toggle-btn {
    display: none; /* Hidden on large screens */
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.5rem;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}

#scrollTopBtn {
    position: fixed;
    bottom: 50px;
    right: 40px;
    width: 42px;
    height: 42px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
    z-index: 999;
}

#scrollTopBtn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#scrollTopBtn:hover {
    background: var(--primary-hover);
}


@media (max-width: 768px) {
    .header {
        padding: 0 15px;
        position: fixed;
        top: 0;          /* ← TAMBAHKAN */
        left: 0;         /* ← TAMBAHKAN */
        right: 0;        /* ← TAMBAHKAN */
        width: 100%; 
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 70px;
        z-index: 999;
    }

    .header .logo {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    .header .logo h1 {
        display: none; /* Hide title on small screens */
    }

    .menu-toggle-btn {
        display: block; /* Show hamburger */
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        z-index: 1000;
        padding-top: 20px; /* Space for header */
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    }
    
    .sidebar-overlay.show {
        display: block;
    }

    .sidebar-overlay { /* ← TAMBAHKAN BLOK BARU INI */
        z-index: 999;
    }
    
    .sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 600;
    padding: 16px 15px 20px;
    width: 100%;
    }

    .sidebar-logo i {
    font-size: 1.4rem;
    }

    .header .search-container {
        position: static;
        width: auto;
        margin-left: auto; /* Mendorong container ke paling kanan */
        display: flex;
        justify-content: flex-end;
    }

    .header .search-container input {
        display: none;
        position: absolute;
        top: 90px; /* Tepat di bawah header */
        left: 15px;
        right: 15px;
        width: calc(100% - 30px);
        height: 44px;
        box-shadow: 0 4px 12px var(--shadow-color);
        z-index: 1000;
    }
    
    .header .search-container i {
        cursor: pointer;
        font-size: 1.3rem;
        position: static; /* Override absolute position from base styles */
        transform: none;
        left: auto; /* Menghapus sisa left: 15px dari base style */
    }

    .header .search-container.expanded input {
        display: block;
    }
    
    .header .search-container.expanded i {
        color: var(--primary-color);
    }
    .main-content {
        margin-top: 70px;
        height: calc(100vh - 70px);
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    #contentViewer {
        flex: 1;
        width: 100%;
        height: auto;
        border: none;
        background: #fff;
        min-height: 0;
    }
    footer {
        flex-shrink: 0; 
        background: var(--bg-light);
        position: relative;
        z-index: 20;
    }
    #scrollTopBtn {
        right: 24px; /* ← mobile tetap 24px */
        bottom: 50px;
    }
}
.search-results-overlay li.keyboard-active {
    background-color: #e8f0fe;
    color: #007bff;
    cursor: pointer;
}