/* =============================================================
   player.css — Video player page styles
   Depends on: style.css (theme tokens, pulse, font)
   ============================================================= */

/* ── Page layout ── */
html {
    height: 100dvh;
}

body {
    background-image: url('/image/BackgroundDark.png');
    background-size: cover;
    margin: 0;
    width: 100%;
    height: 100dvh;
}

body::before {
    content: "";
    position: absolute;
    inset: 0;
    height: 100dvh;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: -1;
}

/* ── Loading overlay ── */
#loadingOverlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: var(--bg);
    display: block;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

#loadingOverlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2;
}

@keyframes spin {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ── Skeleton loading: shared shimmer ── */
.skeleton-box,
.skeleton-tick-bar,
.skeleton-map-location,
.skeleton-compass-close {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.05) 25%,
            rgba(255, 255, 255, 0.15) 50%,
            rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: ghost-shimmer 1.5s infinite;
    border-radius: 6px;
}

@keyframes ghost-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ── Light Mode Skeleton Adjustments ── */
[data-theme="light"] .skeleton-box,
[data-theme="light"] .skeleton-tick-bar,
[data-theme="light"] .skeleton-map-location,
[data-theme="light"] .skeleton-compass-close {
    background: linear-gradient(90deg,
            rgba(0, 0, 0, 0.06) 25%,
            rgba(0, 0, 0, 0.15) 50%,
            rgba(0, 0, 0, 0.06) 75%);
    background-size: 200% 100%;
}

[data-theme="light"] .skeleton-compass,
[data-theme="light"] .skeleton-toolbar {
    background: rgba(255, 255, 255, 0.85) !important;
    border-color: var(--border) !important;
}

[data-theme="light"] .skeleton-drone-data {
    background: rgba(255, 255, 255, 0.85) !important;
    border: 1px solid var(--border) !important;
}

/* Compass skeleton */
.skeleton-compass {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 40px;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.6);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.skeleton-compass-strip {
    display: flex;
    align-items: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.skeleton-tick {
    width: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.skeleton-tick-bar {
    height: 10px;
    border-radius: 3px;
    background-size: 400% 100%;
}

.skeleton-tick-bar.tick-cardinal {
    width: 18px;
    height: 14px;
}

.skeleton-tick-bar.tick-intercardinal {
    width: 14px;
    height: 10px;
}

.skeleton-compass-center {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: rgba(64, 0, 0, 0.5);
    z-index: 2;
    pointer-events: none;
}

.skeleton-map-location {
    position: absolute;
    left: 20px;
    width: 140px;
    height: 16px;
    border-radius: 3px;
    background-size: 400% 100%;
}

/* Skeleton compass controls positioning */
.skeleton-compass-controls {
    position: absolute;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
}

.skeleton-ai-toggle {
    width: 32px;
    height: 24px;
    border-radius: 20px;
}

.skeleton-close-btn {
    width: 65px;
    height: 24px;
    border-radius: 6px;
}

/* Map skeleton */
.skeleton-map {
    position: absolute;
    top: 60px;
    left: 20px;
    width: 20vw;
    height: 20vh;
    min-width: 150px;
    min-height: 150px;
    max-width: 350px;
    max-height: 500px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Drone data skeleton */
.skeleton-drone-data {
    position: absolute;
    bottom: 60px;
    right: 20px;
    width: 280px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    padding: 6px 10px;
    box-sizing: border-box;
}

.skeleton-drone-row {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30px;
    gap: 8px;
    padding: 4px 0;
}

.skeleton-drone-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 3px;
}

.skeleton-drone-name {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.skeleton-drone-name-line {
    width: 52px;
    height: 12px;
    border-radius: 3px;
}

.skeleton-drone-pilot-line {
    width: 36px;
    height: 9px;
    border-radius: 3px;
    opacity: 0.6;
}

.skeleton-drone-tel {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.skeleton-drone-tel-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.skeleton-drone-tel-val {
    width: 26px;
    height: 12px;
    border-radius: 3px;
}

/* Toolbar skeleton */
.skeleton-toolbar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.6);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    gap: 0.75rem;
    box-sizing: border-box;
}

.skeleton-toolbar .btn-placeholder {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-toolbar .timeline-placeholder {
    flex: 1;
    height: 4px;
    border-radius: 2px;
}

.skeleton-toolbar .info-placeholder {
    width: 90px;
    height: 12px;
    flex-shrink: 0;
}

/* ── State overlays ── */
#notPublic,
#notStarted,
#processing {
    display: none;
    justify-content: center;
    align-items: center;
    position: absolute;
    inset: 0;
    height: 100dvh;
    width: 100%;
    z-index: 1000;
    background-color: rgba(128, 0, 0, 0.5);
}

#notPublic .container,
#notStarted .container,
#processing .container {
    max-width: 600px;
    width: 100%;
    background: white;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    padding: 2.5rem;
}

#pause {
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    inset: 0;
    height: 100%;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.25);
    transition: display 0.2s ease;
    pointer-events: auto;
    z-index: 2;
}

