/* APP SHELL CSS - OPTIMIZED APP-UI VERSION
   Fokus: Transformasi Web ke Mobile App UI (MD3 Standards)
*/

/* --- 1. GLOBAL FIX: MEMBERSIHKAN JALUR SCROLL --- */
html {
    overflow-x: hidden;
    scroll-behavior: smooth;
    height: auto; /* Jangan dikunci 100% */
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: var(--bg-color);
    /* Hilangkan scrollbar kanan secara total */
    scrollbar-width: none; 
    -ms-overflow-style: none;
}

body::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
}

.md3-navigation-bar, 
.st-mobile-app-header, 
.mobile-only { 
    display: none !important; 
}

@media (max-width: 767px) {
    /* Munculkan kembali hanya di Mobile */
    .mobile-only { 
        display: block !important; 
    }
    
    /* Nav bar harus Flex agar ikon sejajar */
    nav.md3-navigation-bar.mobile-only { 
        display: flex !important; 
    }

    .st-mobile-app-header {
        display: block !important;
    }

    body {
        padding-bottom: 80px !important;
    }
}

/* --- 2. BOTTOM NAVIGATION BAR (MD3 - APP-LIKE UI) --- */
.md3-navigation-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px; /* Standar MD3 sedikit lebih tinggi untuk kenyamanan jempol */
    background-color: var(--header-bg); /* SINKRON: Mengikuti bg skin */
    
    display: flex;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-around;
    align-items: center;
    
    z-index: 1000; /* Pastikan di atas elemen apapun */
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.05);
    border-top: 1px solid var(--border-color); /* SINKRON: Garis tepi halus sesuai skin */
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    gap: 4px;
}

.nav-icon-container {
    position: relative;
    width: 64px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius); /* SINKRON: Akila (16px) vs Luxury (0px) */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted); /* SINKRON: Warna ikon default dari skin */
}

.nav-label {
    font-family: var(--font-body); /* SINKRON: Inter/Lato/Outfit sesuai skin */
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: var(--btn-text-transform); /* SINKRON: Uppercase otomatis di Skin Luxury */
}

/* --- 3. STATE AKTIF (MENGGUNAKAN LOGIKA MD3 & BRANDING) --- */

/* Indikator Pill (Background Ikon) */
.nav-item.active .nav-icon-container {
    background-color: var(--accent-color); /* SINKRON: Pakai warna lembut aksen skin */
}

/* Warna Ikon & Label */
.nav-item.active .material-symbols-outlined {
    color: var(--primary-color) !important; /* SINKRON: Ikon jadi warna utama */
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; /* Efek ikon terisi saat aktif */
}

.nav-item.active .nav-label {
    color: var(--primary-color);
    font-weight: 700;
}

/* --- 4. OVERRIDE KHUSUS SKIN LUXURY (Sesuai Karakter Branding) --- */
.skin-luxury .nav-item.active .nav-icon-container {
    background-color: transparent; /* Luxury tidak cocok pakai pill kapsul */
    border-bottom: 2px solid var(--accent-color); /* Ganti dengan underline emas */
    border-radius: 0;
}

