@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200..1000&display=swap');

:root {
    --primary: #d4af37;
    /* Gold */
    --primary-hover: #f1c40f;
    --bg-dark: #0a0a0a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: #b3b3b3;
    --accent: #064e3b;
    /* Deep Emerald */
    --font-cairo: "Cairo", sans-serif;

    /* Theme Variables for Unified Nav & Footer */
    --nav-bg: rgba(15, 12, 5, 0.9);
    --nav-primary: var(--primary);
    --footer-bg: linear-gradient(to top, var(--bg-dark), rgba(15, 12, 5, 0.95));
    --footer-primary: var(--primary);
}

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

body {
    font-family: var(--font-cairo);
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 50% 0%, rgba(6, 78, 59, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(212, 175, 55, 0.05) 0%, transparent 50%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px 20px 0;
    /* Removed bottom padding to eliminate gap */
    direction: rtl;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex-grow: 1;
    /* Pushes footer to the bottom if content is short */
    max-width: 1550px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

/* Glassmorphism Utility */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

header {
    margin-bottom: 40px;
    padding: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(to bottom, #fff, #d4af37);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(212, 175, 55, 0.2);
    letter-spacing: -1px;
}



.video-container {
    padding: 24px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.video-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 45px rgba(212, 175, 55, 0.15);
}

.video-title-bar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 15px;
    margin-bottom: 5px;
}

.video-footer {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.video-container h2 {
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-badge {
    background: #ff0000;
    color: white;
    padding: 3px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: pulse 2s infinite;
}

.live-badge::before {
    content: "";
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.video-container p {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1.5;
}

/* Video Player Styling */
.vjs-matrix.video-js {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--border-glass);
}

.vjs-big-play-button {
    background-color: rgba(212, 175, 55, 0.7) !important;
    border: none !important;
    width: 80px !important;
    height: 80px !important;
    line-height: 80px !important;
    border-radius: 50% !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    transition: all 0.3s ease !important;
}

.video-container:hover .vjs-big-play-button {
    background-color: var(--primary) !important;
    transform: translate(-50%, -50%) scale(1.1) !important;
}

/* Visitor Counter Section */
.stats-section {
    grid-column: span 2;
    margin-top: 50px;
    margin-bottom: 25px;
    /* Reduced margin */
    display: flex;
    justify-content: center;
}

.visitor-card {
    padding: 20px 40px;
    /* Reduced padding */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    border: 1px solid var(--primary);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.1);
}

.visitor-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.visitor-icon {
    font-size: 1.5rem;
    /* Reduced size */
}

.visitor-label {
    font-size: 1.1rem;
    /* Reduced size */
    color: var(--text-muted);
    font-weight: 600;
}

.visitor-count {
    font-size: 2.8rem;
    /* Reduced font size from 3.5rem */
    font-weight: 900;
    color: var(--primary);
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 5px;
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 25px;
    border-radius: 10px;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

/* Footer replaced by unified-footer.css */

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        max-width: 780px;
        margin: 0 auto;
    }

    header h1 {
        font-size: 2rem;
    }

    .stats-section {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .video-container {
        padding: 15px;
        border-radius: 15px;
    }

    header {
        padding: 20px 10px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 40px;
        text-align: center;
    }

    .footer-logo {
        justify-content: center;
    }

    .footer-section h4::after {
        right: 50%;
        transform: translateX(50%);
    }

    .footer-links li a {
        justify-content: center;
    }

    .social-links {
        justify-content: center;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 1s ease forwards;
    opacity: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Stream Source Selector Styles --- */
.stream-selectors {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.35);
    padding: 2px;
    border-radius: 30px;
    border: 1px solid var(--border-glass);
    align-items: center;
    white-space: nowrap;
}

.selector-btn {
    background: none;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    /* مطابقة لحجم شارة البث المباشر */
    font-weight: 700;
    padding: 2px 8px;
    /* تباعد داخلي أصغر ليكون متناسقاً وفي سطر واحد */
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    /* منع التفاف النص */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.selector-btn:hover {
    color: var(--text-main);
}

.selector-btn.active {
    background: var(--primary);
    color: var(--bg-dark);
    box-shadow: 0 2px 6px rgba(212, 175, 55, 0.2);
}

/* Player Wrapper & Stream Containers */
.player-wrapper {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--border-glass);
    background: #000;
}

.stream-container {
    display: none;
    width: 100%;
}

.stream-container.active {
    display: block;
}

.youtube-player {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    display: block;
    border: none;
}

@media (max-width: 768px) {
    .stream-selectors {
        width: auto;
    }
}

@media (max-width: 480px) {
    .video-title-bar {
        gap: 8px;
        flex-wrap: wrap;
    }

    .video-container h2 {
        font-size: 1.25rem;
    }

    .live-badge {
        font-size: 0.75rem;
        padding: 2px 8px;
    }
}

/* Theater Button & Cinema Layout */
.theater-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.theater-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(212, 175, 55, 0.05);
    transform: scale(1.05);
}

.theater-btn.active {
    background: var(--primary);
    color: var(--bg-dark);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.video-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-top: 8px;
}

body.theater-active {
    overflow: hidden !important;
    /* Stop page scroll */
}

/* Immersive Cinematic Theater Mode Overlay */
.video-container.theater-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    inset: 0;
    margin: 0;
    border-radius: 0;
    background: rgba(5, 5, 5, 0.98) !important;
    /* Slightly darker for better immersion */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    /* Space around the video content */
    box-shadow: 0 0 100px rgba(0, 0, 0, 1);
    border: none;
    transform: none !important;
    animation: theaterFadeIn 0.4s ease forwards !important;

    /* Dynamic size variables to prevent overflow and preserve 16:9 aspect ratio */
    --theater-reserved-height: 200px;
    --theater-width: min(90vw, calc((100vh - var(--theater-reserved-height)) * 16 / 9));
}

@keyframes theaterFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.video-container.theater-mode:hover {
    transform: none;
    box-shadow: 0 0 100px rgba(0, 0, 0, 1);
}

.video-container.theater-mode p {
    display: none !important;
    /* Hide description in pure mode to save vertical space */
}

.video-container.theater-mode .video-title-bar,
.video-container.theater-mode .video-footer {
    width: var(--theater-width);
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

.video-container.theater-mode .player-wrapper {
    width: var(--theater-width);
    max-width: 1100px;
    margin: 10px auto;
    border: 2px solid rgba(212, 175, 55, 0.4);
    box-shadow: 0 0 50px rgba(212, 175, 55, 0.2);
}

/* Force video elements to display fully without cropping */
.video-container.theater-mode .video-js video,
.video-container.theater-mode .video-js .vjs-tech,
.video-container.theater-mode .youtube-player {
    object-fit: contain !important;
}


/* Dynamic Fallback Alert */
.fallback-alert {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 700;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: none;
    animation: slideDownFade 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    direction: rtl;
}

@keyframes slideDownFade {
    from {
        opacity: 0;
        transform: translate(-50%, -30px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .video-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }

    .theater-btn {
        justify-content: center;
    }

    .video-container.theater-mode {
        padding: 15px;
        --theater-reserved-height: 150px;
        /* Accounts for side-by-side footer on mobile */
        --theater-width: min(95vw, calc((100vh - var(--theater-reserved-height)) * 16 / 9));
    }

    .video-container.theater-mode .video-title-bar,
    .video-container.theater-mode .video-footer,
    .video-container.theater-mode .player-wrapper {
        width: var(--theater-width) !important;
        margin: 8px auto;
    }
}

/* Extra responsive adjustment for very small mobile screens */
@media (max-width: 400px) {
    .selector-btn {
        padding: 2px 6px;
        font-size: 0.75rem;
    }
    .theater-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
        gap: 4px;
    }
}

/* Immersive scaling on short screens (e.g. mobile landscape) */
@media (max-height: 500px) {
    .video-container.theater-mode {
        padding: 10px;
        --theater-reserved-height: 110px;
        /* Very compact reserved space */
        --theater-width: min(95vw, calc((100vh - var(--theater-reserved-height)) * 16 / 9));
    }

    .video-container.theater-mode .video-title-bar {
        display: none !important;
        /* Hide title to maximize video height on short screens */
    }

    .video-container.theater-mode .video-footer {
        width: var(--theater-width) !important;
        flex-direction: row !important;
        /* Force side-by-side buttons on landscape */
        gap: 10px;
        margin-top: 5px;
    }

    .video-container.theater-mode .theater-btn {
        width: auto !important;
    }

    .video-container.theater-mode .player-wrapper {
        width: var(--theater-width) !important;
        margin: 5px auto;
    }
}