/**
 * VojvodinaMeteo Universal Media Player
 * PORT OF vm-player.css v1.1.0 (VP tema) — sync sed: s/vm-player/vm-player/g; s/vmPlayerSpin/vmPlayerSpin/g
 * Shared by satellite imagery and radar animation pages.
 * Modern, minimal design inspired by RainViewer/Windy.
 *
 * @version 1.1.0 â€” range selektor (4h/12h/24h) + export meni (PNG/GIF/MP4) + progress
 */

/* â”€â”€ Container â”€â”€ */
.vm-player {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #0a0f1a;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

/* â”€â”€ Canvas (image area) â”€â”€ */
.vm-player__canvas {
    position: relative;
    width: 100%;
    background: #0a0f1a;
    overflow: hidden;
    line-height: 0;
    min-height: 200px;
}

.vm-player__canvas img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* Stacked frames mode â€” all frames absolute, only active visible via opacity.
   Canvas aspect-ratio se postavlja kroz CSS variable --vm-player-aspect
   (default Balkan 1.333). JS postavlja varijablu pre `loadFrames` na osnovu
   region.width/height. Time canvas ima TAÄŒAN oblik pre nego Å¡to slike stignu â€”
   sizer slika se viÅ¡e ne koristi za odreÄ‘ivanje visine. */
.vm-player__canvas--stacked {
    position: relative;
    overflow: hidden;
    background: #0a0f1a;
    aspect-ratio: var(--vm-player-aspect, 1.333);
    width: 100%;
}

/* Sizer ostaje radi kompatibilnosti, ali nije viÅ¡e potreban za visinu â€”
   sakriven je i ne uÄestvuje u layout-u (display: none umesto position relative).
   Nove verzije browser-a koriste aspect-ratio iznad. */
.vm-player__canvas--stacked .vm-player__sizer {
    display: none !important;
}

/* All frame images are absolute-positioned, only active is visible */
.vm-player__canvas--stacked img:not(.vm-player__sizer) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    pointer-events: none;
    /* NO transition â€” instant swap eliminates flickering */
}

.vm-player__canvas--stacked img.vm-player__frame--active {
    opacity: 1;
    z-index: 2;
}

/* â”€â”€ Overlay: timestamp badge â”€â”€ */
.vm-player__timestamp {
    position: absolute;
    bottom: 52px;
    right: 12px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #e2e8f0;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    pointer-events: none;
    z-index: 5;
}

/* â”€â”€ Overlay: loading spinner â”€â”€ */
.vm-player__loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 15, 26, 0.7);
    z-index: 10;
}

.vm-player__loading.active {
    display: flex;
}

.vm-player__spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: vmPlayerSpin 0.8s linear infinite;
}

@keyframes vmPlayerSpin {
    to { transform: rotate(360deg); }
}

/* â”€â”€ Controls bar â”€â”€ */
.vm-player__bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(10, 15, 26, 0.0) 0%, rgba(10, 15, 26, 0.95) 100%);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 6;
}

/* â”€â”€ Buttons â”€â”€ */
.vm-player__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
    padding: 0;
    font-size: 0;
}

.vm-player__btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.vm-player__btn:active {
    transform: scale(0.92);
}

.vm-player__btn--play {
    width: 42px;
    height: 42px;
    background: #3b82f6;
}

.vm-player__btn--play:hover {
    background: #2563eb;
}

/* SVG icons inside buttons */
.vm-player__btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.vm-player__btn--play svg {
    width: 20px;
    height: 20px;
}

/* â”€â”€ Timeline (progress bar) â”€â”€ */
.vm-player__timeline {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    margin: 0 4px;
}

.vm-player__timeline:hover {
    height: 8px;
}

.vm-player__progress {
    height: 100%;
    background: #3b82f6;
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
    pointer-events: none;
}

/* â”€â”€ Counter â”€â”€ */
.vm-player__counter {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 48px;
    text-align: center;
}

/* â”€â”€ Speed selector â”€â”€ */
.vm-player__speed {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    padding: 0 8px;
}

.vm-player__speed:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}

/* â”€â”€ Range selektor (4h/12h/24h) â”€â”€ */
.vm-player__range {
    display: inline-flex;
    align-items: center;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    flex-shrink: 0;
}

.vm-player__range-btn {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.68rem;
    font-weight: 600;
    height: 100%;
    padding: 0 9px;
    cursor: pointer;
    transition: all 0.15s;
}

.vm-player__range-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}

.vm-player__range-btn.active {
    background: #3b82f6;
    color: #fff;
}

/* â”€â”€ Export meni (PNG/GIF/MP4) â”€â”€ */
.vm-player__export {
    position: relative;
    flex-shrink: 0;
}

.vm-player__btn--export[disabled] {
    opacity: 0.4;
    cursor: default;
}

.vm-player__export-menu {
    position: absolute;
    bottom: 44px;
    right: 0;
    z-index: 20;
    min-width: 185px;
    background: rgba(10, 15, 26, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.vm-player__export-menu[hidden] {
    display: none;
}

.vm-player__export-menu button {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: #e2e8f0;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
    padding: 8px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.vm-player__export-menu button:hover {
    background: rgba(255, 255, 255, 0.12);
}

.vm-player__export-menu button[disabled] {
    opacity: 0.4;
    cursor: default;
}

/* â”€â”€ Export progress (iznad bara) â”€â”€ */
.vm-player__export-progress {
    position: absolute;
    bottom: 56px;
    left: 12px;
    right: 12px;
    z-index: 7;
    background: rgba(10, 15, 26, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 8px 12px;
}

.vm-player__export-progress[hidden] {
    display: none;
}

.vm-player__export-progress-text {
    display: block;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.72rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.vm-player__export-progress-track {
    height: 5px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    overflow: hidden;
}

.vm-player__export-progress-fill {
    height: 100%;
    width: 0%;
    background: #3b82f6;
    border-radius: 3px;
    transition: width 0.15s linear;
}

/* â”€â”€ Freshness badge â”€â”€ */
.vm-player__fresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.vm-player__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.vm-player__dot--fresh {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.vm-player__dot--recent {
    background: #eab308;
    box-shadow: 0 0 6px rgba(234, 179, 8, 0.3);
}

.vm-player__dot--stale {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.3);
}

/* â”€â”€ Responsive â”€â”€ */
@media (max-width: 600px) {
    .vm-player__bar {
        gap: 4px;
        padding: 6px 8px;
    }

    .vm-player__btn {
        width: 32px;
        height: 32px;
    }

    .vm-player__btn--play {
        width: 38px;
        height: 38px;
    }

    .vm-player__speed {
        display: none;
    }

    /* Range OSTAJE vidljiv na mobilnom (menja koliÄinu podataka, ne samo tempo) */
    .vm-player__range-btn {
        padding: 0 6px;
        font-size: 0.62rem;
    }

    .vm-player__counter {
        font-size: 0.65rem;
        min-width: 40px;
    }

    .vm-player__export-menu {
        min-width: 165px;
    }

    .vm-player__timestamp {
        bottom: 48px;
        font-size: 0.72rem;
        padding: 4px 10px;
    }
}

/* â”€â”€ Light theme adjustments â”€â”€ */
[data-theme="light"] .vm-player {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}
