/* Base styles & Colors */
:root {
    --bg-dark: #0f111a;
    --bg-card: rgba(26, 29, 46, 0.65);
    --bg-sidebar: rgba(18, 20, 33, 0.95);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.35);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.3);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.45);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.3);
    
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 20%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex-shrink: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo {
    font-size: 2rem;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary-glow);
}

.brand h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.brand h2 span {
    color: var(--primary);
}

/* Connection Status Card */
.connection-status-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.status-indicator.connected {
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success-glow);
}

.status-indicator.disconnected {
    background-color: var(--danger);
    box-shadow: 0 0 10px var(--danger-glow);
}

.status-indicator::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0.4;
    animation: ripple 2s infinite ease-out;
}

.status-info {
    display: flex;
    flex-direction: column;
}

.status-info span {
    font-weight: 600;
    font-size: 0.9rem;
}

.status-info small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* IP Input Form */
.ip-config-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ip-config-container label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ip-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.ip-input-wrapper input {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.3s;
}

.ip-input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.ip-input-wrapper button {
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: white;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
}

.ip-input-wrapper button:hover {
    background: #2563eb;
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Navigation Menu */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s;
}

.nav-menu a:hover, .nav-menu a.active {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.nav-menu a.active {
    border-left: 3px solid var(--primary);
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, transparent 100%);
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: center;
}

/* Main Content area */
.main-content {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: calc(100% - 280px);
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.header-title h1 {
    font-size: 1.8rem;
    font-weight: 800;
}

.header-title p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.quick-stats {
    display: flex;
    gap: 1.5rem;
}

.header-stat {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.header-stat .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.header-stat .value {
    font-size: 1.1rem;
    font-weight: 700;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* Dashboard Cards Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

.span-2 {
    grid-column: span 2;
}

.span-3 {
    grid-column: span 3;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h3 i {
    color: var(--primary);
}

.badge-container {
    display: flex;
    gap: 0.5rem;
}

.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

/* Live Parking Layout (SCADA Map) */
.parking-layout {
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2rem 1.5rem;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 250px;
    margin-bottom: 1rem;
}

/* Turnstile gates styling */
.entrance-gate, .exit-gate {
    width: 90px;
    height: 100px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    background: rgba(255, 255, 255, 0.02);
}

.gate-barricade {
    position: absolute;
    width: 60px;
    height: 6px;
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger-glow);
    border-radius: 3px;
    top: 50%;
    left: 15px;
    transform-origin: left center;
    transform: rotate(0deg);
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.5s;
}

.gate-barricade.open {
    transform: rotate(-90deg);
    background: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
}

.gate-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 10px;
    font-weight: 600;
}

.approach-warning {
    position: absolute;
    top: -30px;
    background: var(--warning);
    color: black;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    animation: flash 1s infinite alternate;
}

/* Parking Slots Grid */
.parking-slots-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    flex-grow: 1;
    margin: 0 2rem;
}

.parking-slot {
    height: 150px;
    border-top: none;
    border-bottom: none;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.5s ease;
    border-radius: 8px;
}

.slot-line {
    position: absolute;
    width: 3px;
    height: 100%;
    background: rgba(255, 255, 255, 0.15);
    top: 0;
}

.slot-line.left { left: 0; }
.slot-line.right { right: 0; }

.slot-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 1;
}

.car-icon {
    font-size: 2.5rem;
    opacity: 0.1;
    transform: translateY(10px);
    transition: all 0.6s cubic-bezier(0.68, -0.6, 0.32, 1.6);
}

