/* ============================================================
   assets/css/main.css  – MeterLog Pro Stylesheet
   Design: Industrial / Utility with accent energy theme
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --primary:       #0f62fe;
    --primary-dark:  #0043ce;
    --primary-light: #d0e2ff;
    --accent:        #f1c21b;
    --accent-dark:   #c09000;
    --danger:        #da1e28;
    --success:       #198038;
    --warning:       #f1c21b;
    --info:          #0072c3;

    --bg-page:       #f4f6fb;
    --bg-card:       #ffffff;
    --bg-sidebar:    #161616;
    --text-primary:  #161616;
    --text-muted:    #6f6f6f;
    --border:        #e0e0e0;

    --sidebar-width: 260px;
    --topbar-height: 60px;

    --font-body:  'Plus Jakarta Sans', sans-serif;
    --font-mono:  'JetBrains Mono', monospace;

    --shadow-sm:  0 1px 4px rgba(0,0,0,.06);
    --shadow-md:  0 4px 16px rgba(0,0,0,.1);
    --shadow-lg:  0 8px 32px rgba(0,0,0,.14);
    --radius:     10px;
    --radius-sm:  6px;
}

/* ── Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: var(--font-body);
    font-size: 14px;
    background: var(--bg-page);
    color: var(--text-primary);
}

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }

/* ── Layout Shell ───────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #f4f4f4;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    font-size: 17px;
    font-weight: 800;
    border-bottom: 1px solid #2a2a2a;
    letter-spacing: -.3px;
    flex-shrink: 0;
}

.sidebar-nav {
    list-style: none;
    margin: 8px 0;
    padding: 0;
    flex: 1;
}

.sidebar-nav .nav-section {
    padding: 14px 20px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: #525252;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: #c6c6c6;
    text-decoration: none;
    border-radius: 0;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .18s, color .18s, padding-left .18s;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    background: #232323;
    color: #fff;
    padding-left: 24px;
}

.sidebar-nav .nav-link.active {
    background: #232323;
    color: #fff;
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-user {
    padding: 16px 16px;
    border-top: 1px solid #2a2a2a;
    flex-shrink: 0;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .3s cubic-bezier(.4,0,.2,1);
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 16px;
    font-weight: 700;
    flex: 1;
}

.btn-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 8px;
}

/* ── Page Content ───────────────────────────────────────────── */
.page-content {
    padding: 24px;
    flex: 1;
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 22px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -.4px;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 20px; }

/* Stat cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s, transform .2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--stat-color, var(--primary));
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--stat-color, var(--primary)) 12%, white);
    color: var(--stat-color, var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 14px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    font-family: var(--font-mono);
    letter-spacing: -1px;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table {
    font-size: 13px;
}

.table thead th {
    background: #f8f9fc;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    padding: 10px 14px;
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
    border-color: var(--border);
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.table tbody tr:hover td {
    background: #f8f9fc;
}

.table-responsive {
    border-radius: var(--radius);
    overflow: auto;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-label {
    font-weight: 600;
    font-size: 12.5px;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.form-control, .form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15,98,254,.15);
}

/* Previous reading hint */
.prev-reading-badge {
    font-size: 11px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    font-weight: 600;
    font-size: 13.5px;
    border-radius: var(--radius-sm);
    transition: all .18s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge-module {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
}

.badge-common   { background: #ddf4ff; color: #0072c3; }
.badge-tristaar { background: #fff8e1; color: #c09000; }
.badge-ansal    { background: #fef3c7; color: #92400e; }

/* ── Login Page ─────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1923 0%, #162032 60%, #0f62fe22 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 8px;
}

.login-logo i {
    font-size: 32px;
    color: var(--accent);
}

.login-logo span {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.5px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 28px;
}

/* ── Meter Entry ────────────────────────────────────────────── */
.meter-grid {
    display: grid;
    gap: 16px;
}

.meter-row-card {
    background: #f8f9fc;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.meter-label {
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* ── Toast Container ────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

/* ── Spinner overlay ────────────────────────────────────────── */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .btn-sidebar-toggle {
        display: block;
    }

    .page-content {
        padding: 16px;
    }

    .stat-card .stat-value {
        font-size: 22px;
    }
}

@media (max-width: 575.98px) {
    .login-card {
        padding: 28px 20px;
    }

    .page-title {
        font-size: 18px;
    }
}

/* ── Utilities ──────────────────────────────────────────────── */
.text-mono { font-family: var(--font-mono); }
.transition { transition: all .2s; }
.cursor-pointer { cursor: pointer; }

/* Module indicator strip */
.module-strip {
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    margin-bottom: 0;
}

/* History month pill */
.month-pill {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 12px;
    font-weight: 700;
}

/* Delete / action confirm modal */
.modal-confirm .modal-header {
    background: var(--danger);
    color: #fff;
    border: none;
}

/* Admin table row hover */
.admin-table tbody tr { cursor: default; }

/* Loading placeholder shimmer */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 4px;
}