/* 3. MOBILE APP HEADER (Sticky) */
@media (max-width: 767px) {
    .st-site-header { display: none !important; }
    
    .st-mobile-app-header {
        display: block;
        position: sticky;
        top: 0;
        z-index: 1000;
        background: var(--md-sys-color-surface, #ffffff);
        padding: 10px 15px;
        border-bottom: 1px solid var(--border-color, #eeeeee);
    }

    .st-mobile-header-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .st-mobile-logo img { height: 32px; width: auto; }

    .st-header-fake-search {
        flex: 1;
        height: 40px;
        background: var(--bg-light, #f5f5f5);
        border: 1px solid var(--border-color, #e0e0e0);
        border-radius: 20px;
        display: flex;
        align-items: center;
        padding: 0 12px;
        color: var(--text-muted, #757575);
    }

    .st-mobile-menu-open {
        background: none;
        border: none;
        padding: 5px;
        color: var(--text-dark, #333333);
    }
}

/* 4. SIDEBAR & OVERLAY (Core Logic) */
.st-mobile-sidebar {
    position: fixed;
    top: 0;
    right: 0; 
    width: 85%;
    max-width: 320px;
    height: 100dvh;
    background: #ffffff;
    z-index: 1200;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    border-radius: 24px 0 0 24px;

    /* Menjadikan sidebar container flexbox vertikal */
    display: flex;
    flex-direction: column; 
    overflow: hidden;
}

.st-mobile-sidebar.active {
    transform: translateX(0);
    visibility: visible;
}

/* --- BAGIAN MENU (SCROLLABLE) --- */
.st-mobile-menu-container {
    flex: 1;            /* Mengambil sisa ruang */
    overflow-y: auto;   /* Scroll mandiri jika menu banyak */
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* --- BAGIAN FOOTER SIDEBAR (WA BUTTON) --- */
.st-sidebar-footer {
    margin-top: auto;   /* Memaksa elemen ke bawah */
    padding: 20px;
    background: #f9f9f9; 
    border-top: 1px solid rgba(0,0,0,0.05);
    padding-bottom: calc(20px + env(safe-area-inset-bottom)); /* Support Notch */
}

#body-overlay, .st-body-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#body-overlay.active, .st-body-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 5. UTILITY */
body.sidebar-open {
    overflow: hidden;
}

.nav-item:active {
    transform: scale(0.92);
}

@media (min-width: 769px) {
    .st-mobile-app-header { display: none; }
}

/* Styling Fake Search Container & Placeholder */
.st-header-fake-search {
    flex: 1;
    min-width: 0; /* KUNCI: Memungkinkan container menyusut di bawah ukuran kontennya */
    height: 40px;
    background: #f5f5f5;
    border-radius: 20px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    overflow: hidden; /* Memastikan teks yang meluap tidak keluar jalur */
}

.st-placeholder {
    font-size: 14px; /* Ukuran default */
    color: #999;
    white-space: nowrap; /* Mencegah teks turun ke baris baru */
    overflow: hidden; /* Sembunyikan teks yang meluap */
    text-overflow: ellipsis; /* Tambahkan titik-titik (...) jika teks terpotong */
    flex: 1;
    min-width: 0;
}

/* RESPONSIVE: Untuk layar sangat kecil (di bawah 360px) */
@media (max-width: 360px) {
    .st-placeholder {
        font-size: 12px; /* Perkecil sedikit ukuran font */
    }
    
    .st-header-fake-search {
        padding: 0 8px; /* Kurangi padding agar ruang teks lebih luas */
    }
}

/* --- 6. FILTER OVERLAY (BOTTOM SHEET) --- */
.filter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: flex-end; /* Lembaran muncul dari bawah */
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-overlay.active {
    visibility: visible;
    opacity: 1;
}

.filter-sheet {
    width: 100%;
    background: #ffffff;
    border-radius: 28px 28px 0 0; /* MD3 Large Shape */
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.filter-overlay.active .filter-sheet {
    transform: translateY(0);
}

/* Header & Handle */
.sheet-header {
    text-align: center;
    margin-bottom: 20px;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin: 0 auto 15px;
}

.sheet-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sheet-title-row h3 {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    margin: 0;
}

/* Filter Group & Chips */
.filter-group {
    margin-bottom: 24px;
}

.group-label {
    display: block;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 12px;
    color: #333;
}

.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Hidden Radio Logic */
.chip-container input[type="radio"] {
    display: none;
}

.filter-chip {
    padding: 8px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip-container input[type="radio"]:checked + .filter-chip {
    background-color: var(--primary-color, #ff4757);
    color: #ffffff;
    border-color: var(--primary-color, #ff4757);
}

/* Footer Action */
.filter-action-footer {
    margin-top: 20px;
    padding-bottom: env(safe-area-inset-bottom);
}

.st-btn-primary-full {
    width: 100%;
    padding: 14px;
    background: var(--primary-color, #ff4757);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 16px;
}

/* Efek saat chip ditekan (Feedback Visual) */
.filter-chip:active {
    transform: scale(0.95);
    background-color: #f0f0f0;
}

/* Animasi halus saat transisi warna */
.filter-chip {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none; /* Mencegah teks ter-highlight saat diklik cepat */
}

/* --- Search Page --- */
.st-search-page {
    padding-top: 20px;
    min-height: 80vh;
}

.search-results-header {
    padding: 0 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 20px;
}

.st-page-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-dark);
}

.st-results-count {
    font-size: 0.9rem;
    color: #888;
    margin-top: 4px;
}

/* ============================================================
   FIX FILTER SHEET (Tambahkan di Paling Bawah File)
   ============================================================ */

/* 1. Pastikan Container Filter ada di depan blur */
.st-filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001; /* Angka tinggi agar pasti di atas body-overlay */
    display: none; 
    align-items: flex-end; /* Memaksa isi filter ke bawah */
    background: rgba(0, 0, 0, 0.1); /* Overlay sangat tipis agar tidak double hitam */
    pointer-events: none;
}

/* 2. Aktifkan saat ada class .active dari JS */
.st-filter-overlay.active {
    display: flex !important;
}

/* 3. Perbaiki tampilan kotak putih (Sheet) */
.st-filter-sheet-content {
    width: 100%;
    background: #ffffff !important; /* Pastikan background putih */
    border-radius: 24px 24px 0 0;
    padding: 20px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 -10px 25px rgba(0,0,0,0.3);
    
    /* Animasi Meluncur */
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Tambahan agar konten di dalamnya kelihatan */
    position: relative;
    color: #333;
    pointer-events: auto; 
}

/* 4. Munculkan kotak saat container aktif */
.st-filter-overlay.active .st-filter-sheet-content {
    transform: translateY(0);
}

/* 5. Styling Header di dalam Filter (Judul & Tombol Close) */
.st-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.st-sheet-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

#close-filter-btn {
    background: #f0f0f0;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 1. Grouping & Label */
.filter-group {
    margin-bottom: 24px;
    padding: 0 4px;
}

.group-label {
    display: block;
    font-family: var(--font-heading); /* Mengikuti font skin */
    font-size: 14px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 12px;
    text-transform: var(--btn-text-transform); /* Sinkron dengan karakter skin */
}

/* 2. Container Chip */
.st-chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.st-chip-container input[type="radio"] {
    display: none;
}

/* 3. Styling Chip - Mengikuti Karakter Skin */
.filter-chip {
    display: inline-block;
    padding: 10px 18px;
    background: var(--bg-light); /* Mengikuti bg-light masing-masing skin */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius); /* Luxury tajam, Playful bulat, Akila 16px */
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* State: Terpilih (Sinkron dengan Primary Color Skin) */
.st-chip-container input[type="radio"]:checked + .filter-chip {
    background-color: var(--primary-color); 
    color: var(--white);
    border-color: var(--primary-color);
    font-weight: 600;
    box-shadow: var(--card-shadow); /* Efek shadow sesuai karakter skin */
}

/* 4. Dropdown (Select) Styling */
.st-select-filter {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background-color: var(--bg-light);
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-color);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

/* 5. Action Buttons (Sticky Footer) */
.st-filter-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
}

.st-btn-apply {
    flex: 2;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 16px;
    border-radius: var(--border-radius);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    text-transform: var(--btn-text-transform);
    cursor: pointer;
    transition: background 0.3s ease;
}

.st-btn-reset {
    flex: 1;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

/* Hover effect */
.st-btn-apply:hover {
    background-color: var(--primary-hover);
}

/* --- FIX DROPDOWN VISUAL LOGIC --- */

/* Sembunyikan sub-menu secara default agar tidak berantakan */
.st-mobile-menu .sub-menu {
    display: none; 
    list-style: none;
    padding-left: 15px;
    background: rgba(0,0,0,0.03); /* Memberi pembeda warna sedikit */
    margin: 5px 0;
    border-left: 2px solid var(--primary-color, #ff4757); /* Indikator garis di pinggir */
}

/* KUNCI: Menampilkan sub-menu ketika JS memberikan class 'is-open' */
.st-mobile-menu .menu-item-has-children.is-open > .sub-menu {
    display: block !important;
}

/* Animasi indikator panah (jika Anda menggunakan icon di link) */
.menu-item-has-children > a {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-item-has-children.is-open > a i, 
.menu-item-has-children.is-open > a span.material-symbols-outlined {
    transform: rotate(180deg);
    transition: transform 0.3s ease;
}

/* --- CSS DROPDOWN SINKRONISASI --- */
.st-mobile-menu .sub-menu {
    display: none; /* Sembunyi default */
    list-style: none;
    padding-left: 20px;
    background: rgba(0,0,0,0.02);
}

/* Muncul hanya saat class is-open ditambahkan oleh JS */
.st-mobile-menu .menu-item-has-children.is-open > .sub-menu {
    display: block !important;
}

/* Indikator Panah agar User tahu bisa diklik */
.st-mobile-menu .menu-item-has-children > a::after {
    content: '\e5cf'; /* Icon expand_more */
    font-family: 'Material Symbols Outlined';
    font-size: 18px;
    transition: transform 0.3s;
}

.st-mobile-menu .menu-item-has-children.is-open > a::after {
    transform: rotate(180deg);
}

/* Tampilkan sub-menu hanya ketika parent memiliki class .is-open */
.st-mobile-menu .menu-item-has-children .sub-menu {
    display: none; 
}

.st-mobile-menu .menu-item-has-children.is-open > .sub-menu {
    display: block !important;
}


/* --- 6. FIX PWA CAROUSEL (FORCE SNAP & NO SCROLLBAR) --- */
@media (max-width: 767px) {
    .st-nav-carousel-wrapper {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        
        /* Aktifkan Scroll & Snap */
        overflow-x: auto !important; 
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important; 
        
        /* Layout */
        gap: 15px !important;
        padding: 20px 15px !important;
        
        /* Bunuh Scrollbar Horizontal di Carousel */
        scrollbar-width: none !important;
    }

    .st-nav-carousel-wrapper::-webkit-scrollbar {
        display: none !important;
        height: 0 !important;
    }

    .st-nav-item {
        /* Kunci Lebar agar Browser Tahu Titik Berhentinya */
        flex: 0 0 120px !important; 
        width: 120px !important;
        
        /* Titik Berhenti */
        scroll-snap-align: start !important; 
        scroll-snap-stop: always !important;
    }
}

/* Force hide scrollbar di PWA mode */
@media (display-mode: standalone) {
    .st-nav-carousel-wrapper {
        scrollbar-width: none !important;
    }
    
    .st-nav-carousel-wrapper::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }
    
    html {
        scrollbar-width: none;
    }
    
    html::-webkit-scrollbar {
        display: none;
    }
}