:root {
    --primary: #00ffcc;
    --danger: #ff4444;
    --bg-dark: #1a1a1a;
    --interface-height: 600px;
    --bg-white: #ffffff;
}

body {
    margin: 0;
    padding: 20px;
    background: var(--bg-white);
    color: #fff;
    font-family: Segoe UI, sans-serif;
    display: flex;
    justify-content: center;
}

.container {
    max-width: 900px;
    width: 100%;
}

/* VIDEO */
.video-wrapper {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 5px;
    /*box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);*/
    -webkit-tap-highlight-color: transparent;
}

video {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

video::-webkit-media-controls {
    display: none !important;
}

/* CONTROLS AREA */
.custom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.6) 60%, transparent 100%);
    padding: 20px 15px 10px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 8;
}

.video-wrapper.user-active .custom-controls,
.video-wrapper.is-paused .custom-controls {
    opacity: 1;
    pointer-events: auto;
}

/* BARRA DE TEMPS */
.seek-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: monospace;
    font-size: 13px;
}

input[type=range].seek-bar {
    -webkit-appearance: none;
    flex-grow: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    cursor: pointer;
    transition: height 0.1s;
}

input[type=range].seek-bar:hover {
    height: 8px;
}

input[type=range].seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    /*box-shadow: 0 0 10px rgba(0, 255, 204, 0.5);*/
    cursor: pointer;
    margin-top: -5px;
}

#currentTimeDisplay {
    min-width: 65px;
    text-align: center;
    font-weight: bold;
    text-shadow: 0 1px 2px black;
}

/* BOTONS I GRUPS */
.buttons-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.left-group,
.right-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

button.ctrl-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 5px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: .2s;
}

button.ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--primary);
}

/* ESTIL SVG */
svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.fill-icon {
    fill: currentColor;
    stroke: none;
}

/* CAST WRAPPER */
.cast-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    display: none;
}

.cast-wrapper .ctrl-btn {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

google-cast-launcher {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    z-index: 2;
    cursor: pointer;
}

/* ALTRES */
.speed-select {
    background: rgba(255, 255, 255, 0.1);
    color: #ddd;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 12px;
    padding: 4px 2px;
    cursor: pointer;
    font-weight: bold;
}

.speed-select:focus {
    outline: none;
    border-color: var(--primary);
}

option {
    background: #333;
    color: white;
}

.vol-container {
    display: flex;
    align-items: center;
    width: 0;
    overflow: hidden;
    transition: width 0.3s;
    margin-left: 5px;
}

.volume-group:hover .vol-container {
    width: 70px;
}

input[type=range].vol-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

input[type=range].vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
}

.live-badge {
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: default;
}

.live-badge.delayed {
    background: #555;
    opacity: 0.8;
}

#liveReturnBtn {
    font-size: 11px;
    font-weight: bold;
    color: var(--danger);
    border: 1px solid var(--danger);
    background: transparent;
    padding: 4px 8px;
    border-radius: 4px;
    display: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

#liveReturnBtn:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.05);
    /*box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);*/
}

#liveReturnBtn:active {
    transform: scale(0.98);
}

#airplayBtn,
#pipBtn {
    display: none;
}

/* EPG HORITZONTAL */
.info {
    text-align: center;
    padding: 0 10px;
    opacity: 0.6;
    font-size: 14px;
}

.epg-container {
    position: relative;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    background: #1b1b1b;
    padding: 14px 0;
    margin-bottom: 5px;
    border-radius: 12px;
}

.epg-track {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    padding-left: 50vw;
    padding-right: 50vw;
}

.program {
    box-sizing: border-box;
    padding: 10px;
    margin-right: 4px;
    background: #2a2a2a;
    border-radius: 4px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
    min-width: 120px;
    white-space: normal;
    flex-shrink: 0;
}

.program:hover {
    transform: scale(1.02);
    background: #333;
}

.program-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.program-time {
    font-size: 12px;
    opacity: 0.7;
    white-space: nowrap;
}

.program.current {
    background: #1f6f3a;
    /*box-shadow: 0 0 5px rgba(0, 255, 120, 0.6);*/
}

.program.focused {
    outline: 3px solid #00aaff;
    background: #2a4a6a;
}

.program.current.focused {
    background: #1f6f3a;
}

.now-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: red;
    z-index: 10;
    /*box-shadow: 0 0 5px rgba(255, 0, 0, 0.8);*/
}

.epg-container::-webkit-scrollbar {
    display: none;
}

.epg-container {
    scrollbar-width: none;
}

.program-details {
    width: calc(100% - 40px);
    margin: 10px 0;
    background: #1a1a1a;
    border-top: 2px solid #00aaff;
    padding: 20px;
    border-radius: 8px;
    min-height: 120px;
    /*box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.5);*/
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.details-title {
    font-size: 22px;
    font-weight: bold;
    color: #00aaff;
}

.details-time {
    font-size: 16px;
    opacity: 0.8;
    color: #aaa;
}

.details-genre {
    display: inline-block;
    background: #2a4a6a;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    margin-top: 8px;
    color: #fff;
}

.details-description {
    font-size: 15px;
    line-height: 1.6;
    color: #ddd;
    margin-top: 10px;
}

.play-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1f6f3a;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s, transform 0.2s;
    gap: 10px;
}

.play-button:hover {
    background: #28a745;
    transform: scale(1.05);
}

.play-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.details-placeholder {
    text-align: center;
    opacity: 0.5;
    font-style: italic;
    padding: 40px;
}

/* LOADER I POSTER */
.poster-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 4;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    align-items: flex-end;      /* ← alinea al fons */
    justify-content: flex-start;
    gap: 12px;
    padding: 0 16px 40px 16px; /* ← 40px del marge inferior */
    box-sizing: border-box;
    z-index: 6;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
    position: relative;
    z-index: 7;
}

.loading-text {
    color: white;
    background-color: #333;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 16px;
    font-weight: 500;
    position: relative;
    z-index: 7;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}