/* ============================================================
   EMRS — Electricity Meter Reading System
   Main Stylesheet (Mobile-First)
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --erp-sidebar-width:  260px;
    --erp-topbar-height:  56px;
    --erp-primary:        #1a237e;
    --erp-primary-dark:   #0d1757;
    --erp-primary-light:  #e8eaf6;
    --erp-accent:         #5c6bc0;
    --erp-success:        #2e7d32;
    --erp-bg:             #f0f2f8;
    --erp-surface:        #ffffff;
    --erp-text:           #2d3748;
    --erp-text-muted:     #718096;
    --erp-border:         #e2e8f0;
    --erp-shadow-sm:      0 1px 3px rgba(0,0,0,.08);
    --erp-shadow-md:      0 4px 12px rgba(0,0,0,.12);
    --erp-radius:         10px;
    --erp-transition:     .22s ease;
    --erp-tap:            44px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--erp-bg);
    color: var(--erp-text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── TOPBAR ─────────────────────────────────────────────────── */
.erp-topbar {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important;
    width: 100% !important;
    height: var(--erp-topbar-height) !important;
    background: var(--erp-primary) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,.28) !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 !important;
}
.erp-topbar-inner {
    width: 100% !important; height: 100% !important;
    display: flex !important; align-items: center !important;
    justify-content: space-between !important;
    padding: 0 8px !important; flex-wrap: nowrap !important;
}
.erp-topbar-left  { display:flex; align-items:center; gap:4px; flex:1; min-width:0; overflow:hidden; }
.erp-topbar-right { display:flex; align-items:center; gap:0; flex-shrink:0; }

.erp-hamburger {
    background: none !important; border: none !important; color: #fff !important;
    width: 40px; height: 40px; min-width: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-size: 1.5rem; cursor: pointer;
    flex-shrink: 0; padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s;
}
.erp-hamburger:hover { background: rgba(255,255,255,.12) !important; }

.erp-brand {
    display: flex; align-items: center; gap: 6px;
    text-decoration: none !important; color: #fff !important;
    font-weight: 700; font-size: .9rem;
    white-space: nowrap; overflow: hidden;
    flex: 1; min-width: 0;
}
.erp-brand-icon {
    width: 28px; height: 28px; flex-shrink: 0;
    background: rgba(255,255,255,.2); border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: .88rem;
}
.erp-brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.erp-tb-btn {
    background: none !important; border: none !important;
    color: rgba(255,255,255,.88) !important;
    width: 38px; height: 38px; min-width: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-size: 1rem; cursor: pointer;
    padding: 0; flex-shrink: 0; position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s;
}
.erp-tb-btn:hover { background: rgba(255,255,255,.12) !important; color: #fff !important; }

.erp-user-btn {
    background: none !important; border: none !important;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    padding: 4px 6px; border-radius: 8px; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s;
}
.erp-user-btn:hover { background: rgba(255,255,255,.12) !important; }

.erp-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--erp-accent); color: #fff;
    font-weight: 700; font-size: .82rem;
    border: 2px solid rgba(255,255,255,.35);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.erp-user-name, .erp-chevron { display: none; }

@media (min-width: 768px) {
    .erp-topbar-inner { padding: 0 16px !important; }
    .erp-topbar-right { gap: 4px; }
    .erp-user-name {
        display: inline; color: #fff;
        font-size: .82rem; font-weight: 600;
        max-width: 120px; overflow: hidden;
        text-overflow: ellipsis; white-space: nowrap;
    }
    .erp-chevron { display: inline; color: rgba(255,255,255,.7); font-size: .7rem; }
}

