/* =========================================================
   xVoltIQ - Main Stylesheet
   Dark energy-management theme
   ========================================================= */

:root {
    --bg-base:    #0f172a;
    --bg-card:    #1e293b;
    --bg-card2:   #162032;
    --border:     #2d3f55;
    --accent:     #38bdf8;
    --accent2:    #0ea5e9;
    --green:      #4ade80;
    --yellow:     #facc15;
    --orange:     #f97316;
    --red:        #ef4444;
    --text:       #e2e8f0;
    --muted:      #94a3b8;
    --sidebar-w:  240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background: var(--bg-base);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.xv-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .25s ease;
}

.xv-sidebar .brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.xv-sidebar .brand img { height: 38px; }

.xv-nav { flex: 1; overflow-y: auto; padding: 12px 0; }

.xv-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .15s;
}

.xv-nav a:hover,
.xv-nav a.active {
    color: var(--accent);
    background: rgba(56,189,248,.08);
    border-left-color: var(--accent);
}

.xv-nav .nav-section {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    color: var(--border);
    padding: 14px 20px 6px;
    text-transform: uppercase;
}

.xv-sidebar .sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--muted);
}

/* ── TOPBAR ──────────────────────────────────────────────── */
.xv-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 900;
}

.xv-topbar .page-title { font-size: 18px; font-weight: 600; }

.xv-topbar .topbar-right { display: flex; align-items: center; gap: 16px; }

.btn-icon {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 20px;
    position: relative;
    padding: 4px;
    transition: color .15s;
}

.btn-icon:hover { color: var(--accent); }

.badge-dot {
    position: absolute;
    top: 2px; right: 2px;
    width: 8px; height: 8px;
    background: var(--red);
    border-radius: 50%;
}

/* ── MAIN CONTENT ────────────────────────────────────────── */
.xv-main {
    margin-left: var(--sidebar-w);
    padding-top: 60px;
    min-height: 100vh;
}

.xv-content { padding: 28px 28px; }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.card-unit { font-size: 14px; color: var(--muted); margin-left: 4px; }

/* ── GAUGE ───────────────────────────────────────────────── */
.gauge-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.gauge-label { position: absolute; text-align: center; }
.gauge-label .g-val { font-size: 22px; font-weight: 700; }
.gauge-label .g-unit { font-size: 11px; color: var(--muted); }

/* ── PROGRESS BAR ────────────────────────────────────────── */
.xv-progress { background: var(--bg-base); border-radius: 99px; height: 10px; overflow: hidden; }
.xv-progress-bar {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), var(--green));
    transition: width .5s ease;
}
.xv-progress-bar.warn  { background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.xv-progress-bar.danger{ background: linear-gradient(90deg, var(--orange), var(--red)); }

/* ── SOURCE STATUS BADGE ─────────────────────────────────── */
.src-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
}
.src-badge.active  { background: rgba(74,222,128,.15); color: var(--green);  border: 1px solid var(--green); }
.src-badge.standby { background: rgba(56,189,248,.10); color: var(--accent); border: 1px solid var(--accent); }
.src-badge.offline { background: rgba(148,163,184,.1); color: var(--muted);  border: 1px solid var(--border); }
.src-badge .dot { width:8px; height:8px; border-radius:50%; background:currentColor; }
.src-badge.active .dot { animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%,100% { opacity:1; transform:scale(1); }
    50%      { opacity:.5; transform:scale(.8); }
}

/* ── FORMS ───────────────────────────────────────────────── */
.xv-form .form-group { margin-bottom: 18px; }
.xv-form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.xv-form input[type=text],
.xv-form input[type=email],
.xv-form input[type=password],
.xv-form input[type=number],
.xv-form select,
.xv-form textarea {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    transition: border-color .15s;
}

.xv-form input:focus,
.xv-form select:focus,
.xv-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56,189,248,.12);
}

.xv-form select option { background: var(--bg-card); }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn-primary {
    background: var(--accent);
    color: #0f172a;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--accent2); }
.btn-primary:active { transform: scale(.98); }

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px 24px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
}
.btn-outline:hover { background: rgba(56,189,248,.1); }

.btn-danger {
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ── TABLE ───────────────────────────────────────────────── */
.xv-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.xv-table th {
    text-align: left;
    padding: 10px 14px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border);
}
.xv-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.xv-table tr:last-child td { border-bottom: none; }
.xv-table tr:hover td { background: rgba(56,189,248,.04); }

/* ── ALERTS PANEL ────────────────────────────────────────── */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.alert-item:last-child { border-bottom: none; }
.alert-icon { font-size: 20px; margin-top: 2px; }
.alert-text { font-size: 13px; line-height: 1.5; }
.alert-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── AUTH PAGES ──────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 0%, rgba(56,189,248,.12) 0%, transparent 70%),
                var(--bg-base);
    padding: 24px;
}

.auth-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 5px;
    background-color: white;
    border-radius: 10px;
}
.auth-logo img { height: 100px; }
.auth-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.auth-sub { font-size: 14px; color: var(--muted); text-align: center; margin-bottom: 28px; }

.form-msg { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.form-msg.error   { background: rgba(239,68,68,.12);   color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.form-msg.success { background: rgba(74,222,128,.12);  color: #86efac; border: 1px solid rgba(74,222,128,.3); }
.form-msg.info    { background: rgba(56,189,248,.12);  color: var(--accent); border: 1px solid rgba(56,189,248,.3); }

/* ── REAL-TIME INDICATOR ─────────────────────────────────── */
.live-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 1.5s infinite;
    margin-right: 6px;
}

/* ── GRID HELPERS ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; }
.grid-6 { display: grid; grid-template-columns: repeat(6,1fr); gap: 20px; }

/* ── UTILITIES ───────────────────────────────────────────── */
.mt-0  { margin-top:0; }
.mt-1  { margin-top:8px; }
.mt-2  { margin-top:16px; }
.mt-3  { margin-top:24px; }
.mb-1  { margin-bottom:8px; }
.mb-2  { margin-bottom:16px; }
.mb-3  { margin-bottom:24px; }
.text-muted  { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red    { color: var(--red); }
.text-orange { color: var(--orange); }
.text-right  { text-align:right; }
.text-center { text-align:center; }
.fw-bold     { font-weight:700; }
.fs-sm       { font-size:12px; }
.fs-lg       { font-size:18px; }
.d-flex      { display:flex; }
.align-center{ align-items:center; }
.gap-2       { gap:16px; }
.flex-1      { flex:1; }
.w-full      { width:100%; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
.hamburger { display: none; background: none; border: none; color: var(--text); font-size: 22px; cursor: pointer; }

@media (max-width: 900px) {
    :root { --sidebar-w: 0px; }
    .xv-sidebar { transform: translateX(-240px); width: 240px; }
    .xv-sidebar.open { transform: translateX(0); }
    .xv-topbar { left: 0; }
    .xv-main { margin-left: 0; }
    .hamburger { display: block; }
    .grid-4 { grid-template-columns: repeat(2,1fr); }
    .grid-6 { grid-template-columns: repeat(3,1fr); }
    .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .xv-content { padding: 16px; }
    .grid-2, .grid-4, .grid-6 { grid-template-columns: 1fr; }
    .auth-box { padding: 28px 20px; }
}
