/* ════════════════════════════════════════════════════
   AURORA DRONE OPS — Sovereign Executive Design System
   Phase 2 | Full Interface Stylesheet
════════════════════════════════════════════════════ */

:root {
    --c-bg:          #0d1117;
    --c-sidebar:     #111827;
    --c-topbar:      #0d1117;
    --c-section:     #161d2b;
    --c-card:        #1a2232;
    --c-card-hover:  #1e2a3f;
    --c-border:      #243046;
    --c-border-subtle: rgba(255,255,255,0.06);

    --c-blue:        #3b82f6;
    --c-blue-glow:   rgba(59,130,246,0.35);
    --c-green:       #10b981;
    --c-green-glow:  rgba(16,185,129,0.35);
    --c-red:         #ef4444;
    --c-red-glow:    rgba(239,68,68,0.35);
    --c-amber:       #f59e0b;
    --c-amber-glow:  rgba(245,158,11,0.35);
    --c-cyan:        #06b6d4;

    --c-text:        #e2e8f0;
    --c-text-muted:  #64748b;
    --c-text-dim:    #475569;

    --sidebar-w:     260px;
    --topbar-h:      44px;
    --font: 'Inter', sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

/* ── RESET ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--c-bg); color: var(--c-text); overflow: hidden; height: 100vh; width: 100vw; font-size: 13px; }
button { font-family: var(--font); cursor: pointer; border: none; outline: none; }
input { font-family: var(--font); }
ul, ol { list-style: none; }

/* ── MAP ──────────────────────────────────────── */
#map {
    position: fixed;
    top: 0; left: var(--sidebar-w); right: 0; bottom: 0;
    background-color: #0d1117; /* Matches body bg to prevent flicker */
    -webkit-transform: translate3d(0,0,0); /* Force GPU acceleration for Safari */
}

/* ── TOP BAR ──────────────────────────────────── */
#top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--c-topbar);
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 100;
}

.top-bar-left, .top-bar-right {
    display: flex; align-items: center; gap: 1rem;
}

.brand {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em;
    color: var(--c-text);
}
.brand-icon {
    width: 18px; height: 18px; color: var(--c-blue);
}

.top-bar-divider {
    width: 1px; height: 18px; background: var(--c-border);
}

.top-status-item {
    font-size: 0.75rem; color: var(--c-text-muted); letter-spacing: 0.04em;
}

.status-val { font-weight: 600; }
.status-val.active { color: var(--c-green); }
.status-val.none { color: var(--c-text-muted); }
.status-val.alert { color: var(--c-red); }

.top-clock {
    font-family: var(--mono); font-size: 0.75rem; color: var(--c-blue);
    letter-spacing: 0.05em;
}

.btn-icon-sm {
    background: transparent; color: var(--c-text-muted);
    font-size: 1rem; padding: 0.2rem 0.5rem; border-radius: 4px;
    transition: color 0.2s;
}
.btn-icon-sm:hover { color: var(--c-text); background: var(--c-section); }

/* ── SIDEBAR ──────────────────────────────────── */
#sidebar {
    position: fixed;
    top: var(--topbar-h); left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--c-sidebar);
    border-right: 1px solid var(--c-border);
    overflow-y: auto;
    z-index: 50;
    display: flex;
    flex-direction: column;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 4px; }

.sidebar-header {
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--c-border);
}
.sidebar-header h2 {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--c-blue);
}

/* ── SECTIONS ─────────────────────────────────── */
.sidebar-section {
    border-bottom: 1px solid var(--c-border);
}

.section-title {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.7rem 1rem;
    background: var(--c-section);
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em;
    color: var(--c-text-muted);
    cursor: pointer;
    user-select: none;
}
.section-title:hover { color: var(--c-text); }

.collapse-btn {
    background: transparent; color: var(--c-text-dim); font-size: 0.55rem;
    transition: transform 0.2s;
}
.collapse-btn.collapsed { transform: rotate(180deg); }

.section-body {
    padding: 0.85rem 1rem;
}
.section-body.collapsed { display: none; }