/* Dropdown */
.erp-dropdown {
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    padding: 4px 0;
}
.erp-dropdown .dropdown-item {
    padding: 9px 16px; font-size: .85rem;
    display: flex; align-items: center;
    min-height: 40px;
}
.erp-dropdown .dropdown-item:hover { background: var(--erp-primary-light); }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.erp-sidebar {
    position: fixed;
    top: var(--erp-topbar-height); left: 0;
    width: var(--erp-sidebar-width);
    height: calc(100vh - var(--erp-topbar-height));
    background: var(--erp-primary-dark);
    overflow-y: auto; overflow-x: hidden;
    z-index: 1040;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
    -webkit-overflow-scrolling: touch;
}
.erp-sidebar::-webkit-scrollbar { width: 3px; }
.erp-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.erp-sidebar.show {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
}
.erp-sidebar-header {
    height: 46px; border-bottom: 1px solid rgba(255,255,255,.07);
    display: flex; align-items: center; padding: 0 16px;
}
.erp-sidebar-label {
    color: rgba(255,255,255,.35); font-size: .66rem;
    font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
}
.erp-nav-group {
    padding: 14px 16px 4px;
    font-size: .64rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    color: rgba(255,255,255,.28); pointer-events: none;
}
.erp-nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 18px; min-height: var(--erp-tap);
    color: rgba(255,255,255,.75); text-decoration: none;
    font-size: .9rem; border-left: 3px solid transparent;
    transition: background var(--erp-transition), color var(--erp-transition), border-color var(--erp-transition);
    white-space: nowrap; cursor: pointer;
    background: none; width: 100%; text-align: left;
}
.erp-nav-link i { font-size: 1.05rem; flex-shrink: 0; width: 22px; text-align: center; }
.erp-nav-link:hover, .erp-nav-link:focus {
    background: rgba(255,255,255,.08); color: #fff;
    border-left-color: var(--erp-accent); outline: none;
}
.erp-nav-link.active {
    background: rgba(255,255,255,.13); color: #fff;
    font-weight: 600; border-left-color: #fff;
}
.erp-nav-logout { color: rgba(255,110,110,.85) !important; }
.erp-nav-logout:hover {
    background: rgba(255,80,80,.12) !important;
    color: #ff6b6b !important; border-left-color: #ff6b6b !important;
}

/* Desktop: always visible */
@media (min-width: 992px) {
    .erp-sidebar { transform: translateX(0); }
    .erp-content-wrapper { margin-left: var(--erp-sidebar-width); }
    .erp-overlay { display: none !important; }
    body.sidebar-collapsed .erp-sidebar { width: 62px; }
    body.sidebar-collapsed .erp-sidebar .erp-nav-link span,
    body.sidebar-collapsed .erp-sidebar .erp-nav-group,
    body.sidebar-collapsed .erp-sidebar .erp-sidebar-label { display: none; }
    body.sidebar-collapsed .erp-sidebar .erp-nav-link {
        justify-content: center; padding: 13px; border-left: none;
    }
    body.sidebar-collapsed .erp-content-wrapper { margin-left: 62px; }
}

/* ── OVERLAY ──────────────────────────────────────────────── */
.erp-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 1039;
    backdrop-filter: blur(2px);
}
.erp-overlay.show { display: block; }

/* ── CONTENT WRAPPER ─────────────────────────────────────── */
.erp-content-wrapper {
    margin-top: var(--erp-topbar-height) !important;
    margin-left: 0;
    min-height: calc(100vh - var(--erp-topbar-height));
    display: flex; flex-direction: column;
}
.erp-main { flex: 1; padding: 16px; }
@media (min-width: 768px) { .erp-main { padding: 20px; } }
@media (min-width: 992px) {
    .erp-main { padding: 24px; }
    .erp-content-wrapper { margin-left: var(--erp-sidebar-width) !important; }
}

/* ── FOOTER ─────────────────────────────────────────────────── */
.erp-footer {
    background: var(--erp-surface);
    border-top: 1px solid var(--erp-border);
    padding: 12px 16px; font-size: .8rem;
    color: var(--erp-text-muted);
}
@media (min-width: 768px) { .erp-footer { padding: 14px 24px; } }

/* ── CARDS ───────────────────────────────────────────────────── */
.erp-card {
    background: var(--erp-surface);
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow-sm);
    border: 1px solid var(--erp-border);
    padding: 16px;
}
@media (min-width: 768px) { .erp-card { padding: 20px; } }

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
    display: none !important;
}

