/* Shared styles for both FPV and DJI Mini simulators */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
    background: rgba(26, 29, 38, 0.85);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    z-index: 10;
    height: 60px;

    & h1 {
        font-size: 1.5rem;
        font-weight: 800;
        background: linear-gradient(135deg, #06b6d4 0%, #10b981 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        letter-spacing: -0.02em;
    }
}

nav {
    display: flex;
    background: rgba(43, 49, 69, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.2rem;
    border-radius: 10px;
    gap: 0.2rem;

    & a {
        color: var(--text-muted);
        font-weight: 600;
        text-decoration: none;
        padding: 0.35rem 0.75rem;
        border-radius: 7px;
        font-size: 0.8rem;
        transition: all 0.2s ease;

        &.active {
            color: #fff;
            background: var(--accent-cyan);
            box-shadow: none;
        }

        &:hover:not(.active) {
            color: var(--text-main);
            background: rgba(255, 255, 255, 0.03);
        }
    }
}

/* Simulator Layout Grid */
.sim-container {
    flex: 1;
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 65px);
    position: relative;
}

/* Sidebar configuration panel */
.sidebar {
    background: rgba(15, 20, 35, 0.9);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    z-index: 5;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    border-left: 3px solid var(--accent-cyan);
    padding-left: 0.5rem;
    letter-spacing: -0.01em;
    color: var(--text-main);
}

.card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;

    & span {
        color: var(--text-muted);
    }

    & strong {
        font-weight: 600;
    }
}

select, button {
    background: rgba(0, 0, 0, 0.5);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

button {
    &:hover {
        border-color: var(--accent-cyan);
        background: rgba(6, 182, 212, 0.08);
    }

    &.action-btn {
        background: var(--accent-cyan);
        border: none;
        font-weight: 600;
        padding: 0.6rem;
        color: #fff;
        box-shadow: none;

        &:hover {
            background: #0891b2;
            box-shadow: none;
            transform: none;
        }
    }
}

/* 3D WebGL Canvas Area */
.canvas-area {
    position: relative;
    background: #000;
    width: 100%;
    height: 100%;
}




/* FPV OSD HUD styles */
.hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    font-family: monospace;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-shadow: 0 0 4px rgba(6, 182, 212, 0.5);
    font-size: 0.9rem;
    z-index: 2;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.hud-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.hud-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Crosshair elements */
.crosshair-c {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid rgba(6, 182, 212, 0.85);
}

.crosshair-left, .crosshair-right {
    position: absolute;
    width: 30px;
    height: 1px;
    background: rgba(6, 182, 212, 0.85);
}

.crosshair-left {
    left: 40px;
    &::after {
        content: '';
        position: absolute;
        height: 6px;
        width: 1px;
        background: rgba(6, 182, 212, 0.85);
        top: -3px;
        right: 0;
    }
}

.crosshair-right {
    right: 40px;
    &::after {
        content: '';
        position: absolute;
        height: 6px;
        width: 1px;
        background: rgba(6, 182, 212, 0.85);
        top: -3px;
        left: 0;
    }
}

/* DJI Gimbal Frame */
.gimbal-frame {
    border: 1px dashed rgba(16, 185, 129, 0.35);
    width: 240px;
    height: 160px;
    position: relative;

    &::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 0;
        width: 100%;
        height: 1px;
        background: rgba(16, 185, 129, 0.15);
    }

    &::after {
        content: '';
        position: absolute;
        left: 50%;
        top: 0;
        width: 1px;
        height: 100%;
        background: rgba(16, 185, 129, 0.15);
    }
}

/* Info Overlays (Crash screen, capture focus screen) */
.info-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    padding: 1.5rem 2.5rem;
    border-radius: 20px;
    text-align: center;
    display: none;
    flex-direction: column;
    gap: 0.8rem;
    z-index: 8;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);

    & h2 {
        font-size: 1.8rem;
        font-weight: 800;
    }

    & p {
        color: var(--text-muted);
        font-size: 0.95rem;
    }
}

/* Gamepad status dots */
.status-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);

    &.connected {
        background-color: var(--accent-green);
        box-shadow: 0 0 8px var(--accent-green);
    }
}

