:root {
    --bg-dark: #020617;
    --bg-panel: rgba(15, 23, 42, 0.85);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --accent-cyan: #06b6d4;
    --accent-red: #ef4444;
    --accent-green: #22c55e;
    --accent: #06b6d4;
    /* Alias for inline styles */
    --border-color: rgba(148, 163, 184, 0.2);
    --glass: rgba(15, 23, 42, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* --- Header --- */
.top-bar {
    height: 64px;
    background-color: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.unit-info {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: 0.05em;
    text-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-green);
    background: rgba(34, 197, 94, 0.1);
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Main Content --- */
.main-view {
    flex: 1;
    position: relative;
    background: #0f172a;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Custom Leaflet Marker Wrapper */
.custom-div-icon {
    background: transparent;
    border: none;
}

/* --- Mission Panel --- */
.mission-panel {
    position: absolute;
    bottom: 24px;
    left: 24px;
    right: 24px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    z-index: 999;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    max-width: 480px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.mission-panel:not(.active) {
    display: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.panel-header h2 {
    font-size: 1rem;
    color: var(--accent-cyan);
    margin: 0;
    letter-spacing: 0.1em;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}

.priority-badge {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    border: 1px solid rgba(239, 68, 68, 0.3);
    letter-spacing: 0.05em;
    animation: alert-pulse 2s infinite;
}

@keyframes alert-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.mission-details {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.detail-row .value {
    font-size: 1rem;
    font-weight: 500;
    color: white;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

/* --- Buttons --- */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.action-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.action-btn:active {
    transform: scale(0.96);
}

.action-btn.primary {
    background: var(--accent-cyan);
    color: #000;
    border: none;
    box-shadow: 0 4px 15px -3px rgba(6, 182, 212, 0.4);
}

.action-btn.warning {
    background: var(--accent-green);
    color: #000;
    border: none;
    box-shadow: 0 4px 15px -3px rgba(34, 197, 94, 0.4);
}

/* --- Chat Overlay --- */
.chat-overlay {
    position: absolute;
    top: 80px;
    right: 24px;
    width: 380px;
    height: 500px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.chat-overlay.hidden {
    transform: translateX(20px);
    opacity: 0;
    pointer-events: none;
}

.chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.chat-header h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--accent-cyan);
    letter-spacing: 1px;
    font-weight: 700;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    max-width: 85%;
    line-height: 1.4;
}

.msg.sent {
    align-self: flex-end;
    background: var(--accent-cyan);
    color: #0f172a;
    border-bottom-right-radius: 2px;
    font-weight: 500;
}

.msg.received {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.chat-input {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.chat-input input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    color: white;
    outline: none;
    font-family: inherit;
}

.chat-input button {
    background: var(--accent-cyan);
    border: none;
    border-radius: 8px;
    width: 48px;
    cursor: pointer;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
}