/* =========================================================
   DESIGN QUEDUSTREAM - COMPLET, MIS À JOUR & MOBILE RESPONSIVE
   ========================================================= */

/* 1. Global Box-Sizing & Overflow Prevention */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px; 
}

body {
    margin: 0;
    padding: 0;
    background: #090909;
    color: #cccccc;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px; /* Fixed from 1px to a readable size */
    width: 100%;
    overflow-x: hidden;
}

/* 2. Fluid Media Elements */
img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* --- CONTENEURS --- */

.header-inner,
.main-nav,
.search-bar,
.page-container,
.site-footer,
.container, 
.main-wrapper, 
.wrapper, 
.content-area {
    width: 1200px;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

a {
    color: #cccccc;
    text-decoration: none;
}

a:hover {
    color: #ffffff;
}

/* --- HEADER --- */

.site-header {
    background: #000000;
    border-bottom: 1px solid #1f1f1f;
}

.header-inner {
    min-height: 85px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    background: #000000;
}

.logo {
    font-size: 32px;
    font-weight: bold;
    letter-spacing: -1px;
    text-align: center;
}

.logo-cine,
.logo-stream {
    color: #00ff00;
    font-family: Impact, Arial, sans-serif;
    letter-spacing: 1px;
}

.logo small {
    display: block;
    margin-top: 2px;
    color: #f1b03e;
    font-size: 11px;
    letter-spacing: 0.5px;
    font-weight: normal;
}

/* --- NAVIGATION --- */

.main-nav {
    min-height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000000;
    border-bottom: 1px solid #1f1f1f;
    flex-wrap: wrap; /* Allows items to wrap nicely on mobile */
}

.main-nav a {
    padding: 8px 12px;
    font-weight: bold;
    font-size: 12px;
    color: #cccccc;
    border-right: 1px solid #151515;
}

.main-nav a:hover,
.main-nav a.active {
    color: #ffffff;
    background: #1c1c1c;
}

/* --- SEARCH --- */

.search-bar {
    margin: 0 auto 10px;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    background: #000000;
    border-bottom: 1px solid #1f1f1f;
}

.search-item form {
    display: flex;
}

.search-item input {
    width: 100%;
    height: 32px; /* Increased touch target size for mobile */
    background: #0b0b0b;
    border: 1px solid #333333;
    color: #cccccc;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px 0 0 4px;
}

.search-item input::placeholder {
    color: #777777;
}

.search-item input:focus {
    outline: none;
    border-color: #88a6d1;
}

.search-item button {
    height: 32px; /* Matched with input height */
    background: #181818;
    color: #cccccc;
    border: 1px solid #333333;
    border-left: none;
    cursor: pointer;
    font-size: 12px;
    padding: 0 12px;
    border-radius: 0 4px 4px 0;
}

.search-item button:hover {
    background: #282828;
    color: #ffffff;
}

/* --- MAIN LAYOUT --- */

.page-container {
    margin: auto;
    padding: 0 10px;
}

.main-layout {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 8px;
}

/* --- SIDEBAR --- */

.sidebar {
    padding: 0;
}

.side-box {
    background: #121212;
    border: 1px solid #222222;
    border-radius: 2px;
    margin-bottom: 8px;
    overflow: hidden;
}

.side-box h3 {
    margin: 0;
    padding: 6px 8px;
    background: #080808;
    border-bottom: 1px solid #222222;
    color: #dddddd;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.side-box a,
.side-box strong {
    display: block;
    padding: 6px 8px; /* Increased padding for better mobile tapping */
    font-size: 11px;
}

.side-box a {
    color: #cccccc;
}

.side-box a:hover {
    background: #252525;
    color: #ffffff;
}

.side-box strong {
    margin-top: 4px;
    color: #ffffff;
    font-weight: bold;
}

.side-box span {
    color: #777777;
}

/* --- CONTENT --- */

.content {
    background: #121212;
    min-height: 500px;
    padding: 8px;
    border: 1px solid #222222;
    border-radius: 2px;
}

.qds-alert-box {
    border: 1px solid #a00;
    background: #0a0000;
    padding: 8px;
    text-align: center;
    margin-bottom: 10px;
    font-size: 11px;
    color: #ffcccc;
}

.qds-alert-box a {
    color: #66b3ff;
    text-decoration: underline;
}

/* --- LATEST BOXES --- */

.latest-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    position: relative;
}

.latest-box {
    background: #0d0d0d;
    border: 1px solid #222222;
    border-radius: 2px;
    position: relative;
    overflow: visible !important;
}

.latest-box h2 {
    margin: 0;
    padding: 6px 8px;
    font-size: 11px;
    color: #ffffff;
    background: #050505;
    border-bottom: 1px solid #222222;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.latest-box h2 span, 
.latest-box h2 a {
    font-size: 10px;
    color: #8ab4f8;
    font-weight: normal;
}

.latest-box ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.latest-box li {
    padding: 6px 8px; /* Tweak for mobile tap targets */
    border-bottom: 1px solid #171717;
    font-size: 11px;
    color: #cccccc;
}

.latest-box li:nth-child(even) {
    background: #141414;
}

.latest-box li:nth-child(odd) {
    background: #0d0d0d;
}

.latest-box li:hover {
    background: #252525;
    color: #ffffff;
}

.latest-box li a:hover {
    color: #f1b03e;
}

/* --- POPOVERS (IMPROVED RESPONSIVE POSITIONING) --- */

.movie-tooltip-container {
    position: relative;
    display: inline-block;
}

.movie-popover {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    width: 320px;
    max-width: 90vw;
    background: #161616;
    border: 1px solid #444444;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.95);
    padding: 10px;
    z-index: 999999;
    border-radius: 4px;
    gap: 10px;
    align-items: flex-start;
    box-sizing: border-box;
    margin-top: 5px;
}

@media screen and (min-width: 769px) {
    .movie-popover {
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 10px;
        margin-top: 0;
        width: 380px;
    }
}

.movie-tooltip-container:hover .movie-popover,
.movie-tooltip-container:focus-within .movie-popover {
    display: flex;
}

.movie-popover img {
    width: 90px;
    height: auto;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid #333333;
}

.movie-popover-info {
    color: #ffffff;
    font-size: 12px;
    line-height: 1.4;
    text-align: left;
    flex-grow: 1;
}

.movie-popover-info h4 {
    margin: 0 0 6px 0;
    color: #f1b03e;
    font-size: 14px;
}

.movie-popover-info p {
    margin: 0;
    font-size: 11px;
    color: #cccccc;
}

/* --- MOVIE GRIDS & CARDS --- */

.movies-grid, .film-list-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 10px 0;
}

.movie-card, .film-item {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.movie-card:active, .movie-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    border-color: #f39c12;
}

.movie-card img {
    border-radius: 4px;
    width: 100%;
    height: 140px;
    object-fit: cover;
}

/* --- MOVIE DETAILS PAGE LAYOUT --- */

.movie-details-container, .film-detail-wrapper {
    display: flex;
    flex-direction: column;
    padding: 10px;
    background: #141414;
    border-radius: 8px;
}

.movie-details-container img, .film-poster {
    width: 100%;
    max-width: 160px;
    height: auto;
    border-radius: 6px;
    object-fit: cover;
    margin: 0 auto 10px auto;
    display: block;
}

.actors-list, .directors-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.actor-pill, .director-pill, span[class*="pill"] {
    display: inline-flex;
    align-items: center;
    background: #222;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 13px;
}

/* --- SAFE TABLE OVERRIDES --- */

.content table, .films-table, table.film-list {
    display: table !important;
    width: 100% !important;
}

.content tr, .films-table tr, table.film-list tr {
    display: table-row !important;
}

.content td, .films-table td, table.film-list td {
    display: table-cell !important;
    padding: 6px 8px !important;
    text-align: left !important;
}

.films-table td::before, table.film-list td::before {
    content: none !important;
}

/* --- FOOTER --- */

.site-footer {
    margin: 15px auto 0;
    padding: 15px;
    text-align: center;
    color: #666666;
    border-top: 1px solid #222222;
    font-size: 11px;
}

/* =========================================================
   RESPONSIVE MEDIA QUERIES (MOBILE OPTIMIZATION)
   ========================================================= */

@media screen and (max-width: 1024px) {
    .sidebar {
        width: 100%; /* Switch sidebar layout smoothly on intermediate widths */
    }
    
    .movies-grid, .series-grid, .grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media screen and (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        width: 100% !important;
        height: auto;
        position: relative;
        margin-bottom: 20px;
        display: block;
    }

    .latest-grid {
        grid-template-columns: 1fr;
    }

    .main-wrapper, .container, .flex-layout {
        flex-direction: column !important;
        width: 100% !important;
        padding: 5px !important;
    }

    .search-bar {
        grid-template-columns: 1fr;
    }

    .movies-grid, .series-grid, .grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
}

@media screen and (min-width: 481px) {
    .movie-details-container {
        flex-direction: row;
        gap: 15px;
    }
}

@media screen and (max-width: 480px) {
    .movies-grid, .series-grid, .grid, .film-list-container {
        grid-template-columns: 1fr !important;
    }

    h1 {
        font-size: 22px !important;
    }

    h2 {
        font-size: 18px !important;
    }

    .video-container, .secure-player {
        position: relative;
        padding-bottom: 56.25%;
        height: 0;
        overflow: hidden;
    }

    .video-container iframe, .secure-player iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

@media screen and (max-width: 380px) {
    .movies-grid, .film-list-container {
        grid-template-columns: 1fr;
    }
}