#pause i {
    filter: invert(0);
}

/* ── Video container ── */
#videoContainer {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
    z-index: 1;
    width: 100%;
    height: 100%;
}

#videoPlayer {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    z-index: 1;
}

/* ── PiP mode ── */
#siblingPicker {
    position: fixed;
    bottom: 60px;
    left: 20px;
    z-index: 15;
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    flex-direction: column-reverse;
}

#siblingPicker .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
    color: var(--bg);
    height: 40px;
    width: 130px;
    gap: 8px;
    font-size: 12px;
    transition: background 0.15s ease, transform 0.15s ease;
}

#siblingPicker .btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

#videoContainer[data-mode="pip"] {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
}

#videoContainer[data-mode="pip"] #videoPlayer {
    width: 100%;
    height: 100%;
}

.pip-video-wrap {
    position: absolute;
    z-index: 25;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.pip-video {
    width: 100%;
    height: 100%;
    display: block;
}

.pip-label {
    position: absolute;
    top: 40px;
    left: 0;
    right: 0;
    color: #fff;
    font-size: 12px;
    text-align: center;
    pointer-events: none;
}

.pip-video-wrap.pip-secondary .pip-label {
    top: 2px;
    left: 5px;
    right: unset;
    font-size: 10px;
}

.pip-video-wrap.pip-main {
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    padding: 40px 0;
    top: 0 !important;
    right: 0 !important;
    border-color: transparent !important;
    z-index: 4;
}

.pip-video-wrap.pip-main .pip-video {
    object-fit: contain;
}

.pip-video-wrap.pip-secondary {
    z-index: 10;
    height: 10vh;
    width: fit-content;
    min-height: 150px;
    max-height: 350px;
    right: 20px;
    cursor: pointer;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.pip-video-wrap.pip-secondary video {
    object-fit: cover !important;
}

.pip-video-wrap.pip-secondary[data-sec-idx="0"] {
    top: 60px;
}

.pip-video-wrap.pip-secondary[data-sec-idx="1"] {
    top: calc(80px + max(10vh, 150px));
}

.pip-video-wrap.pip-secondary[data-sec-idx="2"] {
    top: calc(100px + max(20vh, 300px));
}

.pip-video-wrap.pip-secondary:hover {
    border-color: #55a1ff;
    transform: scale(1.02);
}

/* ── Grid mode ── */
#videoContainer[data-mode="grid"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 3px;
    padding-top: 0;
}

#videoContainer[data-mode="grid"] #videoPlayer {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#videoContainer[data-mode="grid"]~#mapBlock {
    margin-top: 20px;
}

#videoContainer[data-mode="grid"]~#mapBlock #mapLocation {
    position: absolute;
    top: unset;
    bottom: 0;
    left: 0;
    margin-bottom: -20px;
}

.pip-video-wrap.grid-cell {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    top: auto !important;
    right: auto !important;
    border: none !important;
    border-radius: 0 !important;
}

.pip-video-wrap.grid-cell .pip-video {
    object-fit: cover;
}

.pip-video-wrap.grid-cell .pip-label {
    top: 0;
}

.pip-close-btn {
    top: 2px;
    right: 2px;
    cursor: pointer;
    border-radius: 8px;
}

/* ── Map widget ── */
#mapBlock {
    z-index: 25;
    width: 20vw;
    height: 20vh;
    min-width: 150px;
    min-height: 150px;
    max-width: 350px;
    max-height: 500px;
    margin: 60px 20px;
    display: none;
    position: absolute;
    align-items: flex-start;
    cursor: default;
    border-radius: 8px;
    border: 1px solid var(--border);
}

#mapBlock.collapsed {
    width: 40px;
    height: 40px;
    overflow: hidden;
    border: 1px solid transparent;
}

#mapBlock.collapsed #mapTitle {
    display: none;
}

#mapBlock.collapsed #map {
    display: none;
}

#mapBlock.collapsed #altitude {
    margin-top: 30px;
    top: 0;
}

#mapBlock.collapsed #mapCollapseButton i::before {
    content: "\f424";
}

#mapDragHandle,
#mapCollapseButton,
.pip-close-btn {
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: background 0.15s;
}

#mapDragHandle {
    top: 0;
    right: 0;
    cursor: move;
    border-radius: 8px;
    user-select: none;
    -webkit-user-select: none;
}

