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

:root {
    --bg-color: #05070a;
    --accent-blue: #00d2ff;
    --accent-purple: #9d50bb;
    --primary-gradient: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    --glass-bg: rgba(22, 27, 34, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);

    --success: #00ff88;
    --warning: #ffcc00;
    --danger: #ff4d4d;

    --text-main: #e6edf3;
    --text-dim: #8b949e;
}

* {
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    background: radial-gradient(circle at top right, #1a2a44 0%, #05070a 100%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

header {
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.8rem;
    position: relative;
    overflow: hidden;
    grid-column: span 3;
    box-shadow: var(--glass-shadow);
}

.card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.9), 0 0 20px rgba(0, 210, 255, 0.1);
}

.card h2 {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-dim);
    margin-top: 0;
    margin-bottom: 1.2rem;
    display: flex;
    justify-content: space-between;
}

.card .value {
    font-size: 3rem;
    font-weight: 700;
    margin: 0.5rem 0;
    font-family: 'Outfit', sans-serif;
}

.value-unit {
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-left: 0.2rem;
}

.card .status {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
}

.status-dot::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.4;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }

    70% {
        transform: scale(2.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 0;
    }
}

.status-green {
    background: var(--success);
}

.status-yellow {
    background: var(--warning);
}

.status-red {
    background: var(--danger);
}

/* Global Footer */
footer {
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: blur(20px);
    padding: 1.5rem 3rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: auto;
}

.footer-stats {
    display: flex;
    gap: 2rem;
}

.footer-stats div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Collapsible Operations Panel */
#operations-panel {
    position: fixed;
    right: -360px;
    /* Hide off-screen by default */
    top: 5rem;
    width: 320px;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--glass-shadow);
    transition: right 0.3s ease;
    z-index: 1000;
}

#operations-panel.active {
    right: 1rem;
}

/* Mobile Operations Panel */
@media (max-width: 600px) {
    #operations-panel {
        width: 100%;
        right: -100%;
        top: 0;
        height: 100vh;
        border-radius: 0;
        padding-top: 5rem;
    }

    #operations-panel.active {
        right: 0;
    }
}

#operations-toggle {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

#operations-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    font-weight: 600;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    backdrop-filter: blur(4px);
}

.btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
}

.btn-danger {
    background: rgba(248, 81, 73, 0.2);
    color: #ff7b72;
    border: 1px solid #f85149;
}

.btn-success {
    background: rgba(35, 134, 54, 0.2);
    color: #7ee787;
    border: 1px solid #238636;
}

.btn-warning {
    background: rgba(210, 153, 34, 0.2);
    color: #d29922;
    border: 1px solid #d29922;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 0.8rem;
    }

    .card {
        grid-column: span 1 !important;
        /* Force single column stack */
        min-width: 0;
        /* Prevent overflow */
        backdrop-filter: none !important;
        /* PERFORMANCE: Disable blur on mobile to prevent crashes */
        -webkit-backdrop-filter: none !important;
        background: rgba(22, 27, 34, 0.95);
        /* Solid fallback */
    }

    #operations-panel {
        width: 100vw;
        /* Full width on mobile */
        max-width: none;
        padding-top: 3.5rem;
        /* Space for close button */
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: #0d1117;
    }

    header {
        backdrop-filter: none !important;
        background: #0d1117;
    }

    header h1 {
        font-size: 1.2rem;
    }
}

/* Responsive Overrides */
@media (max-width: 1200px) {
    .card {
        grid-column: span 4;
    }
}

@media (max-width: 900px) {
    .card {
        grid-column: span 6;
    }

    .dashboard-grid {
        padding: 1rem;
        gap: 1rem;
    }
}

@media (max-width: 600px) {
    .card {
        grid-column: span 12;
        /* Force full width on mobile */
    }

    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    /* Fix Footer on Mobile */
    footer {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
        padding: 1.5rem;
    }

    .footer-stats {
        flex-direction: column;
        gap: 0.8rem;
        width: 100%;
    }

    .footer-stats div {
        justify-content: center;
    }

    /* Fix Health Gauges on Mobile */
    #health-gauges {
        grid-template-columns: 1fr !important;
        /* Stack gauges vertically */
    }

    /* Adjust Chart Height */
    canvas#batteryChart {
        max-height: 200px;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: white;
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    padding: 0.8rem;
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}