.slot-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.slot-status {
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* Occupied Slot Styles */
.parking-slot.occupied {
    background: rgba(239, 68, 68, 0.05);
}

.parking-slot.occupied .slot-line {
    background: rgba(239, 68, 68, 0.3);
}

.parking-slot.occupied .car-icon {
    color: var(--danger);
    opacity: 1;
    transform: translateY(0) scale(1.1);
    filter: drop-shadow(0 5px 10px rgba(239, 68, 68, 0.3));
}

.parking-slot.occupied .slot-name {
    color: white;
}

.parking-slot.occupied .slot-status {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

/* Empty Slot Styles */
.parking-slot.empty {
    background: rgba(16, 185, 129, 0.03);
}

.parking-slot.empty .slot-line {
    background: rgba(16, 185, 129, 0.2);
}

.parking-slot.empty .car-icon {
    transform: translateY(20px);
}

.parking-slot.empty .slot-status {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

/* Safety Controls and LED Bar */
.parking-controls-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.occupancy-bar-section {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.section-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.led-bar-graph {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.led-segment {
    width: 8px;
    height: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    transition: all 0.3s;
}

/* LED Graph Coloring Rules (1 to 10) */
/* Green logic for low occupancy */
.led-segment.active-low {
    background: var(--success);
    box-shadow: 0 0 6px var(--success-glow);
}
/* Orange logic for mid occupancy */
.led-segment.active-mid {
    background: var(--warning);
    box-shadow: 0 0 6px var(--warning-glow);
}
/* Red logic for high occupancy */
.led-segment.active-high {
    background: var(--danger);
    box-shadow: 0 0 6px var(--danger-glow);
}

#led-percent {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Warnings and Indicators */
.ultrasonic-warning-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid var(--warning);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--warning);
}

.pulse-warn {
    font-size: 1.2rem;
    animation: flash 0.8s infinite alternate;
}

/* Environmental Gauges */
.gauge-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.gauge-card {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.gauge-card i {
    font-size: 1.8rem;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
}

.temp-color { color: #f43f5e; }
.humidity-color { color: #06b6d4; }
.pressure-color { color: #a855f7; }
.altitude-color { color: #e2e8f0; }

.gauge-info {
    display: flex;
    flex-direction: column;
}

.gauge-value {
    font-size: 1.4rem;
    font-weight: 700;
}

.gauge-unit {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.gauge-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
    font-weight: 500;
}

/* Safety & Control Panel */
.safety-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.safety-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.4s;
}

.safety-icon-wrapper {
    font-size: 1.4rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
}

.safety-text h4 {
    font-size: 0.9rem;
    font-weight: 600;
}

.safety-text p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Security States styling */
.status-ok {
    background: rgba(16, 185, 129, 0.03);
    border-color: rgba(16, 185, 129, 0.2);
}
.status-ok .safety-icon-wrapper {
    color: var(--success);
}

.status-alarm {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.4);
    animation: pulse-border 1.5s infinite;
}
.status-alarm .safety-icon-wrapper {
    color: var(--danger);
    animation: flash 0.5s infinite alternate;
}

.path-lights-status {
    margin-top: 5px;
}

.text-on {
    color: var(--warning);
    text-shadow: 0 0 5px var(--warning-glow);
}
.text-off {
    color: var(--text-secondary);
}

.manual-trigger-box {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.box-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

.btn {
    flex-grow: 1;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.5rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 0 10px var(--primary-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-sm:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* RFID Log Table */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.log-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.log-table th, .log-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.log-table th {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
    color: var(--text-secondary);
}

.log-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

.empty-row td {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.log-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.log-in { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.log-out { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

/* Fire Alarm Overlay screen */
.emergency-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(239, 68, 68, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

.emergency-overlay.hidden {
    display: none;
}

.emergency-content {
    background: var(--bg-dark);
    border: 3px solid var(--danger);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    max-width: 500px;
    width: 90%;
    animation: scale-up 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pulse-icon {
    font-size: 4.5rem;
    color: var(--danger);
    animation: flash 0.4s infinite alternate;
    margin-bottom: 1.5rem;
}

.emergency-content h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: 2px;
}

.emergency-content p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.water-pump-status {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    border-radius: 8px;
    padding: 0.75rem;
    font-weight: 700;
    color: var(--success);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.water-drop {
    animation: drop-bounce 1s infinite alternate;
}

.btn-dismiss {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 2rem;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-dismiss:hover {
    background: #dc2626;
    box-shadow: 0 0 15px rgba(239,68,68,0.5);
}

/* Animations */
@keyframes ripple {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(2.2); opacity: 0; }
}

@keyframes flash {
    0% { opacity: 0.3; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1.05); }
}

@keyframes drop-bounce {
    0% { transform: translateY(-3px); }
    100% { transform: translateY(3px); }
}

@keyframes pulse-border {
    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); }
}

@keyframes scale-up {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1.5rem;
    }
    .main-content {
        width: 100%;
        padding: 1.5rem;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .span-2, .span-3 {
        grid-column: span 1;
    }
    .parking-slots-grid {
        grid-template-columns: repeat(2, 1fr);
        margin: 1rem 0;
    }
    .parking-layout {
        flex-direction: column;
        gap: 1.5rem;
    }
}
