@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-primary: #050b14;
    --glass-bg: rgba(10, 20, 38, 0.55);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-glow: rgba(0, 245, 255, 0.15);
    --text-primary: #f8f9fa;
    --text-muted: #8ecae6;

    /* State colors */
    --color-safe: #39ff14;
    --color-evac: #ffaa00;
    --color-swim: #00f5ff;
    --color-trap: #ff003c;

    --shadow-premium: 0 12px 40px 0 rgba(0, 0, 0, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Glassmorphism Panel Base */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-premium);
    z-index: 10;
    pointer-events: auto;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 16px 48px 0 rgba(0, 0, 0, 0.7), 0 0 20px var(--glass-glow);
}

/* Left HUD Dashboard */
#dashboard {
    position: absolute;
    top: 24px;
    left: 24px;
    width: 340px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

#dashboard::-webkit-scrollbar {
    width: 6px;
}

#dashboard::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Merged control section in dashboard */
.control-section {
    display: flex;
    flex-direction: column;
    gap: 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 20px;
    margin-top: 5px;
}

header h1 {
    font-size: 22px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    background: linear-gradient(135deg, #00f5ff, #0077b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

header p {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Grid Info Display */
.info-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0;
}

.metric-label {
    font-size: 13px;
    color: var(--text-muted);
}

.metric-value {
    font-size: 15px;
    font-weight: 600;
}

/* State Badge */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px currentColor;
}

/* Color codes for states */
.status-safe {
    background: rgba(57, 255, 20, 0.15);
    color: var(--color-safe);
    border: 1px solid rgba(57, 255, 20, 0.3);
}

.status-evac {
    background: rgba(255, 170, 0, 0.15);
    color: var(--color-evac);
    border: 1px solid rgba(255, 170, 0, 0.3);
}

.status-swim {
    background: rgba(0, 245, 255, 0.15);
    color: var(--color-swim);
    border: 1px solid rgba(0, 245, 255, 0.3);
}

.status-trap {
    background: rgba(255, 0, 60, 0.15);
    color: var(--color-trap);
    border: 1px solid rgba(255, 0, 60, 0.3);
    animation: pulse-border 1.5s infinite alternate;
}

@keyframes pulse-border {
    from {
        border-color: rgba(255, 0, 60, 0.3);
        box-shadow: 0 0 4px rgba(255, 0, 60, 0.2);
    }

    to {
        border-color: rgba(255, 0, 60, 0.8);
        box-shadow: 0 0 12px rgba(255, 0, 60, 0.5);
    }
}

/* Monospaced Log Console */
.log-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.log-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.log-console {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
    height: 120px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.5;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.log-console::-webkit-scrollbar {
    width: 4px;
}

.log-console::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.log-entry {
    color: #cbd5e1;
    word-break: break-word;
    border-left: 2px solid rgba(0, 245, 255, 0.4);
    padding-left: 6px;
}

/* Control Panel (Deprecated, controls moved inside dashboard) */

.control-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Beautiful custom toggle switch */
.switch-container {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

input:checked+.slider {
    background-color: #00b4d8;
    box-shadow: 0 0 10px rgba(0, 180, 216, 0.5);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Speed multiplier layout */
.speed-slider-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.speed-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.speed-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

.speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #00f5ff;
    cursor: pointer;
    box-shadow: 0 0 8px #00f5ff;
}

/* Action button */
.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.4), rgba(0, 119, 182, 0.4));
    border: 1px solid rgba(0, 245, 255, 0.3);
    border-radius: 8px;
    color: white;
    padding: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.6), rgba(0, 119, 182, 0.6));
    border-color: rgba(0, 245, 255, 0.6);
    box-shadow: 0 0 15px rgba(0, 245, 255, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(1px);
}

/* Depth Gauge Slider (Right Floating) */
#depth-gauge-container {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    height: auto;
    width: 140px;
}

.gauge-label {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    margin-bottom: 2px;
}

.gauge-row-wrap {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.gauge-slider-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 280px;
}

/* Cross-browser vertical slider styling */
.water-level-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 8px;
    height: 280px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    outline: none;
    border: 1px solid rgba(255, 255, 255, 0.05);
    writing-mode: vertical-lr;
    /* Vertically align natively */
    direction: rtl;
    /* Drag up increases value */
    cursor: pointer;
}

.water-level-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #00f5ff;
    box-shadow: 0 0 8px #00f5ff, 0 0 16px rgba(0, 245, 255, 0.5);
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.2s;
}

