:root {
    --bg-base: #060b13;
    --bg-surface: #0e1525;
    --bg-panel: rgba(20, 30, 48, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    
    --brand-primary: #00d2ff;
    --brand-secondary: #0077ff;
    
    --status-normal: #10b981; 
    --status-normal-bg: rgba(16, 185, 129, 0.1);
    
    --status-alert: #ef4444; 
    --status-alert-bg: rgba(239, 68, 68, 0.1);
    
    --status-offline: #64748b;
    --status-offline-bg: rgba(100, 116, 139, 0.1);
    
    --gradient-brand: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    
    --sidebar-w: 280px;
    --header-h: 70px;
    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-neon: 0 0 15px rgba(0, 210, 255, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    transition: all 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    margin-bottom: 40px;
}

.logo i {
    font-size: 32px;
    color: var(--brand-primary);
    text-shadow: var(--shadow-neon);
}

.logo span {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-muted);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-links li a i {
    font-size: 20px;
}

.nav-links li.active a,
.nav-links li a:hover {
    background: rgba(0, 210, 255, 0.05);
    color: var(--brand-primary);
}

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: radial-gradient(circle at top right, rgba(0, 119, 255, 0.05), transparent 50%),
                radial-gradient(circle at bottom left, rgba(0, 210, 255, 0.05), transparent 50%);
}

.topbar {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: rgba(14, 21, 37, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 8px 16px;
    width: 350px;
    gap: 10px;
    transition: all 0.3s;
}

.search-bar:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.1);
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    width: 100%;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--brand-primary);
}

/* Dashboard Grid */
.dashboard-grid {
    padding: 32px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.card {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.card h3 {
    font-size: 18px;
    font-weight: 600;
}

/* Env Params Grid */
.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 16px;
}

.param-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}

.param-item:hover {
    transform: translateY(-3px);
}

.param-name {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.param-value {
    font-size: 20px;
    font-weight: 700;
}

.param-unit {
    font-size: 12px;
    opacity: 0.7;
}

/* Status variants */
.status-normal {
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.1);
}
.status-normal .param-value { color: var(--status-normal); }

.status-alert {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
    animation: pulse-red 2s infinite;
}
.status-alert .param-value { color: var(--status-alert); }

.status-offline {
    border-color: rgba(100, 116, 139, 0.3);
    opacity: 0.6;
}
.status-offline .param-value { color: var(--status-offline); }

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Map */
.map-section {
    grid-column: span 1;
}
.map-container {
    height: 300px;
    border-radius: var(--radius-md);
    overflow: hidden;
    z-index: 1; /* For leaflet */
}

/* O2 & Flow Section */
.o2-flow {
    grid-column: span 1;
}
.o2-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.o2-modules {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}
.module-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}
.module-box .m-title {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.module-box .m-val {
    font-size: 14px;
    font-weight: 600;
    color: var(--brand-primary);
}

.total-capacity {
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.1), rgba(0, 119, 255, 0.1));
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}
.total-capacity h4 {
    color: var(--brand-primary);
    font-size: 14px;
    margin-bottom: 8px;
}
.capacity-value .gradient-text {
    font-size: 32px;
    font-weight: 700;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Chart */
.chart-section {
    grid-column: 1 / -1;
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chart-filters {
    display: flex;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 4px;
}
.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.filter-btn.active, .filter-btn:hover {
    background: var(--brand-secondary);
    color: #fff;
}
.chart-container {
    height: 300px;
    width: 100%;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.modal.active {
    display: flex;
}
.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 600px;
    max-width: 90%;
    /* Add animation */
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { font-size: 18px; }
.close-btn {
    cursor: pointer;
    font-size: 24px;
    color: var(--text-muted);
}
.close-btn:hover { color: #fff; }

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 14px;
}
.input-row {
    display: flex;
    gap: 12px;
}
.input-row input {
    flex: 1;
}

input[type="number"], input[type="text"] {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
    color: #fff;
    outline: none;
    font-size: 14px;
    transition: all 0.2s;
}
input[type="number"]:focus, input[type="text"]:focus {
    border-color: var(--brand-primary);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}
.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.btn-secondary:hover { background: rgba(255,255,255,0.2); }

.btn-primary {
    background: var(--brand-secondary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--brand-primary);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.4);
}

/* Animations fade-in */
.fade-in {
    opacity: 0;
    animation: fadeIn 0.6s ease forwards;
}
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }

@keyframes fadeIn {
    to { opacity: 1; }
}

@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}
