/* Blochează selectarea textului și imaginilor pe tot site-ul */
body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

img {
    -webkit-user-drag: none;
    pointer-events: none;
}

/* 2. Mapăm fonturile cu format clar pentru browserele mobile */
@font-face {
    font-family: 'Isidora Sans';
    src: url('https://db.onlinewebfonts.com/t/696d7821e7eeb0a0f422b1a3e9084946.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Isidora Sans';
    src: url('https://db.onlinewebfonts.com/t/5a2997d9cd39bd9d0bc3295b1a73d927.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Isidora Sans';
    src: url('https://db.onlinewebfonts.com/t/d28024dd0f8248d26a677397a526960d.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --glass-bg: rgba(8, 20, 48, 0.65);
    --glass-bg-hover: rgba(14, 35, 80, 0.8);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-light: rgba(255, 255, 255, 0.25);
    --liquid-glow: rgba(30, 64, 175, 0.4);
    --accent-color: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #1e40af 0%, #030712 100%);
    --text-primary: #ffffff;
    --text-secondary: rgba(220, 232, 255, 0.75);
    --spring-transition: cubic-bezier(0.34, 1.56, 0.64, 1);
    --smooth-transition: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Isidora Sans', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    background-color: #020617;
    min-height: 100vh;
    position: relative;
}

/* OPTIMIZAT: Am eliminat blur-ul si animatia continua de pe fundalul mare */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(30, 58, 138, 0.35) 0%, transparent 50%),
        radial-gradient(circle at 85% 85%, rgba(15, 23, 42, 0.5) 0%, transparent 50%),
        linear-gradient(180deg, rgba(2, 6, 23, 0.4) 0%, rgba(1, 3, 12, 0.7) 100%),
        url('XMEDIA-bg.png');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    z-index: -2;
    pointer-events: none;
    transform: translateZ(0);
}

/* ===== ADVANCED 4s BOOT SCREEN OVERLAY ===== */
#boot-screen {
    position: fixed;
    inset: 0;
    background-color: #000000;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1), transform 1.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 1.2s;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

#boot-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(3, 10, 28, 0.2) 0%, rgba(0, 0, 0, 0.6) 100%),
        url('XMEDIA-bg.png');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    opacity: 0;
    animation: bgReveal4s 3.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    z-index: 0;
    transform: translateZ(0);
}

@keyframes bgReveal4s {
    0% { opacity: 0; transform: scale(1.08) translateZ(0); }
    30% { opacity: 0.35; }
    50% { opacity: 0.85; transform: scale(1.02) translateZ(0); }
    100% { opacity: 0.95; transform: scale(1) translateZ(0); }
}

#boot-screen.fade-out {
    opacity: 0;
    transform: scale(1.02) translateZ(0);
    visibility: hidden;
    pointer-events: none;
}

#boot-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.boot-rect {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 130px;
    background: rgba(255, 255, 255, 0.14);
    border-left: 1px solid rgba(255, 255, 255, 0.25);
    border-right: 1px solid rgba(255, 255, 255, 0.25);
    z-index: 2;
    pointer-events: none;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.boot-rect-left {
    left: 0;
    transform: translate3d(-100vw, 0, 0);
    animation: rectSweepLeft 2.8s cubic-bezier(0.25, 1, 0.5, 1) forwards 0.2s;
}

.boot-rect-right {
    right: 0;
    transform: translate3d(100vw, 0, 0);
    animation: rectSweepRight 2.8s cubic-bezier(0.25, 1, 0.5, 1) forwards 0.2s;
}

@keyframes rectSweepLeft {
    0% { transform: translate3d(-100vw, 0, 0); opacity: 0; }
    25% { opacity: 0.9; }
    60% { transform: translate3d(100vw, 0, 0); opacity: 0.75; }
    85% { opacity: 0.2; }
    100% { transform: translate3d(120vw, 0, 0); opacity: 0; }
}

@keyframes rectSweepRight {
    0% { transform: translate3d(100vw, 0, 0); opacity: 0; }
    25% { opacity: 0.9; }
    60% { transform: translate3d(-100vw, 0, 0); opacity: 0.75; }
    85% { opacity: 0.2; }
    100% { transform: translate3d(-120vw, 0, 0); opacity: 0; }
}

.boot-content {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.boot-logo-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.boot-logo-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.22) 0%, rgba(30, 64, 175, 0.18) 45%, transparent 75%);
    border-radius: 50%;
    opacity: 0;
    animation: glowPulse4s 3.8s ease-in-out forwards;
    transform: translateZ(0);
}