/* ── SETUP STATE ──────────────────────────────── */
.hint-text {
    font-size: 0.75rem; color: var(--c-text-muted);
    line-height: 1.5; margin-bottom: 1rem;
    background: rgba(59,130,246,0.05);
    border-left: 2px solid var(--c-blue);
    padding: 0.5rem 0.75rem; border-radius: 0 4px 4px 0;
}

.slider-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em;
    color: var(--c-text-muted); margin-bottom: 0.5rem;
}
.count-badge {
    font-family: var(--mono); font-size: 0.7rem;
    color: var(--c-blue); font-weight: 600;
    background: rgba(59,130,246,0.1);
    padding: 0.15rem 0.5rem; border-radius: 3px;
    border: 1px solid rgba(59,130,246,0.25);
}

.slider-track {
    display: flex; align-items: center; gap: 0.4rem; margin-bottom: 1rem;
}
.slider-min, .slider-max {
    font-size: 0.65rem; color: var(--c-text-dim); font-family: var(--mono);
    min-width: 14px;
}

.drone-slider {
    -webkit-appearance: none; appearance: none;
    flex: 1; height: 4px;
    background: var(--c-border); border-radius: 4px; outline: none;
}
.drone-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--c-blue); cursor: pointer;
    border: 2px solid var(--c-sidebar);
    box-shadow: 0 0 10px var(--c-blue-glow);
    transition: transform 0.15s;
}
.drone-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }

/* ── DEPLOY BUTTON ────────────────────────────── */
.btn-deploy {
    width: 100%;
    padding: 0.65rem;
    background: var(--c-blue);
    color: #fff; font-weight: 700;
    font-size: 0.75rem; letter-spacing: 0.08em;
    border-radius: 5px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px var(--c-blue-glow);
}
.btn-deploy:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--c-blue-glow);
}
.btn-deploy:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* ── ACTION BUTTONS ───────────────────────────── */
.action-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.action-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.4rem; padding: 0.75rem 0.35rem;
    border-radius: 5px;
    font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em;
    text-align: center;
    transition: all 0.2s;
}
.action-btn svg { width: 18px; height: 18px; }

