/* assets/css/style.css */

/* --- Variables and Basic Setup --- */
:root {
    --bg-color: #ffffff;
    --text-color: #222222;
    --card-bg: #f4f4f4;
    --primary-color: #ffc107;
    --primary-text: #000000;
    --border-color: #e0e0e0;
    --skeleton-bg: #e0e0e0;
    --skeleton-shine: rgba(255, 255, 255, 0.6);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

html.dark {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --card-bg: #1e1e1e;
    --border-color: #333333;
    --skeleton-bg: #333;
    --skeleton-shine: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.6;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Header --- */
header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Space between logo and nav */
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem; /* Space between search and icons */
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
    flex-shrink: 0;
}

.search-form {
    width: 250px; /* Set a fixed width for the search bar */
    display: flex;
}

.search-form input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 5px 0 0 5px;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.search-form button {
    padding: 0.5rem 1rem;
    border: none;
    background-color: var(--primary-color);
    color: var(--primary-text);
    border-radius: 0 5px 5px 0;
    cursor: pointer;
    font-weight: bold;
}

.mobile-search-trigger {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0;
}
.mobile-search-trigger svg {
    /* Ensures the icon color matches the text/theme color */
    stroke: var(--text-color);
}

header nav a {
    color: var(--text-color);
    text-decoration: none;
    margin: 0 0.5rem;
    font-weight: 500;
    transition: color 0.2s;
}

header nav a:hover {
    color: var(--primary-color);
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

/* --- Main Content & Grids --- */
main {
    padding: 2rem 0;
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.content-section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 0.5rem;
    display: inline-block;
}

.drama-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

#carousel-section .splide__track {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

#carousel-section .splide__arrow {
    background-color: rgba(0, 0, 0, 0.4);
}
#carousel-section .splide__arrow svg {
    fill: #fff;
}

.carousel-card {
    position: relative;
    display: block;
    width: 100%;
    /* 16:9 is a good ratio for a feature slider */
    aspect-ratio: 16 / 9; 
    text-decoration: none;
    color: #ffffff;
    overflow: hidden;
    background-color: var(--skeleton-bg); /* Background while image loads */
}

.carousel-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* This will cover the entire area */
    transition: transform 0.3s ease;
}

.carousel-card:hover .carousel-poster {
    transform: scale(1.05); /* Add a nice hover zoom effect */
}

.carousel-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3rem 1.5rem 1.5rem; /* More padding at top for gradient */
    /* Dark gradient from bottom to transparent */
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
}

.carousel-overlay h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: #fff;
}

.carousel-overlay p {
    font-size: 0.9rem;
    color: #eee;
}

/* --- Drama Card --- */
.drama-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.drama-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.card-poster {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background-color: var(--skeleton-bg);
}

.card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    flex-grow: 1;
}

.card-meta {
    font-size: 0.8rem;
    color: #888;
}

/* --- Skeleton Loading --- */
.skeleton {
    opacity: 0.7;
    animation: skeleton-shine 1.5s linear infinite;
    background: linear-gradient(90deg, var(--skeleton-bg) 25%, var(--skeleton-shine) 50%, var(--skeleton-bg) 75%);
    background-size: 200% 100%;
}

@keyframes skeleton-shine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination a, .pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    text-decoration: none;
    color: var(--text-color);
}

.pagination a:hover {
    background-color: var(--card-bg);
}

.pagination .current {
    background-color: var(--primary-color);
    color: var(--primary-text);
    border-color: var(--primary-color);
    font-weight: bold;
}