/* ── STAT CARDS ─────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (min-width: 576px) { .stats-grid { grid-template-columns: repeat(3,1fr); } }
@media (min-width: 992px) { .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); } }

.stat-card {
    background: var(--erp-surface);
    border-radius: var(--erp-radius); padding: 10px;
    box-shadow: var(--erp-shadow-sm); border: 1px solid var(--erp-border);
    display: flex; align-items: center; gap: 8px;
    transition: box-shadow var(--erp-transition), transform var(--erp-transition);
}
@media (min-width: 576px) { .stat-card { padding: 14px; gap: 12px; } }
.stat-card:hover { box-shadow: var(--erp-shadow-md); transform: translateY(-2px); }
.stat-card-icon {
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; flex-shrink: 0;
}
@media (min-width: 576px) { .stat-card-icon { width: 44px; height: 44px; border-radius: 10px; font-size: 1.25rem; } }
.stat-card h3 { font-size: .65rem; color: var(--erp-text-muted); margin: 0 0 2px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card p  { font-size: 1.3rem; font-weight: 700; color: var(--erp-text); margin: 0; line-height: 1; word-break: break-all; }
@media (min-width: 576px) { .stat-card p { font-size: 1.55rem; } }
.stat-card-icon.blue   { background: #e8eaf6; color: var(--erp-primary); }
.stat-card-icon.green  { background: #e8f5e9; color: #2e7d32; }
.stat-card-icon.orange { background: #fff3e0; color: #e65100; }
.stat-card-icon.red    { background: #ffebee; color: #c62828; }
.stat-card-icon.purple { background: #f3e5f5; color: #6a1b9a; }
.stat-card-icon.teal   { background: #e0f2f1; color: #00695c; }

/* ── ACTION CARDS (MR Quick Actions) ────────────────────────── */
.erp-action-card {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow-sm);
    display: flex; align-items: center; gap: 14px;
    padding: 16px; color: var(--erp-text);
    transition: box-shadow var(--erp-transition), transform var(--erp-transition), border-color var(--erp-transition);
    min-height: var(--erp-tap);
    -webkit-tap-highlight-color: transparent;
}
.erp-action-card:hover {
    box-shadow: var(--erp-shadow-md);
    transform: translateY(-2px);
    border-color: var(--erp-accent);
    color: var(--erp-text);
}
.erp-action-icon {
    width: 54px; height: 54px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; flex-shrink: 0;
}
.erp-action-body { flex: 1; min-width: 0; }
.erp-action-body h3 { font-size: .96rem; font-weight: 700; margin: 0 0 2px; }
.erp-action-body p  { font-size: .78rem; color: var(--erp-text-muted); margin: 0 0 6px; }
.erp-action-badge {
    display: inline-block; padding: 2px 10px; border-radius: 20px;
    font-size: .72rem; font-weight: 700;
}
.erp-action-arrow { color: var(--erp-text-muted); font-size: .9rem; flex-shrink: 0; }

/* ── STEP BADGE ─────────────────────────────────────────────── */
.step-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--erp-primary); color: #fff;
    font-size: .75rem; font-weight: 700;
    margin-right: 8px; flex-shrink: 0;
}

