/* Global Styles */
@font-face {
    font-family: 'Mj_tunisiaBold';
    src: url('Mj_tunisiaBold.ttf') format('truetype');
}

:root {
    --primary-color: #800000;
    /* Dark Red */
    --secondary-color: #1a1a1a;
    --accent-color: #d4af37;
    /* Gold */
    --text-color: #ffffff;
    --text-muted: #cccccc;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #1c1c1c;
    color: var(--text-color);
    display: flex;
    justify-content: center;

    height: 100vh;
    width: 100%;
    /* Fix horizontal scroll */
    margin: 0;
    overflow-y: auto;
    /* Allow vertical scroll */
    overflow-x: hidden;
}

/* The Container - Now Full Stretch */
.app-container {
    width: 100%;
    min-height: 100vh;
    /* Allow growing */
    height: auto;

    position: relative;

    position: relative;
    background-color: #1c1c1c;
    /* Black bars for contain method */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Mobile Header - Hidden by default */
.mobile-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: rgba(60, 0, 0, 0.9);
    /* Dark Red background matching header in image */
    color: #cca45a;
    /* Goldish text */
    border-bottom: 1px solid #550000;
    position: relative;
    z-index: 100;
    /* Increased to ensure it's always on top */
}

.mobile-brand {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.hamburger-menu {
    font-size: 1.5rem;
    cursor: pointer;
    border: 1px solid #777;
    border-radius: 4px;
    padding: 8px 12px;
    /* Increased padding for larger tap target */
    color: #aaa;
    user-select: none;
    /* Prevent text selection on double-tap */
    -webkit-tap-highlight-color: transparent;
    /* Remove tap highlight on mobile */
}

/* Desktop Header */
.desktop-header {
    width: 100%;
    position: relative;
    z-index: 20;
}

.container {
    width: 95%;
    margin: 0 auto;
}

.top-bar {
    background-color: #979797;
    padding: 4px;
    text-align: right;
    font-size: 1rem;
    color: #000000;
    font-family: 'HacenTunisiaLt', 'Segoe UI', sans-serif;
    font-weight: bold;
}

.top-bar .container {
    display: flex;
    justify-content: flex-start;
    /* In RTL, start is Right */
    direction: rtl;
}

.main-nav {
    background-color: rgba(98, 0, 0, 0.7);


}

.nav-tabs {
    list-style: none;
    display: flex;
    justify-content: center;
    padding: 0;
}

.nav-tabs a {
    display: block;
    padding: 8px 30px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 1.1rem;
    transition: background 0.3s ease;
    font-family: 'Mj_tunisiaBold', sans-serif;
}

.nav-tabs a:hover,
.nav-tabs a.active {
    background-color: rgba(0, 0, 0, 0.3);
    color: var(--accent-color);
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Align to top */
    pointer-events: none;
}

/* THE SCALER: This div now maintains aspect ratio and allows zooming */
.content-scaler {
    position: relative;
    width: 100%;
    max-width: none;
    aspect-ratio: 16 / 9;

    display: flex;
    justify-content: center;

    /* Background image set via inline style in HTML for easy per-page customization */
    background-repeat: no-repeat;
    background-position: center top;
    background-size: 100% 100%;
    margin-top: 24px;
    pointer-events: none;
}

/* No Aspect Ratio Fixing Media Queries Needed for Stretch Mode */

.video-container {
    position: absolute;

    /* 
       STRETCH MODE VALUES
       To distort with the background, we define width/height in % 
       relative to the viewport (which matches the background image).
    */
    width: 55%;
    height: 55%;
    /* Matches 43% width if both are 16:9 */
    top: 31.3%;
    left: 50%;
    /* Center horizontally relative to parent */
    transform: translateX(-50%);

    max-width: none;
    pointer-events: auto;
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    /* Fill the container, ignore aspect ratio */
    padding-bottom: 0;
    /* Remove 16:9 enforcement */

    background-color: #000;
    border: 4px solid #620000;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    margin-bottom: 20px;
}

/* === REMOVED old .video-placeholder and .play-icon styles === */

/* ============================================
   KTV PLAYER — Custom HLS Player Styles
   ============================================ */

/* Player root — fills the video-wrapper */
.ktv-player {
    position: absolute;
    inset: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

/* The actual <video> element */
#ktvVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---- Buffering Spinner ---- */
.ktv-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.ktv-spinner.hidden {
    opacity: 0;
}

.ktv-spinner-ring {
    width: 52px;
    height: 52px;
    border: 4px solid rgba(255, 255, 255, 0.18);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ktvSpin 0.9s linear infinite;
}

@keyframes ktvSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- Controls Bar ---- */
.ktv-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 20;
}

/* Show controls on hover OR when player is paused */
.ktv-player:hover .ktv-controls,
.ktv-player.paused .ktv-controls {
    opacity: 1;
}

.ktv-controls-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ktv-controls-left,
.ktv-controls-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.ktv-controls-right {
    justify-content: flex-end;
}

.ktv-controls-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

/* ---- Control Buttons ---- */
.ktv-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ktv-btn:hover {
    color: #d4af37;
    background: rgba(255, 255, 255, 0.1);
}

/* ---- Volume Wrap ---- */
.ktv-volume-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ---- Volume Slider ---- */
.ktv-volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 64px;
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.35);
    outline: none;
    cursor: pointer;
    transition: width 0.2s ease;
}