/* --- Detail & Episode Pages --- */
.details-container, .episode-container {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.details-poster img, .episode-player {
    width: 300px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.details-info, .episode-info {
    flex: 1;
}

.details-info h1, .episode-container h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.details-info .synopsis {
    margin: 1.5rem 0;
}

.details-info .labels, .details-info .meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.labels a {
    background-color: var(--card-bg);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.9rem;
}

.play-button {
    display: inline-block;
    margin-top: 1.5rem;
    padding: 0.75rem 2rem;
    background-color: var(--primary-color);
    color: var(--primary-text);
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    font-size: 1.2rem;
}

.episode-player video {
    width: 100%;
    border-radius: 8px;
}

.episode-list {
    margin-top: 2rem;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.episode-list a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

.episode-list a:last-child {
    border-bottom: none;
}

.episode-list a.current {
    background-color: var(--primary-color);
    color: var(--primary-text);
    font-weight: bold;
}

.episode-list a:hover:not(.current) {
    background-color: var(--card-bg);
}

.video-player-wrapper {
    position: relative; /* Needed for absolute positioning of the video */
    width: 100%;
    /* This creates the 16:9 aspect ratio container (height / width * 100%) */
    /* For 9:16 vertical video, it would be (16 / 9 * 100%) = 177.77% */
    /* But since you want it to look like YouTube, we'll keep 16:9 for the container */
    padding-top: 56.25%; /* 16:9 Aspect Ratio (9 / 16 * 100%) */
    background-color: #000;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex; /* Use flexbox to center content */
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
}

.video-player-wrapper video {
    position: absolute; /* Position the video absolutely within the wrapper */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* This is the key: it makes the video fit within the container, adding black bars if aspect ratios don't match */
    display: block;
}

.video-details h1 {
    font-size: 2rem;
    line-height: 1.3;
}

.video-details .meta {
    font-size: 0.9rem;
    color: #888;
    margin-top: 0.5rem;
}

.video-details .synopsis {
    margin-top: 1rem;
}

.episode-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.episode-button {
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 50px;
    height: 40px;
    padding: 0 0.5rem;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    text-decoration: none;
    border-radius: 5px;
    font-weight: 500;
    transition: background-color 0.2s, border-color 0.2s;
}

.episode-button:hover {
    border-color: var(--primary-color);
}

.episode-button.current {
    background-color: var(--primary-color);
    color: var(--primary-text);
    border-color: var(--primary-color);
    font-weight: bold;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 2rem;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
}

.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.language-selector {
    display: flex;
    gap: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.language-selector button {
    background-color: transparent;
    border: none;
    color: var(--text-color);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.language-selector button.active {
    background-color: var(--primary-color);
    color: var(--primary-text);
    font-weight: bold;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.view-more-btn {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 500;
    font-size: 1rem;
}

.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    justify-content: center;
    padding-top: 5rem;
    
    /* Hide by default */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

/* --- The Active/Visible State --- */
.search-modal.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- The Search Bar within the Modal --- */
.search-modal-content {
    width: 90%;
    max-width: 500px;
    position: relative;
}

.search-modal .search-form {
    width: 100%;
    display: flex;
}

.search-modal .search-form input {
    width: 100%;
}

/* --- The Close Button 'X' --- */
.search-modal-close {
    position: absolute;
    top: -35px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
}

@media (max-width: 1024px) {
    .container {
        width: 95%;
    }
    .drama-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }
    .details-info h1, .episode-container h1 {
        font-size: 2.2rem;
    }
}

/* --- For Mobile Phones (768px and below) --- */
@media (max-width: 768px) {
    /* General Mobile Styles */
    body {
        font-size: 15px;
    }
    .section-title {
        font-size: 1.8rem;
    }

    /* Correct Mobile Header Styles */
    .header-left nav,
    .header-right .header-search-container {
        display: none;
    }
    .mobile-search-trigger {
        display: block;
    }

    /* Carousel */
    #carousel-section .splide__arrow {
        display: none;
    }
    .carousel-overlay h3 {
        font-size: 1.2rem;
    }

    /* Details & Episode Pages */
    .details-container, .episode-container {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    .details-poster img, .episode-player {
        width: 100%;
        max-width: 350px;
        margin: 0 auto;
    }
    .details-info {
        text-align: center;
    }
    .details-info .labels {
        justify-content: center;
    }
    .details-info h1, .video-details h1 {
        font-size: 1.9rem;
        line-height: 1.2;
    }

    /* Footer */
    .footer-container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* --- For Desktop Devices (769px and above) --- */
@media (min-width: 769px) {
    /* Hides the mobile-only search icon on desktop */
    .mobile-search-trigger {
        display: none;
    }
}