@keyframes glowPulse4s {
    0% { opacity: 0; transform: scale(0.5) translateZ(0); }
    30% { opacity: 0.2; transform: scale(0.8) translateZ(0); }
    45% { opacity: 0.95; transform: scale(1.1) translateZ(0); }
    70% { opacity: 0.6; transform: scale(1.05) translateZ(0); }
    100% { opacity: 0.8; transform: scale(1.1) translateZ(0); }
}

.boot-logo {
    width: 240px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.5));
    opacity: 0;
    transform: scale(1.08) translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    animation: bootLogoZoomOut 2.4s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.8s;
}

@keyframes bootLogoZoomOut {
    0% { opacity: 0; transform: scale(1.08) translateZ(0); }
    30% { opacity: 0.7; }
    100% {
        opacity: 1;
        filter: drop-shadow(0 0 25px rgba(255, 255, 255, 0.8));
        transform: scale(1) translateZ(0);
    }
}

#mouse-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 250px;
    margin-left: -125px;
    margin-top: -125px;
    background: radial-gradient(
        circle, 
        rgba(30, 64, 175, 0.25) 0%, 
        rgba(15, 23, 42, 0.1) 45%, 
        transparent 70%
    );
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
    transform: translateZ(0);
}

.glass, header, #categories, .channels, #playerSection, .site-footer {
    position: relative;
    z-index: 1;
}

/* ===== HEADER ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 2rem;
    margin: 1.5rem auto 1.2rem auto;
    width: calc(100% - 4rem);
    max-width: 1400px;
    background: rgba(8, 20, 48, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    box-shadow: 
        inset 0 1px 1px rgba(255, 255, 255, 0.2),
        0 20px 40px rgba(1, 4, 14, 0.8);
    animation: slideDown 0.8s var(--smooth-transition);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}

#main-logo {
    width: 115px;
    height: 40px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(255, 255, 255, 0.15));
    transition: transform 0.3s var(--spring-transition);
    cursor: pointer;
}

#main-logo:hover {
    transform: scale(1.05);
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    pointer-events: none;
    transition: color 0.3s;
}

header input {
    font-family: inherit;
    font-weight: 500;
    background: rgba(3, 10, 28, 0.7);
    border: 1px solid var(--glass-border);
    padding: 0.7rem 1.2rem 0.7rem 2.6rem;
    border-radius: 100px;
    color: #ffffff;
    font-size: 0.9rem;
    width: 240px;
    transition: all 0.3s var(--smooth-transition);
}

header input::placeholder {
    color: var(--text-secondary);
    font-weight: 500;
}

header input:focus {
    background: rgba(10, 25, 60, 0.9);
    border-color: #ffffff;
    outline: none;
    width: 320px;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

header input:focus + i {
    color: #ffffff;
}

/* ===== CATEGORIES ===== */
#categories {
    display: flex;
    gap: 0.4rem;
    padding: 0.4rem;
    margin: 0 auto 1.5rem auto;
    width: fit-content;
    max-width: calc(100% - 2rem);
    background: rgba(6, 16, 38, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.15);
    animation: fadeIn 0.8s var(--smooth-transition);
}

.category {
    padding: 0.6rem 1.5rem;
    background: transparent;
    border-radius: 100px;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    white-space: nowrap;
    position: relative;
    user-select: none;
}

.category i, .category .material-symbols-rounded {
    font-size: 1.1rem;
    transition: transform 0.2s var(--spring-transition);
}

.category:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.category:hover i {
    transform: scale(1.15);
}