.patrol-btn { background: var(--c-blue); color: #fff; }
.patrol-btn:hover { background: #2563eb; box-shadow: 0 0 16px var(--c-blue-glow); }
.patrol-btn.active { background: var(--c-green); box-shadow: 0 0 16px var(--c-green-glow); }

.stop-btn { background: var(--c-red); color: #fff; }
.stop-btn:hover { box-shadow: 0 0 16px var(--c-red-glow); filter: brightness(1.1); }

.return-btn { background: var(--c-amber); color: #000; }
.return-btn:hover { box-shadow: 0 0 16px var(--c-amber-glow); filter: brightness(1.1); }

.btn-reset {
    width: 100%; padding: 0.5rem;
    background: transparent; color: var(--c-text-muted);
    font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em;
    border: 1px solid var(--c-border);
    border-radius: 4px; transition: all 0.2s;
}
.btn-reset:hover { background: var(--c-section); color: var(--c-text); }

/* ── TRAILS TOGGLE ROW ────────────────────────────────── */
.trails-toggle-row {
    display: flex; gap: 0.45rem;
    margin-bottom: 0.5rem;
}

.btn-trails {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.45rem 0.5rem;
    background: rgba(6,182,212,0.08);
    color: var(--c-text-muted);
    font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em;
    border: 1px solid rgba(6,182,212,0.2);
    border-radius: 4px;
    transition: all 0.2s;
}
.btn-trails svg { width: 13px; height: 13px; flex-shrink: 0; }
.btn-trails:hover { background: rgba(6,182,212,0.18); color: var(--c-cyan); }
.btn-trails.active {
    background: rgba(6,182,212,0.15);
    color: var(--c-cyan);
    border-color: rgba(6,182,212,0.45);
    box-shadow: 0 0 8px rgba(6,182,212,0.25);
}

.btn-trails-clear {
    padding: 0.45rem 0.6rem;
    background: transparent;
    color: var(--c-text-dim);
    font-size: 0.62rem; font-weight: 600; letter-spacing: 0.04em;
    border: 1px solid var(--c-border);
    border-radius: 4px;
    transition: all 0.18s;
    white-space: nowrap;
}
.btn-trails-clear:hover { background: rgba(239,68,68,0.08); color: var(--c-red); border-color: rgba(239,68,68,0.3); }

/* ── ANALYTICS GRID ───────────────────────────── */
.analytics-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
}
.analytic-card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: 5px;
    padding: 0.65rem 0.4rem;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    position: relative; overflow: hidden;
}
.analytic-card.highlight {
    border-color: rgba(59,130,246,0.35);
    background: rgba(59,130,246,0.07);
}
.analytic-card.highlight::after {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--c-blue);
}
.analytic-label {
    font-size: 0.58rem; font-weight: 700; letter-spacing: 0.1em;
    color: var(--c-text-muted); margin-bottom: 0.3rem;
}
.analytic-value {
    font-size: 1.1rem; font-weight: 700; font-family: var(--mono);
    color: var(--c-text);
}
.analytic-unit {
    font-size: 0.58rem; color: var(--c-text-dim); margin-top: 0.15rem;
}

/* ── FLEET LIST ───────────────────────────────── */
.fleet-list {
    display: flex; flex-direction: column; gap: 0.35rem;
    max-height: 300px;
    overflow-y: auto;
}
.fleet-list::-webkit-scrollbar { width: 3px; }
.fleet-list::-webkit-scrollbar-thumb { background: var(--c-border); }

.fleet-empty {
    font-size: 0.72rem; color: var(--c-text-dim); text-align: center;
    padding: 0.5rem; line-height: 1.5;
}

.drone-card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: 4px;
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;   /* stack top-row + actions vertically */
    cursor: pointer;
    transition: all 0.2s;
}
.drone-card:hover { background: var(--c-card-hover); border-color: var(--c-blue); }
.drone-card.selected { border-color: var(--c-blue); background: rgba(59,130,246,0.08); }

.drone-card-icon {
    width: 28px; height: 28px;
    background: rgba(59,130,246,0.12);
    border: 1px solid;
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; flex-shrink: 0;
}

.drone-card-info { flex: 1; min-width: 0; }
.drone-card-name {
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em;
    color: var(--c-text); margin-bottom: 0.2rem;
}
.drone-card-meta {
    display: flex; flex-direction: column; gap: 0.1rem;
}
.drone-card-meta span {
    font-size: 0.65rem; color: var(--c-text-muted);
    font-family: var(--mono);
}
.drone-card-meta .dstatus { font-weight: 600; }
.dstatus.active    { color: var(--c-green); }
.dstatus.idle      { color: var(--c-text-muted); }
.dstatus.returning { color: var(--c-amber); }
.dstatus.transiting { color: #a78bfa; animation: pulse-transit 1.2s ease-in-out infinite; }
.dstatus.low       { color: var(--c-red); animation: blink 1s step-end infinite; }
.dstatus.done      { color: var(--c-cyan); }

@keyframes pulse-transit {
    0%,100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

@keyframes blink { 0%,100% { opacity:1; } 50%{ opacity:0.4; } }

.drone-bat-bar {
    width: 100%; height: 3px; background: var(--c-border);
    border-radius: 2px; overflow: hidden; margin-top: 0.25rem;
}
.drone-bat-fill {
    height: 100%; border-radius: 2px;
    transition: width 0.5s, background-color 0.5s;
}

/* ── STATUS OVERVIEW ──────────────────────────── */
.overview-list {
    display: flex; flex-direction: column; gap: 0.4rem;
}
.overview-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.72rem; padding: 0.35rem 0;
    border-bottom: 1px solid var(--c-border-subtle);
}
.overview-label { color: var(--c-text-muted); }
.overview-val { font-family: var(--mono); font-weight: 700; font-size: 0.85rem; }
.active-col   { color: var(--c-green); }
.return-col   { color: var(--c-amber); }
.idle-col     { color: var(--c-text-muted); }
.done-col     { color: var(--c-cyan); }

/* ── ZONE TOOLTIP ─────────────────────────────── */
.zone-tooltip {
    position: fixed;
    bottom: 2rem; right: 2rem;
    background: rgba(13, 17, 23, 0.92);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 0.85rem 1rem;
    min-width: 180px;
    z-index: 60;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}
.zone-tooltip-header {
    font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em;
    color: var(--c-text-muted); margin-bottom: 0.5rem;
}
.zone-tooltip-header span { color: var(--c-blue); }
.zone-tooltip-row {
    font-size: 0.72rem; color: var(--c-text);
    font-family: var(--mono); margin-bottom: 0.2rem;
}
.zone-tooltip-row span { color: var(--c-green); font-weight: 600; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity:1; transform:translateY(0); } }