#mapCollapseButton {
    top: 0;
    left: 0;
    cursor: pointer;
    border-radius: 8px;
}

#mapDragHandle:hover,
#mapCollapseButton:hover {
    background: rgba(255, 255, 255, 0.9);
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* ── Toolbar ── */
#toolbar {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 40px;
    padding: 0 0.75rem;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.6);
    border-top: 1px solid var(--border);
    z-index: 15;
}

#live {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#live p {
    margin: 0;
    color: #ffffff;
}

#timeline {
    flex: 1 1 auto;
    min-width: 150px;
    max-width: 100%;
}

.toolbar-info {
    flex: 0 0 auto;
    text-align: right;
    white-space: nowrap;
}

#toolbar p {
    color: #fff;
    margin: 0;
    font-size: 0.85rem;
}

#timestamp {
    font-size: 0.7rem;
    opacity: 0.8;
}

#multiToggleBtn {
    display: none;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.15s;
}

#multiToggleBtn:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* ── Compass ── */
.compass-container {
    display: none;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    width: 100%;
    height: 40px;
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.6);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    z-index: 15;
}

#mapLocation {
    top: 12px;
    left: 20px;
    position: fixed;
    max-width: 35dvw;
    max-height: 36px;
    margin: 0;
    color: white;
    z-index: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    line-height: 1.1;
    font-size: clamp(9px, 1.2vw, 14px);
    transition: font-size 0.2s ease;
}

.compass-viewport {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to right,
            transparent 0px,
            transparent min(calc(35dvw - 25px), 225px),
            black min(35dvw, 250px),
            black calc(100% - 170px),
            transparent calc(100% - 130px));
    mask-image: linear-gradient(to right,
            transparent 0px,
            transparent min(calc(35dvw - 25px), 225px),
            black min(35dvw, 250px),
            black calc(100% - 170px),
            transparent calc(100% - 130px));
}

.compass-strip {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    transition: transform 0.1s linear;
}

.tick {
    width: 80px;
    text-align: center;
    color: #aaa;
    font-size: 14px;
}

.tick strong {
    color: white;
    font-size: 18px;
}

.center-marker {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: red;
}

/* Compass Bar Right Controls Wrapper */
.compass-controls {
    position: absolute;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
}

/* AI Detection Toggle Styling */
.ai-toggle-wrap {
    display: flex;
    align-items: center;
    position: relative;
}

.ai-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.ai-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.ai-toggle-label i {
    font-size: 0.9rem;
    transition: transform 0.2s ease, color 0.2s ease;
}

.ai-toggle-label:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Checked state styling for AI Switch */
.ai-toggle-input:checked + .ai-toggle-label {
    background: rgba(13, 110, 253, 0.35);
    border-color: #0d6efd;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(13, 110, 253, 0.4);
}

.ai-toggle-input:checked + .ai-toggle-label i {
    color: #4595ff;
    transform: scale(1.1);
}

/* ── Prominent Close Page Button ── */
.btn-close-page {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(220, 53, 69, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.btn-close-page:hover {
    background: #dc3545;
    border-color: #ffffff;
    transform: scale(1.03);
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.6);
}

.btn-close-page i {
    font-size: 0.85rem;
}

/* ── Drone data overlay ── */
#droneData {
    display: none;
    position: fixed;
    bottom: 60px;
    right: 20px;
    color: white;
    font-size: 14px;
    text-align: end;
    z-index: 15;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px;
    backdrop-filter: blur(8px);
    width: 280px;
}

.drone-row {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30px;
    gap: 8px;
    font-size: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
}

.drone-row:last-child {
    border-bottom: none;
}

.drone-row span {
    color: #30363d;
    line-height: 1.2;
}

.drone-row-focused span {
    color: #0d1117;
}

.drone-row img {
    flex-shrink: 0;
    opacity: 0.9;
}

/* ── YOLO detection overlay canvas ── */
#detectionCanvas {
    position: fixed;
    display: none;           /* shown only when detections are present */
    pointer-events: none;    /* clicks pass through to the video */
    z-index: 12;             /* above video (z:1) but below toolbar (z:15) */
    image-rendering: pixelated;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .pip-video-wrap.pip-secondary {
        width: 140px;
        height: 78px;
        right: 8px;
    }

    .pip-video-wrap.pip-secondary[data-sec-idx="0"] {
        top: 8px;
    }

    .pip-video-wrap.pip-secondary[data-sec-idx="1"] {
        top: 94px;
    }

    .pip-video-wrap.pip-secondary[data-sec-idx="2"] {
        top: 180px;
    }
}