.category.active {
    background: var(--accent-gradient);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 
        0 4px 15px rgba(30, 64, 175, 0.5),
        inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

/* ===== CHANNEL GRID ===== */
.channels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.2rem;
    padding: 0.5rem 2rem 2rem 2rem;
    margin: 0 auto;
    max-width: 1400px;
    max-height: 60vh;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.channels::-webkit-scrollbar {
    width: 6px;
}
.channels::-webkit-scrollbar-track {
    background: transparent;
}
.channels::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}
.channels::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* OPTIMIZAT: contain layout style paint oprește randarea inutilă */
.channel-card {
    position: relative;
    background: rgba(8, 20, 48, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 22px;
    padding: 1.2rem 1rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
    transition: transform 0.25s var(--smooth-transition), border-color 0.2s, background 0.2s, box-shadow 0.2s;
    box-shadow: 0 8px 15px rgba(1, 4, 12, 0.5);
    opacity: 0;
    animation: cardAppear 0.4s forwards var(--smooth-transition);
    contain: layout style paint;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.channel-card:hover {
    transform: translateY(-4px);
    background: rgba(15, 35, 80, 0.75);
    border-color: var(--glass-border-light);
    box-shadow: 
        0 15px 30px rgba(1, 4, 15, 0.7),
        0 0 10px rgba(255, 255, 255, 0.08);
}

.channel-card:active {
    transform: scale(0.98);
}

.logo {
    width: 100%;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo img {
    max-width: 80%;
    max-height: 65px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
    transition: transform 0.3s var(--spring-transition);
}

.channel-card:hover .logo img {
    transform: scale(1.06);
}

.meta {
    width: 100%;
}

.meta .name {
    font-weight: 500;
    font-size: 0.95rem;
    margin: 10px 0 4px 0;
    color: #ffffff;
    letter-spacing: -0.2px;
}

.meta .details {
    font-weight: 500;
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* ===== EPG CONTAINER ===== */
.epg-container {
    width: 100%;
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(3, 10, 28, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    text-align: left;
    transition: background 0.2s;
}

.channel-card:hover .epg-container {
    background: rgba(6, 18, 48, 0.85);
    border-color: rgba(255, 255, 255, 0.25);
}

.epg-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.epg-marcaj {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 500;
    color: #ffffff;
    animation: livePulse 2s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.epg-time-info {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
}

.epg-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    margin-top: 6px;
    overflow: hidden;
}

.epg-progress-fill {
    height: 100%;
    background: #ffffff;
    border-radius: 10px;
    transition: width 0.5s ease-out;
}

/* ===== PLAYER SECTION ===== */
#playerSection {
    width: 90%;
    max-width: 1100px;
    margin: 2rem auto 3rem auto;
    padding: 2rem;
    background: rgba(6, 16, 42, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border-light);
    border-radius: 32px;
    box-shadow: 
        inset 0 1px 2px rgba(255, 255, 255, 0.2),
        0 35px 70px rgba(1, 4, 15, 0.9);
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.4s var(--smooth-transition), transform 0.4s var(--smooth-transition);
    display: none;
}

#playerSection .player-theme,
#playerSection .player-description,
#playerSection .player-quality {
    font-weight: 500;
    text-align: left;
    margin-top: 0.4rem;
    text-shadow: 0 0 4px rgba(0, 1, 43, 0.9);
    opacity: .95;
}

#playerSection.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.player-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
    text-align: left;
}

.player-logo img {
    max-width: 70px;
    max-height: 70px;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.video-wrapper, .audio-wrapper {
    width: 100%;
    margin-top: 1.2rem;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    background: #000000;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.video-wrapper:hover, .audio-wrapper:hover {
    border-color: var(--glass-border-light);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.8);
}

video-player, audio-player {
    display: block;
    width: 100%;
    height: 100%;
}

#playerVideo {
    width: 100%;
    background: #000;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    height: auto;
    display: block;
    overflow: hidden;
    outline: none;
}

#playerAudio {
    width: 100%;
    display: block;
}

#playerSection .player-name {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.8px;
    color: #ffffff;
}

.quality-selector {
    margin-top: 1.2rem;
}

#qualityDropdown {
    padding: 0.6rem 1.6rem;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: #ffffff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

#qualityDropdown:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #ffffff;
}

#qualityDropdown option {
    background: #030a1c;
    color: #ffffff;
}

.player-epg-info {
    margin: 1rem 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 
        inset 0 1px 1px rgba(255, 255, 255, 0.15),
        0 6px 16px rgba(0, 0, 0, 0.25);
    text-align: left;
    padding: 1rem;
    font-weight: 500;
}

/* ===== FOOTER ===== */
.site-footer {
    margin: 3rem auto 2rem auto;
    width: fit-content;
    padding: 0.8rem 2.5rem;
    background: rgba(6, 16, 38, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    text-align: center;
    transition: transform 0.2s, border-color 0.2s;
}

.site-footer:hover {
    border-color: var(--glass-border-light);
    transform: translateY(-2px);
}

.footer-content {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.footer-content strong {
    color: #ffffff;
    font-weight: 700;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* RESPONSIVE DESIGN */
@media(max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        width: calc(100% - 2rem);
        padding: 1rem;
    }
    .search-wrapper, header input {
        width: 100%;
    }
    header input:focus {
        width: 100%;
    }
    .channels {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        padding: 0.5rem 1rem;
    }
    #categories {
        width: calc(100% - 2rem);
        overflow-x: auto;
        justify-content: flex-start;
    }
    .boot-rect {
        width: 80px;
    }
}