.keys-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;

    & kbd {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.15);
        padding: 0.1rem 0.3rem;
        border-radius: 4px;
        color: var(--text-main);
        font-family: inherit;
    }
}

/* ── Picture-in-Picture (PiP) ground camera ── */
.pip-window {
    position: absolute;
    bottom: 1.2rem;
    right: 1.2rem;
    width: 280px;
    height: 175px;
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid rgba(6, 182, 212, 0.45);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(6, 182, 212, 0.12);
    z-index: 6;
    transition: width 0.35s cubic-bezier(.4,0,.2,1),
                height 0.35s cubic-bezier(.4,0,.2,1),
                bottom 0.35s cubic-bezier(.4,0,.2,1),
                right 0.35s cubic-bezier(.4,0,.2,1);
    cursor: pointer;
    background: #000;
}

.pip-window:hover {
    border-color: rgba(6, 182, 212, 0.7);
    box-shadow: 0 8px 36px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(6, 182, 212, 0.22), 0 0 20px rgba(6, 182, 212, 0.12);
}

/* When views are swapped, PiP becomes the big screen */
.pip-window.swapped {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
    z-index: 1;
    cursor: default;
}

#simulator-canvas.swapped {
    position: absolute;
    bottom: 1.2rem;
    right: 1.2rem;
    width: 280px;
    height: 175px;
    border-radius: 14px;
    border: 2px solid rgba(16, 185, 129, 0.45);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(16, 185, 129, 0.12);
    z-index: 6;
    transition: width 0.35s cubic-bezier(.4,0,.2,1),
                height 0.35s cubic-bezier(.4,0,.2,1),
                bottom 0.35s cubic-bezier(.4,0,.2,1),
                right 0.35s cubic-bezier(.4,0,.2,1);
}

#simulator-canvas {
    width: 100%;
    height: 100%;
    display: block;
    position: absolute;
    inset: 0;
    transition: width 0.35s cubic-bezier(.4,0,.2,1),
                height 0.35s cubic-bezier(.4,0,.2,1),
                bottom 0.35s cubic-bezier(.4,0,.2,1),
                right 0.35s cubic-bezier(.4,0,.2,1);
}

#pip-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* PiP label badge */
.pip-label {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    font-family: monospace;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: rgba(16, 185, 129, 0.9);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    padding: 0.15rem 0.4rem;
    border-radius: 5px;
    border: 1px solid rgba(16, 185, 129, 0.3);
    pointer-events: none;
    z-index: 3;
    transition: opacity 0.2s;
}

/* Swap button inside PiP */
.pip-swap-btn {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    font-family: 'Outfit', sans-serif;
    color: #fff;
    background: rgba(6, 182, 212, 0.2);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(6, 182, 212, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);

    & svg {
        width: 13px;
        height: 13px;
        flex-shrink: 0;
    }

    &:hover {
        background: rgba(6, 182, 212, 0.45);
        border-color: var(--accent-cyan);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
    }

    &:active {
        transform: scale(0.96);
    }
}

/* HUD overlay visibility when swapped */
#hud-overlay.hidden {
    display: none;
}

/* Accordion Panels Styling for Settings Drawer */
.settings-group {
    background: rgba(55, 65, 92, 0.35);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    margin-bottom: 0.6rem;
}

.settings-group[open] {
    border-color: rgba(6, 182, 212, 0.25);
    background: rgba(55, 65, 92, 0.65);
}

.settings-group summary {
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    list-style: none;
    user-select: none;
}

.settings-group summary::-webkit-details-marker {
    display: none;
}

.settings-group summary:hover {
    background: rgba(255, 255, 255, 0.015);
}

.summary-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.summary-icon {
    width: 15px;
    height: 15px;
    color: var(--accent-cyan);
}

.accordion-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.settings-group[open] summary .accordion-chevron {
    transform: rotate(180deg);
    color: var(--accent-cyan);
}

.group-content {
    padding: 0.85rem 1rem 1rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

/* Subtle animation on open */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-group[open] .group-content {
    animation: slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
