/* ===== STYLE EXISTING (TETAP) ===== */
:root {
    --bg-color: #0f0f0f;
    --card-bg: #1e1e1e;
    --primary: #ff3b30;
    --text-main: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow-x: hidden;
}

/* Header & Search */
header {
    padding: 15px;
    position: sticky;
    top: 0;
    background: rgba(15, 15, 15, 0.95);
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #222;
}

header h1 { font-size: 1.3rem; font-weight: 900; letter-spacing: -0.5px; color: white; }

.search-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

#search-input {
    background: #222;
    border: 1px solid #333;
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    outline: none;
    width: 150px;
    font-size: 0.9rem;
    transition: width 0.3s ease;
}
#search-input:focus { border-color: var(--primary); width: 200px; }

/* Grid - DEFAULT UNTUK MOBILE */
.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px;
    min-height: 80vh;
}

.drama-card {
    position: relative;
    aspect-ratio: 2/3;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.drama-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(255, 59, 48, 0.2);
}
.drama-card img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover;
    transition: transform 0.5s ease;
}
.drama-card:hover img {
    transform: scale(1.05);
}
.drama-info {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    padding: 15px 5px 5px 5px;
}
.drama-title { 
    font-size: 0.75rem; 
    font-weight: 600; 
    text-align: center; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    padding: 0 5px;
}

/* Player */
#player-view {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: black; z-index: 200;
    display: none; flex-direction: column;
}
#player-view.active { display: flex; }

.video-container { 
    flex: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: #000; 
    position: relative;
}
video { 
    width: 100%; 
    max-height: 100vh; 
    object-fit: contain;
}

.player-header { 
    position: absolute; 
    top: 10px; 
    left: 10px; 
    z-index: 10; 
}

.back-btn {
    background: rgba(0,0,0,0.6); 
    border: none; 
    color: white;
    width: 40px; 
    height: 40px; 
    border-radius: 50%;
    font-size: 1.2rem; 
    cursor: pointer;
    transition: background 0.3s ease;
}
.back-btn:hover {
    background: rgba(255, 59, 48, 0.8);
}

/* Drawer */
.episode-drawer {
    background: #1a1a1a;
    height: 50%;
    overflow-y: auto;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    padding: 15px;
    display: none;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
}
.episode-drawer.show { display: block; animation: slideUp 0.3s ease-out; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.drawer-header { 
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 15px; 
    font-weight: bold; 
    border-bottom: 1px solid #333; 
    padding-bottom: 10px; 
    font-size: 1rem;
}

.episode-grid { 
    display: grid; 
    grid-template-columns: repeat(5, 1fr); 
    gap: 10px; 
}

.ep-btn {
    background: #2a2a2a; 
    border: none; 
    color: #ccc;
    padding: 12px 0; 
    border-radius: 8px; 
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}
.ep-btn:hover {
    background: #333;
    color: white;
}
.ep-btn.active { 
    background: var(--primary); 
    color: white; 
}

/* Loader */
.loader {
    border: 3px solid #222; 
    border-top: 3px solid var(--primary);
    border-radius: 50%; 
    width: 30px; 
    height: 30px;
    animation: spin 1s linear infinite; 
    margin: 50px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ===== STYLE UNTUK DESKTOP (MIN-WIDTH: 768px) ===== */
@media (min-width: 768px) {
    /* Header yang lebih besar untuk desktop */
    header {
        padding: 20px 40px;
        border-bottom: 1px solid #333;
    }
    
    header h1 { 
        font-size: 1.8rem; 
        letter-spacing: -0.5px; 
    }
    
    #search-input {
        width: 200px;
        padding: 10px 15px;
        font-size: 1rem;
    }
    
    #search-input:focus { 
        width: 250px; 
    }
    
    #page-title {
        font-size: 1.5rem;
        padding: 0 40px;
        margin: 20px 0 15px 0;
        display: block !important;
    }
    
    /* Grid yang lebih rapi untuk desktop */
    .grid-container {
        grid-template-columns: repeat(5, 1fr); /* 5 kolom untuk desktop */
        gap: 20px;
        padding: 20px 40px;
        max-width: 1600px; /* Batas maksimum lebar grid */
        margin: 0 auto; /* Pusatkan grid */
    }
    
    .drama-card {
        border-radius: 10px;
        overflow: hidden;
        max-width: 240px; /* Batas maksimum lebar card */
        margin: 0 auto; /* Pusatkan card dalam grid cell */
    }
    
    .drama-title {
        font-size: 0.9rem;
        padding: 0 8px;
    }
    
    /* Player untuk desktop */
    .video-container {
        padding: 20px;
    }
    
    video {
        max-width: 90%;
        max-height: 80vh;
        border-radius: 10px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    }
    
    .player-header {
        top: 20px;
        left: 20px;
    }
    
    .back-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    /* Episode drawer untuk desktop */
    .episode-drawer {
        height: 60%;
        max-width: 1200px;
        margin: 0 auto;
        border-radius: 16px 16px 0 0;
        padding: 20px 30px;
    }
    
    .drawer-header {
        font-size: 1.2rem;
    }
    
    .episode-grid {
        grid-template-columns: repeat(10, 1fr); /* Lebih banyak kolom untuk desktop */
        gap: 12px;
    }
    
    .ep-btn {
        padding: 15px 0;
        font-size: 1rem;
    }
    
    /* Footer untuk desktop */
    footer {
        padding: 30px 20px;
        font-size: 0.9rem;
        margin-top: 40px;
        border-top: 1px solid #222;
    }
}

/* ===== STYLE UNTUK DESKTOP BESAR (MIN-WIDTH: 1200px) ===== */
@media (min-width: 1200px) {
    .grid-container {
        grid-template-columns: repeat(6, 1fr); /* 6 kolom untuk desktop besar */
        gap: 25px;
        padding: 30px 60px;
    }
    
    .drama-card {
        max-width: 220px;
    }
    
    .episode-grid {
        grid-template-columns: repeat(12, 1fr); /* 12 kolom untuk desktop besar */
    }
    
    video {
        max-width: 85%;
    }
}

/* ===== STYLE UNTUK TABLET (MIN-WIDTH: 480px DAN MAX-WIDTH: 767px) ===== */
@media (min-width: 480px) and (max-width: 767px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr); /* 4 kolom untuk tablet */
        gap: 12px;
        padding: 15px;
    }
    
    .episode-grid {
        grid-template-columns: repeat(6, 1fr); /* 6 kolom untuk tablet */
    }
}