.ktv-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.ktv-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
}

/* ---- LIVE Badge ---- */
.ktv-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #cc0000;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 2px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
}

.ktv-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: ktvPulse 1.4s ease-in-out infinite;
}

@keyframes ktvPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* Footer */

/* Footer */
footer {
    background-color: transparent;
    padding: 0;
    position: absolute;
    top: 90%;
    /* Fixed relative to video bottom (74.3%) */
    width: 100%;
    left: 0;
    pointer-events: auto;
    z-index: 10;
}

.social-icons {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
}

.social-btn {
    width: clamp(30px, 4vw, 50px);
    height: clamp(30px, 4vw, 50px);
    background-color: #1c1c1c;
    /* Gray background for PNGs */
    border-radius: 50%;
    /* Keep round click area */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Removed color/font-size */
    transition: all 0.3s ease;
    border: 1px solid #777777;
    /* Remove border */
    overflow: hidden;
    /* Clip if square image */

    /* Padding to prevent icon from touching edges */
}

.social-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.7;

    /* Ensure full icon is visible inside the button area */
}

/* Brand-specific hover colors for social buttons */
.social-btn:hover {
    transform: scale(1.1);
    transition: all 0.3s ease;
}

.social-btn:hover img {
    opacity: 1;
    /* Adjust this value: 0 = fully transparent, 1 = fully opaque */
}

/* YouTube - Red */
#btn-youtube:hover {
    background-color: #FF0000;
}

/* Facebook - Blue */
#btn-facebook:hover {
    background-color: #1877F2;
}

/* Instagram - Gradient */
#btn-instagram:hover {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

/* Aparat - Red */
#btn-aparat:hover {
    background-color: #E62117;
}

/* Rubika - Blue */
#btn-rubika:hover {
    background-color: #1A73E8;
}

/* WhatsApp - Green */
#btn-whatsapp:hover {
    background-color: #25D366;
}

/* Telegram - Blue */
#btn-telegram:hover {
    background-color: #0088cc;
}

/* Eita - Orange/Red */
#btn-eita:hover {
    background-color: #db6301;
}

.social-follow-text {
    text-align: justify;
    text-align-last: justify;
    color: var(--text-color);
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    margin-bottom: 12px;
    font-weight: 700;
    width: 100%;
    font-family: 'Mj_tunisiaBold', sans-serif;
}

.footer-group {
    display: flex;
    flex-direction: column;
    width: fit-content;
    /* Shrink to fit the icons */
    margin: 0 auto;
}

.footer-brand-text {
    text-align: justify;
    text-align-last: justify;
    /* Force justify single line */
    color: var(--text-color);
    font-size: clamp(0.8rem, 1.8vw, 1.1rem);
    margin-bottom: 30px;
    font-weight: 700;
    width: 100%;
    /* Fill the wrapper width */
    transform: none;
    /* Remove previous stretch */
    display: block;
}

.footer-text {
    text-align: center;
    color: #aaa;
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--secondary-color);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
    border: 1px solid #330000;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* =========================================
   MOBILE VIEW (Max Width 768px)
   ========================================= */
@media (max-width: 768px) {
    .app-container {
        /* Remove mobile background to prevent duplication with content-scaler */
        background-image: none;
    }

    /* Show Mobile Header, Hide Desktop Header components selectively */
    .mobile-header {
        display: flex;
    }

    .desktop-header {
        display: block;
        /* Show container but hide components inside */
        position: relative;
        z-index: 21;
        /* Slightly higher than background */
    }

    .top-bar {
        display: none;
        /* Hide date on mobile header area */
    }

    .main-nav {
        /* Changed from display:none to max-height for smooth animation */
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        background-color: rgba(90, 90, 90, 0.90);
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 99;
        /* Just below mobile header */
        transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out;
    }

    .main-nav.show {
        max-height: 500px;
        /* Large enough to fit all menu items */
        opacity: 1;
    }

    .nav-tabs {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-tabs a {
        text-align: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 12px 20px;
    }

    /* Mobile Scaler Logic */
    .content-scaler {
        width: 100%;
        aspect-ratio: 9 / 16;

        /* Mobile background image set via inline style in HTML */
        background-position: center top;
        background-size: 100% 100%;
        transform: none;
        left: 0;
    }

    /* Remove Mobile Media Queries for aspect ratio since we fill 100% */

    .video-container {
        /*
           Mobile Calibrated Values (Round 3)
           Width: 75.6% (Relative to Mobile BG Width)
           Height: ~23.9% (Calculated: 75.6% width * 9/16 video ratio vs 9/16 screen ratio)
           Top: 43.8%
         */
        width: 75.6%;
        height: 23.9%;
        top: 43.8%;
        left: 50%;
        transform: translateX(-50%);
        /* Center it explicitly */
        margin-top: 0;
    }



    /* Footer Adjustments */
    footer {
        top: 70%;
        /* Fixed relative to mobile video bottom (67.7%) */
        bottom: auto;
    }

    .social-icons {
        gap: 8px;
    }

}