/* ── AUTH MODAL ───────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; backdrop-filter: blur(6px);
}
.auth-modal {
    background: var(--c-sidebar);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 2rem;
    width: 420px; text-align: center;
    display: flex; flex-direction: column; gap: 0.75rem;
}
.auth-icon { font-size: 2rem; }
.auth-modal h2 { font-size: 0.85rem; letter-spacing: 0.12em; color: var(--c-text); }
.auth-modal p { font-size: 0.78rem; color: var(--c-text-muted); line-height: 1.6; }
.token-input {
    width: 100%; padding: 0.75rem 1rem;
    background: var(--c-bg); border: 1px solid var(--c-border);
    border-radius: 5px; color: var(--c-text);
    font-family: var(--mono); font-size: 0.75rem; outline: none;
}
.token-input:focus { border-color: var(--c-blue); box-shadow: 0 0 0 2px var(--c-blue-glow); }
.error-msg { font-size: 0.72rem; color: var(--c-red); text-align: left; }

/* ── DRONE MARKERS ────────────────────────────── */
.marker-wrapper {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.custom-marker {
    cursor: pointer; pointer-events: auto;
    transition: transform 0.25s;
    position: relative;
}
.custom-marker:hover { transform: scale(1.3); }
.drone-icon {
    width: 28px; height: 28px;
    stroke: var(--c-blue); fill: rgba(59,130,246,0.12);
    stroke-width: 1.5;
    filter: drop-shadow(0 0 6px var(--c-blue-glow));
    animation: drone-bob 2s ease-in-out infinite;
}
@keyframes drone-bob {
    0%,100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.drone-label {
    position: absolute; top: -16px; left: 50%;
    transform: translateX(-50%);
    font-family: var(--mono); font-size: 0.58rem; font-weight: 700;
    color: var(--c-blue);
    background: rgba(13,17,23,0.75);
    border: 1px solid rgba(59,130,246,0.3);
    border-radius: 2px;
    padding: 1px 4px;
    white-space: nowrap;
    pointer-events: none;
}

/* ── MAPBOX OVERRIDES ─────────────────────────── */
.mapboxgl-ctrl-group {
    background: var(--c-sidebar) !important;
    border: 1px solid var(--c-border) !important;
    box-shadow: none !important;
}
.mapboxgl-ctrl-icon { filter: invert(0.7); }
.mapboxgl-ctrl-attrib { display: none !important; }

/* ── PER-DRONE ACTION BUTTONS ─────────────────── */
.drone-card-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;          /* fill the card */
    min-width: 0;        /* prevent overflow */
}

.drone-expand-icon {
    flex-shrink: 0;
    margin-left: auto;
    color: var(--c-text-dim);
    font-size: 0.75rem;
    font-weight: 600;
    width: 16px;
    text-align: center;
    transition: transform 0.2s;
}

.drone-actions {
    display: flex;
    flex-direction: row;  /* always a row */
    gap: 0.4rem;
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--c-border-subtle);
    width: 100%;
}

.drone-act-btn {
    flex: 1;              /* equal width, fills available space */
    padding: 0.4rem 0;
    border-radius: 4px;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    transition: all 0.18s;
    border: 1px solid transparent;
    white-space: nowrap;
}