/* ── STATUS OPTIONS (radio cards) ──────────────────────────── */
.status-option {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 8px;
    border: 1.5px solid var(--erp-border);
    cursor: pointer; transition: border-color var(--erp-transition), background var(--erp-transition);
    -webkit-tap-highlight-color: transparent;
}
.status-option:hover { border-color: var(--erp-accent); background: #f8f9ff; }
.status-option.selected {
    border-color: var(--erp-primary);
    background: var(--erp-primary-light);
}
.status-option i  { font-size: 1.3rem; flex-shrink: 0; }
.status-option div > div:first-child { font-size: .9rem; font-weight: 600; }
.status-option small { font-size: .76rem; }

/* ── CAMERA ─────────────────────────────────────────────────── */
.camera-container {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    max-height: 55vw;
    min-height: 200px;
    display: flex; align-items: center; justify-content: center;
}
@media (min-width: 600px) { .camera-container { max-height: 320px; } }

.camera-video {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 10px;
}
.camera-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.45);
    color: #fff; padding: 5px 10px;
    font-size: .72rem; text-align: left;
    pointer-events: none;
}
.capture-preview {
    width: 100%; max-height: 340px;
    object-fit: contain; border-radius: 10px;
    border: 2px solid var(--erp-border);
    background: #000;
    display: block;
}

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn-erp {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; min-height: var(--erp-tap);
    background: var(--erp-primary); color: #fff !important;
    border: none; border-radius: 8px; cursor: pointer;
    font-size: .9rem; font-weight: 500;
    text-decoration: none;
    transition: background var(--erp-transition), box-shadow var(--erp-transition);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn-erp:hover  { background: var(--erp-accent); box-shadow: 0 2px 8px rgba(26,35,126,.25); }
.btn-erp:active { transform: scale(.97); }

/* Bootstrap btn overrides for touch */
.erp-main .btn, .erp-main .btn-sm {
    min-height: 36px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.erp-topbar .btn, .erp-topbar button { min-height: unset !important; }

/* ── FORMS ───────────────────────────────────────────────────── */
.form-control, .form-select,
input[type="text"], input[type="email"],
input[type="password"], input[type="number"],
input[type="date"], input[type="tel"],
textarea, select {
    font-size: 16px !important; /* prevent iOS zoom */
    border-radius: 8px; min-height: var(--erp-tap);
    padding: 10px 13px; width: 100%;
    border: 1.5px solid var(--erp-border);
    transition: border-color var(--erp-transition), box-shadow var(--erp-transition);
    -webkit-appearance: none; appearance: none;
}
.form-control:focus, .form-select:focus,
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--erp-accent);
    box-shadow: 0 0 0 3px rgba(92,107,192,.15);
}

/* ── AUTH PAGE ──────────────────────────────────────────────── */
.auth-page {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; padding: 16px;
    background: linear-gradient(135deg, var(--erp-primary) 0%, #5c6bc0 50%, #283593 100%);
}
.auth-box {
    background: var(--erp-surface);
    padding: 28px 22px; border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.22);
    width: 100%; max-width: 420px;
    display: flex; flex-direction: column; gap: 14px;
}
@media (min-width: 480px) { .auth-box { padding: 36px 32px; } }
.auth-logo-wrap {
    width: 64px; height: 64px; border-radius: 16px;
    background: var(--erp-primary-light);
    display: inline-flex; align-items: center; justify-content: center;
    margin: 0 auto 8px;
}

/* ── TABLES ──────────────────────────────────────────────────── */
.table-responsive { -webkit-overflow-scrolling: touch; overflow-x: auto; }
.table thead th { white-space: nowrap; font-size: .75rem !important; font-weight: 600; }
.table tbody td { font-size: .85rem; vertical-align: middle; }

/* ── ALERTS ─────────────────────────────────────────────────── */
.alert { border-radius: 10px; font-size: .88rem; }

/* ── BADGES ──────────────────────────────────────────────────── */
.badge { padding: 4px 10px; border-radius: 20px; font-size: .72rem; font-weight: 600; }

/* ── PAGINATION ──────────────────────────────────────────────── */
.page-link { min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }

/* ── UTILITY ─────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--erp-accent); outline-offset: 2px; }

/* ── MOBILE TWEAKS ───────────────────────────────────────────── */
@media (max-width: 380px) {
    .erp-main { padding: 10px !important; }
    .stat-card p { font-size: 1.3rem; }
}
@media (max-width: 575.98px) {
    .erp-action-card { padding: 12px; }
    .erp-action-icon { width: 46px; height: 46px; font-size: 1.3rem; }
    .erp-action-body h3 { font-size: .88rem; }
    .page-header h1 { font-size: 1.05rem; }
}

/* ── SETUP PAGE ──────────────────────────────────────────────── */
.setup-step {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid #e8eaf6;
    font-size: .85rem;
}
.setup-step:last-child { border-bottom: none; }

.setup-step-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--erp-primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; flex-shrink: 0;
}

.user-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 0; border-bottom: 1px solid #e8eaf6; gap: 8px;
}
.user-row:last-child { border-bottom: none; }

