/* ==================== THEME VARIABLES ==================== */
:root {
    /* LIGHT MODE (Default fallback, but we start in dark mode via HTML attribute) */
    --bg-base: #f3f4f6;
    --bg-panel: #ffffff;
    --bg-panel-hover: #f9fafb;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    
    --cyan: #0284c7;
    --cyan-dim: rgba(2, 132, 199, 0.1);
    --green: #16a34a;
    --green-dim: rgba(22, 163, 74, 0.1);
    --red: #dc2626;
    --red-dim: rgba(220, 38, 38, 0.1);
    --purple: #7c3aed;
    --purple-dim: rgba(124, 58, 237, 0.1);
    --yellow: #ca8a04;
    
    --glow-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --sidebar-bg: #f9fafb;
}[data-theme="dark"] {
    /* DARK MODE (Posh Tech/Cyber look) */
    --bg-base: #060b14;
    --bg-panel: #0d1522;
    --bg-panel-hover: #131d2e;
    --text-main: #f1f5f9;
    --text-muted: #64748b;
    --border: #1e293b;
    
    --cyan: #00e5ff;
    --cyan-dim: rgba(0, 229, 255, 0.1);
    --green: #00ff66;
    --green-dim: rgba(0, 255, 102, 0.1);
    --red: #ff3366;
    --red-dim: rgba(255, 51, 102, 0.1);
    --purple: #b366ff;
    --purple-dim: rgba(179, 102, 255, 0.1);
    --yellow: #ffcc00;

    --glow-shadow: 0 0 15px rgba(0, 229, 255, 0.05);
    --sidebar-bg: #090e17;
}

/* ==================== GLOBAL STYLES ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; transition: background-color 0.3s, border-color 0.3s; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.tech-font { font-family: 'JetBrains Mono', Consolas, monospace; }
.text-cyan { color: var(--cyan); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-purple { color: var(--purple); }
.text-yellow { color: var(--yellow); }
.text-muted { color: var(--text-muted); }

.bg-cyan-dim { background-color: var(--cyan-dim); }
.bg-green-dim { background-color: var(--green-dim); }
.bg-purple-dim { background-color: var(--purple-dim); }

.border-cyan { border: 1px solid var(--cyan) !important; }
.border-green { border: 1px solid var(--green) !important; }
.border-red { border: 1px solid var(--red) !important; }
.border-yellow { border: 1px solid var(--yellow) !important; }
.border-purple { border: 1px solid var(--purple) !important; }

.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

/* Utilities */
.view { display: none; flex: 1; }
.view.active { display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Buttons */
.btn {
    padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer;
    font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px;
    background: transparent; color: var(--text-main); transition: 0.2s;
}
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-cyan { background: var(--cyan); color: #000; font-weight: 700; }
.btn-cyan:hover { box-shadow: 0 0 15px var(--cyan-dim); transform: translateY(-1px); }
.btn-outline { border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-panel-hover); }
.btn-outline-cyan { border: 1px solid var(--cyan); color: var(--cyan); }
.btn-outline-cyan:hover { background: var(--cyan-dim); }
.btn-outline-danger { border: 1px solid var(--red); color: var(--red); }
.btn-outline-danger:hover { background: var(--red-dim); }
.badge { padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.bg-red { background: var(--red); color: #fff; }

.glow-border { border: 1px solid var(--border); box-shadow: var(--glow-shadow); background: var(--bg-panel); }
.glow-hover:hover { border-color: var(--cyan); box-shadow: 0 0 20px var(--cyan-dim); }

/* ==================== NAV & FOOTER ==================== */
.top-nav {
    background: var(--bg-panel); border-bottom: 1px solid var(--border);
    padding: 0 24px; height: 60px; display: flex; justify-content: space-between; align-items: center;
}
.nav-brand { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px;}
.logo-text { color: var(--red); letter-spacing: 1px; }
.divider { color: var(--border); font-weight: 300; }
.sub-text { font-size: 14px; color: var(--text-muted); font-weight: 400; }
.nav-actions { display: flex; align-items: center; gap: 20px; }
.theme-toggle { background: transparent; border: none; color: var(--cyan); font-size: 18px; cursor: pointer; }
.nav-user { display: flex; align-items: center; gap: 15px; border-left: 1px solid var(--border); padding-left: 15px; }
.user-info { display: flex; flex-direction: column; text-align: right; }
.user-name { font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-muted); }

.system-footer {
    background: var(--bg-panel); border-top: 1px solid var(--border);
    padding: 0 24px; height: 35px; display: flex; justify-content: space-between; align-items: center;
    font-size: 11px;
}

/* ==================== LOGIN VIEW ==================== */
.login-container { flex: 1; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at center, var(--bg-panel) 0%, var(--bg-base) 100%); }
.login-card { width: 100%; max-width: 420px; padding: 40px; border-radius: 8px; position: relative; overflow: hidden; }
.login-card::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 2px; background: linear-gradient(90deg, transparent, var(--cyan), transparent); }
.login-header { text-align: center; margin-bottom: 30px; }
.login-header h2 { font-size: 26px; margin-bottom: 8px; }
.login-header p { color: var(--text-muted); font-size: 12px; letter-spacing: 2px; }
.input-group { margin-bottom: 20px; }
.input-group label { display: block; margin-bottom: 8px; font-size: 11px; color: var(--text-muted); letter-spacing: 1px; }
.input-group input { width: 100%; padding: 12px; background: var(--bg-base); border: 1px solid var(--border); border-radius: 4px; color: var(--text-main); font-family: inherit; outline: none; }
.input-group input:focus { border-color: var(--cyan); box-shadow: inset 0 0 5px var(--cyan-dim); }
.login-footer { margin-top: 24px; text-align: center; font-size: 10px; }