.act-resume {
    background: rgba(59,130,246,0.12);
    color: var(--c-blue);
    border-color: rgba(59,130,246,0.25);
}
.act-resume:hover { background: rgba(59,130,246,0.25); }

.act-stop {
    background: rgba(239,68,68,0.12);
    color: var(--c-red);
    border-color: rgba(239,68,68,0.25);
}
.act-stop:hover { background: rgba(239,68,68,0.25); }

.act-return {
    background: rgba(245,158,11,0.12);
    color: var(--c-amber);
    border-color: rgba(245,158,11,0.25);
}
.act-return:hover { background: rgba(245,158,11,0.25); }

/* ── MISSION DONE BADGE (replaces action buttons) ── */
.drone-mission-done {
    margin-top: 0.5rem;
    padding: 0.35rem 0.6rem;
    border-top: 1px solid var(--c-border-subtle);
    font-size: 0.63rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--c-cyan);
    background: rgba(6,182,212,0.07);
    border-radius: 0 0 4px 4px;
    text-align: center;
}

/* ── UTILITIES ────────────────────────────────── */
.hidden { display: none !important; }

.hidden { display: none !important; }

/* ── BASE MARKER ──────────────────────────────── */
.base-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

.base-pulse {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 60px; height: 60px;
    border: 2px solid var(--c-blue);
    border-radius: 50%;
    opacity: 0;
    animation: base-radar 3s ease-out infinite;
}

@keyframes base-radar {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(2.0); opacity: 0; }
}

.base-icon {
    width: 38px; height: 38px;
    background: #1e293b;
    border: 2px solid var(--c-blue);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--c-blue);
    box-shadow: 0 0 20px var(--c-blue-glow);
    z-index: 2;
}

.base-label {
    margin-top: 6px;
    font-family: var(--mono);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--c-blue);
    background: rgba(15, 23, 42, 0.9);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--c-border);
    text-shadow: 0 0 5px var(--c-blue-glow);
    z-index: 2;
}

/* ── EVENT PULSE ──────────────────────────────── */
.event-pulse-wrapper {
    width: 80px; height: 80px;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.event-pulse-circle {
    width: 10px; height: 10px;
    background: var(--c-red);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 15px var(--c-red-glow);
}
.event-pulse-ring {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 10px; height: 10px;
    border: 2px solid var(--c-red);
    border-radius: 50%;
    opacity: 0;
    animation: event-ring-pulse 2s cubic-bezier(0.21, 0.61, 0.35, 1) infinite;
}
@keyframes event-ring-pulse {
    0% { width: 10px; height: 10px; opacity: 1; }
    100% { width: 80px; height: 80px; opacity: 0; }
}

/* ── ACTIVITY FEED ────────────────────────────── */
.activity-log {
    display: flex; flex-direction: column; gap: 0.5rem;
    max-height: 250px; overflow-y: auto;
    padding-right: 4px;
}
.activity-log::-webkit-scrollbar { width: 3px; }
.activity-log::-webkit-scrollbar-thumb { background: var(--c-border); }

.activity-empty {
    font-size: 0.68rem; color: var(--c-text-dim); text-align: center;
    padding: 1rem 0.5rem; font-style: italic;
}

.activity-item {
    background: rgba(255,255,255,0.03);
    border-left: 2px solid var(--c-border);
    padding: 0.5rem 0.65rem;
    border-radius: 0 4px 4px 0;
    animation: slideInLeft 0.3s ease;
}
.activity-item.system { border-color: var(--c-blue); }
.activity-item.alert { border-color: var(--c-red); background: rgba(239,68,68,0.05); }
.activity-item.success { border-color: var(--c-green); }
.activity-item.dispatch { border-color: var(--c-amber); }

.activity-time {
    font-family: var(--mono); font-size: 0.6rem; color: var(--c-text-dim);
    margin-bottom: 0.2rem; display: block;
}
.activity-msg {
    font-size: 0.7rem; color: var(--c-text); line-height: 1.4;
}
.activity-msg b { color: var(--c-blue); font-weight: 600; }

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}