.role-pill {
    display: inline-block; padding: 2px 10px;
    border-radius: 20px; font-size: .7rem;
    font-weight: 700; color: #fff;
}

/* Dark mode for setup page */
[data-theme="dark"] .setup-step      { border-color: var(--erp-border); }
[data-theme="dark"] .user-row        { border-color: var(--erp-border); }
[data-theme="dark"] .setup-step-num  { background: var(--erp-accent); }

/* ── SPINNER OVERLAY on capture ─────────────────────────────── */
.camera-container::after {
    content: ''; display: none;
    position: absolute; inset: 0;
    background: rgba(0,0,0,.3);
    border-radius: 10px;
}
.camera-container.loading::after { display: block; }

/* ── NOTIFICATION DOT ────────────────────────────────────────── */
.erp-notif-dot {
    position: absolute; top: 5px; right: 5px;
    background: #ef5350; color: #fff;
    font-size: .52rem; font-weight: 700;
    min-width: 15px; height: 15px;
    border-radius: 8px; padding: 0 3px;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}
.erp-notif-menu { min-width: 280px; max-height: 380px; overflow-y: auto; }
@media (max-width: 480px) {
    .erp-notif-menu {
        position: fixed !important;
        left: 8px !important; right: 8px !important;
        top: calc(var(--erp-topbar-height) + 4px) !important;
        width: auto !important; min-width: unset;
        transform: none !important;
    }
}

/* ── ROLE BADGE ──────────────────────────────────────────────── */
.erp-role-badge {
    background: var(--erp-primary-light);
    color: var(--erp-primary);
    font-size: .7rem; padding: 2px 8px; border-radius: 20px;
}

/* ── PROFILE CARD ────────────────────────────────────────────── */
.profile-card {
    background: var(--erp-surface);
    padding: 18px; border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow-sm);
    border: 1px solid var(--erp-border);
    margin-bottom: 16px;
}
.profile-card p {
    padding: 9px 0; border-bottom: 1px solid var(--erp-border);
    font-size: .9rem; margin: 0;
}
.profile-card p:last-child { border-bottom: none; }

/* ── GLOBAL SEARCH RESULT ─────────────────────────────────────── */
.global-search-result {
    border-bottom: 1px solid #f0f2f8;
    transition: background .12s;
    display: block; color: var(--erp-text);
    text-decoration: none; padding: 12px 16px;
}
.global-search-result:hover { background: #f5f7ff; color: var(--erp-primary); }

/* ── ANIMATED COUNTER ────────────────────────────────────────── */
[data-count-to] { display: inline-block; }

/* ── DATA TABLE (legacy) ─────────────────────────────────────── */
.data-table {
    width: 100%; border-collapse: collapse;
    background: var(--erp-surface);
    border-radius: var(--erp-radius);
    overflow: hidden;
    box-shadow: var(--erp-shadow-sm);
    border: 1px solid var(--erp-border);
    min-width: 480px;
}
.data-table thead th {
    background: var(--erp-primary); color: #fff;
    padding: 10px 12px; text-align: left;
    font-size: .75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .5px;
    white-space: nowrap;
}
.data-table tbody td {
    padding: 10px 12px; border-bottom: 1px solid var(--erp-border);
    font-size: .85rem; vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--erp-primary-light); }