/* ==================== DASHBOARD VIEW ==================== */
.container { max-width: 1200px; margin: 30px auto; padding: 0 20px; width: 100%; }
.dashboard-header-flex { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 40px; border-bottom: 1px solid var(--border); padding-bottom: 20px; }
.pulse-dot { display: inline-block; width: 8px; height: 8px; background: var(--cyan); border-radius: 50%; margin-right: 8px; box-shadow: 0 0 10px var(--cyan); animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.4; } 100% { opacity: 1; } }
.page-title { font-size: 12px; letter-spacing: 2px; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; }
.main-heading { font-size: 28px; font-weight: 700; }
.stats-pills { display: flex; gap: 15px; }
.stat-pill { border: 1px solid var(--border); padding: 8px 16px; border-radius: 20px; font-size: 11px; font-weight: 600; display: flex; gap: 10px; align-items: center; background: var(--bg-panel); }
.stat-pill span { font-size: 16px; }

.section-title { font-size: 13px; color: var(--text-muted); letter-spacing: 1px; margin-bottom: 15px; display: flex; align-items: center; gap: 8px; }
.module-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: all 0.2s ease; }
.module-card-left { display: flex; align-items: center; gap: 20px; }
.icon-box { width: 50px; height: 50px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.module-card-left h4 { font-size: 16px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.module-card-left p { font-size: 13px; color: var(--text-muted); }
.module-card-right { display: flex; gap: 30px; align-items: center; font-size: 12px; color: var(--text-muted); }
.module-card-right span { display: flex; flex-direction: column; text-align: center; gap: 4px; }
.module-card-right b { font-size: 18px; font-weight: normal; }
.icon-arrow { font-size: 18px; color: var(--text-muted); transition: 0.2s; }
.module-card:hover .icon-arrow { color: var(--cyan); transform: translateX(5px); }

/* ==================== MODULE DETAILS (ALARM SERVICE) ==================== */
.module-layout { display: flex; flex: 1; height: calc(100vh - 95px); }
.sidebar { width: 260px; background: var(--sidebar-bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
.sidebar-header h5 { font-size: 12px; color: var(--text-muted); letter-spacing: 2px; }
.sidebar-menu { list-style: none; flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar-menu li { padding: 12px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; border-left: 3px solid transparent; transition: 0.2s; }
.sidebar-menu li:hover { background: var(--bg-panel); }
.sidebar-menu li.active { background: var(--bg-panel); border-left-color: var(--cyan); }
.sidebar-menu li strong { display: block; font-size: 14px; font-weight: 500; color: var(--text-main); margin-bottom: 4px; }
.sidebar-menu li .sub-text { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.sidebar-menu li i { color: var(--text-muted); font-size: 12px; }
.sidebar-menu li.active i { color: var(--cyan); }
.sidebar-footer { padding: 20px; border-top: 1px solid var(--border); }

.main-content { flex: 1; padding: 30px; overflow-y: auto; background: var(--bg-base); }
.action-bar { display: flex; justify-content: space-between; margin-bottom: 20px; }
.module-data-header { padding: 25px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; }
.header-info h2 { font-size: 24px; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 1px; }
.header-info p { font-size: 12px; color: var(--text-muted); }
.header-stats { display: flex; gap: 15px; align-items: flex-end; }
.date-picker label { display: block; font-size: 10px; color: var(--text-muted); margin-bottom: 5px; }
.date-picker input { background: var(--bg-base); border: 1px solid var(--border); padding: 8px 12px; border-radius: 4px; color: var(--text-main); outline: none; }
.stat-box { width: 100px; height: 75px; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg-base); }
.stat-box h3 { font-size: 22px; margin-bottom: 5px; }
.stat-box span { font-size: 10px; color: var(--text-muted); letter-spacing: 1px; }

.empty-state { text-align: center; padding: 100px 0; }
.empty-state i { font-size: 40px; opacity: 0.2; }
.empty-state p { font-size: 13px; }

/* ==================== LIVE MONITOR VIEW ==================== */
.monitor-top-bar { background: var(--bg-panel); padding: 15px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.monitor-title h2 { font-size: 18px; }
.monitor-title p { font-size: 11px; margin-top: 4px; }
.monitor-controls { display: flex; gap: 15px; align-items: center; }
.pulse-indicator { border: 1px solid var(--border); padding: 5px 12px; border-radius: 20px; font-size: 11px; font-family: 'JetBrains Mono', monospace; display: flex; align-items: center; gap: 8px; }

.monitor-dashboard { padding: 24px; max-width: 1400px; margin: 0 auto; }
.monitor-stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; }
.monitor-stat-card { background: var(--bg-panel); padding: 20px; border-radius: 6px; border-top: 2px solid var(--border); box-shadow: var(--glow-shadow); }
.monitor-stat-card p { font-size: 10px; color: var(--text-muted); letter-spacing: 1px; margin-bottom: 10px; }
.monitor-stat-card h2 { font-size: 28px; margin-bottom: 5px; }
.monitor-stat-card span { font-size: 11px; color: var(--text-muted); }

.monitor-charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.chart-box { padding: 20px; border-radius: 6px; }
.chart-box h4 { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }

/* Mockup CSS for Charts */
.placeholder-chart { height: 200px; position: relative; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); }
.chart-grid { position: absolute; width: 100%; height: 100%; background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px); background-size: 40px 40px; opacity: 0.2; }
.chart-line { position: absolute; bottom: 20%; left: 0; width: 100%; height: 2px; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); transform: rotate(-5deg); transform-origin: left; }
.placeholder-donut { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 200px; }
.donut-circle { width: 120px; height: 120px; border-radius: 50%; border: 15px solid var(--border); border-top-color: var(--cyan); border-right-color: var(--green); transform: rotate(45deg); }
.donut-legend { font-size: 11px; display: flex; gap: 15px; }