.water-level-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    background: #ffffff;
}

.water-level-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: #00f5ff;
    box-shadow: 0 0 8px #00f5ff, 0 0 16px rgba(0, 245, 255, 0.5);
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.2s;
}

.water-level-slider::-moz-range-thumb:hover {
    transform: scale(1.25);
    background: #ffffff;
}

/* Ruler Scale labels on the left of the slider */
.gauge-ruler {
    height: 280px;
    /* Must match the slider height exactly! */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 0px;
}

.ruler-mark {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ruler-tick {
    width: 6px;
    height: 1px;
    background: rgba(255, 255, 255, 0.25);
}

.ruler-mark.major .ruler-tick {
    width: 12px;
    background: #00f5ff;
    box-shadow: 0 0 4px #00f5ff;
}

.gauge-switch-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin-top: 4px;
}

.gauge-switch-wrap .switch-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}


/* Hover tooltips or info hints */
.instructions-hint {
    position: absolute;
    bottom: 24px;
    right: 24px;
    padding: 12px 18px;
    font-size: 12px;
    color: var(--text-muted);
    max-width: 280px;
    text-align: right;
    pointer-events: none;
}

/* Orbit Controls instruction badge */
.instructions-hint strong {
    color: #f8f9fa;
}

@media(max-height: 700px) {
    #dashboard {
        top: 12px;
        left: 12px;
        padding: 16px;
        width: 300px;
        gap: 12px;
        max-height: calc(100vh - 24px);
    }

    #depth-gauge-container {
        right: 12px;
        height: auto;
        padding: 16px 12px;
    }

    .water-level-slider {
        height: 220px;
    }

    .gauge-ruler {
        height: 220px;
    }

    .gauge-slider-wrap {
        height: 220px;
    }
}

/* Stats Progress Bars */
.bar-container {
    position: relative;
    width: 140px;
    height: 16px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.2s ease, background-color 0.3s ease;
}

.hunger-fill {
    background: linear-gradient(90deg, #d62828, #f77f00);
    box-shadow: 0 0 8px rgba(247, 127, 0, 0.4);
}

.stamina-fill {
    background: linear-gradient(90deg, #fcbf49, #06d6a0);
    box-shadow: 0 0 8px rgba(6, 214, 160, 0.4);
}

.bar-text {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Multi-Agent Sidebar & Windows */
#agents-panel-container {
    position: absolute;
    right: 190px;
    top: 24px;
    width: 280px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 10;
    pointer-events: auto;
    scrollbar-width: none;
    /* Hide standard Firefox scrollbar */
}

#agents-panel-container::-webkit-scrollbar {
    display: none;
    /* Hide Chrome/Safari scrollbar */
}

.agent-card {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.agent-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.agent-id {
    font-weight: 700;
    font-size: 16px;
    background: linear-gradient(135deg, #00f5ff, #8ecae6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.agent-card-mini-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 8px;
}

.mini-metric {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.mini-label {
    font-size: 11px;
    color: var(--text-muted);
    width: 30px;
}

.mini-bar-container {
    flex-grow: 1;
    height: 6px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.mini-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.2s ease, background-color 0.3s ease;
}

.mini-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    width: 32px;
    text-align: right;
}

.agent-card-inventory {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-primary);
    gap: 4px;
}

.inv-item {
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.inv-pos {
    width: 100%;
    margin-top: 2px;
    color: #a0c4ff;
    font-size: 11px;
}

.agent-card-toggle-btn {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    background: rgba(0, 245, 255, 0.05);
    border: 1px dashed rgba(0, 245, 255, 0.15);
    transition: all 0.2s ease;
}

.agent-card-toggle-btn:hover {
    background: rgba(0, 245, 255, 0.12);
    color: var(--text-primary);
    border-style: solid;
}

.agent-card-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 8px;
    transition: max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    overflow: hidden;
    max-height: 240px;
    /* high enough for expanded state */
    opacity: 1;
}

.agent-card-details.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    border-top: none;
    pointer-events: none;
}

.action-highlight {
    font-weight: 600;
    color: #00f5ff;
}

.agent-details-row {
    font-size: 12px;
}

.agent-details-log-title {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    margin-top: 4px;
    text-transform: uppercase;
}

.agent-details-log-console {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px;
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.agent-details-log-console::-webkit-scrollbar {
    width: 4px;
}

.agent-details-log-console::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}