/* ── SORTABLE TABLE HEADERS ─────────────────────────────────── */
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]::after { content: ' ⇅'; opacity: .4; font-size: .7em; }
th[data-sort].sort-asc::after  { content: ' ↑'; opacity: 1; color: #fff; }
th[data-sort].sort-desc::after { content: ' ↓'; opacity: 1; color: #fff; }

/* ── INLINE TABLE SEARCH ─────────────────────────────────────── */
.table-search-wrap { position: relative; }
.table-search-wrap input { padding-left: 2.2rem; }
.table-search-wrap .bi-search {
    position: absolute; left: 10px; top: 50%;
    transform: translateY(-50%); color: #aaa; pointer-events: none;
}

/* ── ERROR / SUCCESS INLINE ──────────────────────────────────── */
.error   { color: #c62828; background: #ffebee; padding: 11px 14px; border-radius: 8px; border-left: 4px solid #c62828; font-size: .88rem; }
.success { color: #2e7d32; background: #e8f5e9; padding: 11px 14px; border-radius: 8px; border-left: 4px solid #2e7d32; font-size: .88rem; }

/* ── BREADCRUMB ──────────────────────────────────────────────── */
.breadcrumb { font-size: .82rem; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--erp-text-muted); }

/* ── PAGINATION WRAPPER ──────────────────────────────────────── */
.pagination-wrapper {
    display: flex; flex-direction: column;
    align-items: center; gap: 8px; padding: 10px 12px;
}
@media (min-width: 576px) {
    .pagination-wrapper { flex-direction: row; justify-content: space-between; }
}

/* ============================================================
   DARK MODE
   Activated by: <html data-theme="dark">
   ============================================================ */
[data-theme="dark"] {
    --erp-primary:       #5c6bc0;
    --erp-primary-dark:  #1a1f3a;
    --erp-primary-light: #2a2f4a;
    --erp-accent:        #7986cb;
    --erp-bg:            #0f1117;
    --erp-surface:       #1a1d2e;
    --erp-text:          #e2e8f0;
    --erp-text-muted:    #94a3b8;
    --erp-border:        #2d3748;
    --erp-shadow-sm:     0 1px 3px rgba(0,0,0,.4);
    --erp-shadow-md:     0 4px 12px rgba(0,0,0,.5);
}
[data-theme="dark"] body { background: var(--erp-bg); color: var(--erp-text); }

/* Topbar */
[data-theme="dark"] .erp-topbar { background: #1a1d2e !important; box-shadow: 0 2px 8px rgba(0,0,0,.5) !important; }
[data-theme="dark"] .erp-hamburger,
[data-theme="dark"] .erp-tb-btn { color: rgba(255,255,255,.85) !important; }
[data-theme="dark"] .erp-hamburger:hover,
[data-theme="dark"] .erp-tb-btn:hover,
[data-theme="dark"] .erp-user-btn:hover { background: rgba(255,255,255,.1) !important; }

/* Sidebar */
[data-theme="dark"] .erp-sidebar { background: #0d1020; }

/* Cards */
[data-theme="dark"] .erp-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .profile-card,
[data-theme="dark"] .erp-action-card,
[data-theme="dark"] .auth-box {
    background: var(--erp-surface) !important;
    border-color: var(--erp-border) !important;
    color: var(--erp-text) !important;
}

/* Tables */
[data-theme="dark"] .table {
    --bs-table-bg: var(--erp-surface);
    --bs-table-color: var(--erp-text);
    --bs-table-border-color: var(--erp-border);
    --bs-table-hover-bg: #252840;
}
[data-theme="dark"] .table thead.table-dark {
    --bs-table-bg: #0d1020;
    --bs-table-color: #e2e8f0;
}
[data-theme="dark"] .table thead.table-light {
    --bs-table-bg: #252840;
    --bs-table-color: var(--erp-text);
    --bs-table-border-color: var(--erp-border);
}
[data-theme="dark"] .table tbody tr:hover td { background: #252840 !important; }
[data-theme="dark"] .data-table tbody tr:hover td { background: #252840 !important; }

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: #252840 !important;
    border-color: var(--erp-border) !important;
    color: var(--erp-text) !important;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    border-color: var(--erp-accent) !important;
    box-shadow: 0 0 0 3px rgba(92,107,192,.25) !important;
}
[data-theme="dark"] .input-group-text {
    background: #252840 !important;
    border-color: var(--erp-border) !important;
    color: var(--erp-text-muted) !important;
}

/* Dropdowns */
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .erp-dropdown {
    background: #1a1d2e !important;
    border-color: var(--erp-border) !important;
}
[data-theme="dark"] .dropdown-item { color: var(--erp-text) !important; }
[data-theme="dark"] .dropdown-item:hover { background: #252840 !important; }
[data-theme="dark"] .dropdown-divider { border-color: var(--erp-border) !important; }

/* Modals */
[data-theme="dark"] .modal-content {
    background: var(--erp-surface) !important;
    border-color: var(--erp-border) !important;
    color: var(--erp-text) !important;
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--erp-border) !important; }

/* Alerts */
[data-theme="dark"] .alert-success { background: #1a2e1a; border-color: #2e7d32; color: #81c784; }
[data-theme="dark"] .alert-danger  { background: #2e1a1a; border-color: #c62828; color: #ef9a9a; }
[data-theme="dark"] .alert-warning { background: #2e2a1a; border-color: #f57f17; color: #ffcc80; }
[data-theme="dark"] .alert-info    { background: #1a2030; border-color: #1565c0; color: #90caf9; }

/* Badges */
[data-theme="dark"] .badge.bg-light { background: #252840 !important; color: var(--erp-text) !important; }
[data-theme="dark"] .badge.bg-dark  { background: #0d1020 !important; }

/* Page header */
[data-theme="dark"] .page-header { border-color: var(--erp-border); }
[data-theme="dark"] .page-header h1 { color: var(--erp-text); }

/* Footer */
[data-theme="dark"] .erp-footer {
    background: var(--erp-surface);
    border-color: var(--erp-border);
    color: var(--erp-text-muted);
}

/* Pagination */
[data-theme="dark"] .page-link {
    background: var(--erp-surface);
    border-color: var(--erp-border);
    color: var(--erp-text);
}
[data-theme="dark"] .page-item.active .page-link {
    background: var(--erp-primary);
    border-color: var(--erp-primary);
}

/* Breadcrumb */
[data-theme="dark"] .breadcrumb-item a { color: var(--erp-accent); }
[data-theme="dark"] .breadcrumb-item.active,
[data-theme="dark"] .breadcrumb-item.active::before { color: var(--erp-text-muted); }

/* Status options (radio cards) */
[data-theme="dark"] .status-option {
    border-color: var(--erp-border);
    background: var(--erp-surface);
    color: var(--erp-text);
}
[data-theme="dark"] .status-option:hover { background: #252840; border-color: var(--erp-accent); }
[data-theme="dark"] .status-option.selected { background: var(--erp-primary-light); border-color: var(--erp-primary); }

/* Text utilities */
[data-theme="dark"] .text-muted { color: var(--erp-text-muted) !important; }
[data-theme="dark"] .text-dark   { color: var(--erp-text) !important; }
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border { border-color: var(--erp-border) !important; }
[data-theme="dark"] .bg-light { background: #252840 !important; }
[data-theme="dark"] .bg-white { background: var(--erp-surface) !important; }

/* Code/kbd */
[data-theme="dark"] code { background: #252840; color: #90caf9; padding: 1px 5px; border-radius: 4px; }
[data-theme="dark"] kbd  { background: #252840; color: var(--erp-text); border-color: var(--erp-border); }

/* Action cards */
[data-theme="dark"] .erp-action-card { background: var(--erp-surface); border-color: var(--erp-border); color: var(--erp-text); }
[data-theme="dark"] .erp-action-card:hover { border-color: var(--erp-accent); color: var(--erp-text); }
[data-theme="dark"] .erp-action-body p { color: var(--erp-text-muted); }

/* Search modal */
[data-theme="dark"] #globalSearchModal .modal-content { background: var(--erp-surface) !important; }
[data-theme="dark"] .global-search-result { border-color: var(--erp-border); color: var(--erp-text); }
[data-theme="dark"] .global-search-result:hover { background: #252840; }
[data-theme="dark"] #globalSearchInput { background: transparent; color: var(--erp-text); }
[data-theme="dark"] #globalSearchInput::placeholder { color: var(--erp-text-muted); }

/* Camera preview */
[data-theme="dark"] .capture-preview { border-color: var(--erp-border); }

/* Notification dot in dark mode */
[data-theme="dark"] .erp-notif-dot { background: #ef5350 !important; }

/* Topbar dropdown in dark mode */
[data-theme="dark"] .erp-topbar .dropdown-menu {
    background: #1a1d2e !important;
    border-color: #2d3748 !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .erp-topbar .dropdown-item { color: #e2e8f0 !important; }
[data-theme="dark"] .erp-topbar .dropdown-item:hover { background: #252840 !important; }
