/* ==========================================================
   JKT48 IDN LIVE STREAMING - FIT SCREEN HEIGHT & AUTO WIDTH
   ========================================================== */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mengunci tinggi halaman agar pas 1 layar penuh (100vh) */
html,
body {
    width: auto;
    height: 100vh;
    max-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    /* Scroll hanya aktif jika konten sangat panjang */
    background-color: var(--bg);
    color: var(--text);
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    width: auto;
    height: 60px;
    /* Tinggi tetap agar perhitungan vh presisi */
    background-color: var(--surface);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.nav-brand {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-brand span {
    color: var(--accent);
}

.live-dot-pulse {
    width: 10px;
    height: 10px;
    background-color: #ef4444;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 rgba(239, 68, 68, 0.4);
    animation: pulse-red 2s infinite;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-secondary-custom {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-secondary-custom:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.nav-status {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* Container Otomatis Mengisi Sisa Tinggi Layar */
.container {
    width: auto;
    flex: 1;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Penting untuk Flexbox agar tidak melimpah */
}

.section-title-group {
    margin-bottom: 12px;
    flex-shrink: 0;
}

.section-title-group h2 {
    font-size: 20px;
    font-weight: 700;
}

.section-title-group p {
    font-size: 13px;
    color: var(--muted);
}

/* Grid Stream Standard */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    width: auto;
}

.card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    width: auto;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--accent);
}

.card-thumb {
    position: relative;
    width: auto;
    aspect-ratio: 9/16;
    background: var(--surface-2);
    overflow: hidden;
}

.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.live-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 700;
}

.view-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    color: white;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
}

.card-info {
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    object-fit: cover;
    flex-shrink: 0;
}

.details {
    overflow: hidden;
}

.details h3 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.details p {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-actions {
    padding: 0 10px 10px 10px;
    display: flex;
    gap: 6px;
}

.btn-card-action {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    text-align: center;
}

.btn-card-action:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

/* ==========================================================
   MULTI-VIEW ROOM - STRICT 100vh FIT (PAS 1 LAYAR PENUH)
   ========================================================== */

/* Kontainer Utama Multi-View */
.multi-view-wrapper {
    width: 100%;
    /* Mengunci tinggi total agar pas dengan sisa layar setelah navbar */
    height: calc(100vh - 80px);
    max-height: calc(100vh - 80px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Mencegah overflow vertikal ke luar layar */
}

.multi-header {
    margin-bottom: 8px;
    flex-shrink: 0;
    /* Header tidak boleh mengecil */
}

.multi-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.multi-header p {
    font-size: 11px;
    color: var(--muted);
}

/* Grid Player Multi-View */
.multi-grid-container {
    flex: 1;
    /* Mengisi seluruh sisa ruang vertikal yang tersedia */
    display: grid;
    /* Grid otomatis: Membagi slot sama rata secara horizontal & vertikal */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    grid-auto-rows: 1fr;
    /* Memaksa setiap baris memiliki tinggi yang sama */
    gap: 10px;
    width: 100%;
    height: 100%;
    min-height: 0;
    /* PENTING: Mencegah flex child melimpah dari 100vh */
    overflow-y: auto;
    /* Scrollbar internal HANYA jika player sangat banyak */
}

/* Slot Card Video */
.multi-slot {
    background: #000;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.multi-slot-header {
    padding: 6px 10px;
    background: var(--surface-2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    height: 32px;
}

.multi-slot-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
}

.multi-slot-close:hover {
    color: #ef4444;
}

/* Pemutar Video Multi-Slot */
.multi-slot-video-wrap {
    width: 100%;
    flex: 1;
    height: calc(100% - 32px);
    background: #000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

/* Menyesuaikan Plyr.io agar tidak merusak tata letak tinggi 100vh */
.multi-slot-video-wrap .plyr {
    width: 100%;
    height: 100% !important;
    max-height: 100%;
}

.multi-slot-video-wrap .plyr--video {
    height: 100%;
}

.multi-slot-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Video skala pas tanpa terpotong atau melebihi frame */
}

/* ==========================================================
   MODAL PLAYER (FIT VERTICAL SCREEN)
   ========================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: auto;
    max-width: 90vw;
    max-height: 90vh;
    /* Kunci modal tidak boleh melebihi 90% tinggi layar */
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-live-sm {
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.close-btn {
    background: var(--surface-2);
    border: none;
    color: var(--text);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: #ef4444;
    color: #fff;
}

.video-container {
    width: auto;
    aspect-ratio: 16/9;
    max-height: calc(90vh - 100px);
    /* Menyesuaikan video agar pas di modal */
    background: #000;
    flex: 1;
}

.modal-footer-info {
    padding: 8px 16px;
    background: var(--surface-2);
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
}

/* Animations & Empty State */
@keyframes pulse-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.empty-state {
    text-align: center;
    grid-column: 1 / -1;
    padding: 60px 16px;
    color: var(--muted);
}

/* Perangkat HP */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .multi-grid-container {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-height: 100vh;
        max-width: 100vw;
        border-radius: 0;
    }

    .multi-view-wrapper {
        height: calc(100vh - 70px);
        padding: 8px;
    }

    .multi-grid-container {
        grid-template-columns: 1fr;
        /* 1 Kolom di HP */
        grid-auto-rows: minmax(200px, 1fr);
    }
}