/* ============================================================
   MOBILE OVERRIDE - STYLE RESMI LP2M (Responsive Fix)
   Digunakan untuk memaksa tampilan 1 kolom di HP tanpa menghapus data
   ============================================================ */

/* ---------- RESET DASAR ---------- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    max-width: 100%;
    overflow-x: hidden !important;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', 'Poppins', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7fc;
}

/* ---------- HILANGKAN SCROLL HORIZONTAL ---------- */
.container, .container-fluid, .row, .main-wrapper, #app, .site-content {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* ---------- SEMBUNYIKAN SIDEBAR LAMA DI HP (diganti bottom nav) ---------- */
@media (max-width: 991px) {
    /* Sembunyikan sidebar kiri yang bikin berantakan */
    .sidebar, .side-menu, .col-md-3, .col-lg-3, .col-xl-3,
    [class*="sidebar"], [class*="side-panel"], .menu-mahasiswa,
    #sidebar-wrapper, .left-panel {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        z-index: -1 !important;
    }

    /* Force semua konten utama menjadi lebar penuh (1 kolom) */
    .col-md-9, .col-lg-9, .col-xl-9, .main-content, #content,
    [class*="col-"]:not(.bottom-nav *) {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        float: none !important;
        display: block !important;
    }

    /* Perbaiki row agar tidak meluap */
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Sembunyikan tombol login/panel/keluar di header atas pada HP */
    .nav-actions, #nav-auth-actions {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* Posisikan tombol menu hamburger di sebelah kanan */
    .nav-toggle {
        order: 2 !important;
        display: block !important;
        margin-left: auto !important;
    }

    /* Ruang bawah pada content-area agar tidak tertutup bottom-nav */
    .content-area {
        padding-bottom: 90px !important;
    }

    /* Tampilkan elemen khusus mobile */
    .mobile-only {
        display: block !important;
    }
    .login-register-nav {
        display: block;
    }
}

/* ---------- HERO / BANNER SAPAAN (Seperti LP2M) ---------- */
.hero-welcome {
    background: linear-gradient(145deg, #0a2a5e, #163a7a);
    padding: 30px 25px;
    border-radius: 20px;
    color: white;
    margin-bottom: 25px;
    box-shadow: 0 8px 25px rgba(10, 42, 94, 0.3);
    border: 1px solid rgba(255, 215, 0, 0.2);
    position: relative;
    overflow: hidden;
}
.hero-welcome::after {
    content: "📚";
    position: absolute;
    right: 10px;
    bottom: 10px;
    font-size: 70px;
    opacity: 0.1;
    transform: rotate(-10deg);
}
.hero-welcome h2 {
    color: #f9c74f;
    font-weight: 700;
    margin: 0 0 8px 0;
    font-size: 1.8rem;
    letter-spacing: 0.5px;
}
.hero-welcome p {
    opacity: 0.9;
    margin: 0 0 15px 0;
    font-size: 1rem;
    line-height: 1.6;
}
.hero-welcome .btn-explore {
    display: inline-block;
    background: #f9c74f;
    color: #0a2a5e;
    font-weight: 700;
    padding: 12px 35px;
    border-radius: 50px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(249, 199, 79, 0.4);
    border: none;
    font-size: 1rem;
}
.hero-welcome .btn-explore:hover {
    transform: translateY(-3px);
    background: #ffd966;
    box-shadow: 0 8px 20px rgba(249, 199, 79, 0.6);
}

/* ---------- BOTTOM NAVIGATION (Fixed) PERSIS LP2M ---------- */
.bottom-nav {
    display: none !important; /* Sembunyikan default di Desktop */
}

@media (max-width: 991px) {
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #0a2a5e;
        display: flex !important; /* Tampilkan hanya di HP/Tablet */
        justify-content: space-around;
        align-items: center;
        padding: 8px 5px;
        padding-bottom: env(safe-area-inset-bottom, 10px);
        z-index: 1050;
        border-top: 3px solid #f9c74f;
        box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
        flex-wrap: nowrap;
    }
}

.bottom-nav a {
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    font-size: 11px;
    text-decoration: none;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 5px 2px;
    transition: all 0.2s ease;
    font-weight: 500;
    letter-spacing: 0.3px;
    border-radius: 10px;
}
.bottom-nav a .nav-icon {
    font-size: 22px;
    line-height: 1;
}
.bottom-nav a.active {
    color: #f9c74f !important;
    background: rgba(249, 199, 79, 0.1);
}
.bottom-nav a:hover {
    color: #ffffff;
}

/* ---------- CARD / KOTAK KONTEN (Agar rapi) ---------- */
.card-pustaka, .panel, .box-item, .unggul-item {
    background: #ffffff;
    border-radius: 16px;
    padding: 18px 16px;
    margin-bottom: 18px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #eef2f7;
    width: 100% !important;
    transition: transform 0.2s;
}
.card-pustaka:hover {
    transform: translateY(-2px);
}

/* ---------- TOMBOL FULL WIDTH (Seperti LP2M) ---------- */
@media (max-width: 991px) {
    .btn, button, .button, a.btn, input[type="submit"] {
        display: block !important;
        width: 100% !important;
        padding: 14px 20px !important;
        font-size: 16px !important;
        border-radius: 50px !important;
        text-align: center !important;
        margin: 8px 0 !important;
        min-height: 48px !important;
        box-sizing: border-box !important;
    }
    /* Tombol khusus untuk aksi utama (misal Unggul) */
    .btn-primary, .btn-success, .btn-warning {
        background: #f9c74f !important;
        color: #0a2a5e !important;
        font-weight: 700 !important;
        border: none !important;
    }
}

/* ---------- TABEL & LIST (Agar tidak overflow) ---------- */
.table-responsive, .table-wrapper {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}
table {
    width: 100% !important;
    min-width: 450px; /* Agar bisa di-scroll horizontal jika perlu */
}
img, figure, .img-responsive {
    max-width: 100% !important;
    height: auto !important;
}

/* Sembunyikan default di desktop */
@media (min-width: 992px) {
    .login-register-nav {
        display: none;
    }
}

/* Fix PDF preview grid on mobile */
@media (max-width: 991px) {
    #tab-content-preview > div {
        display: flex !important;
        flex-direction: column !important;
    }
    #tab-content-preview > div > div:first-child {
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        max-height: 250px !important;
    }
    #inline-pdf-pane {
        height: 500px !important;
    }
}

/* Fix Browse/Search page layout on mobile */
@media (max-width: 991px) {
    .browse-grid-container {
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Make the filter sidebar card static and not sticky on mobile */
    .browse-grid-container > .filter-card {
        position: static !important;
        width: 100% !important;
        max-height: none !important;
        margin-bottom: 1.5rem !important;
    }
}
