/* ============================================================================
   ERMS — Electronic Repair Management System
   Main stylesheet. Built on Bootstrap 5 with custom layout + dark-mode tokens.
   Theme is driven by [data-bs-theme="light|dark"] on <html>.
   ========================================================================== */

:root {
    --erms-sidebar-w: 250px;
    --erms-topbar-h: 60px;
    --erms-brand: #2563eb;
    --erms-brand-rgb: 37, 99, 235;
    --erms-radius: .65rem;
    --erms-sidebar-bg: #0f172a;
    --erms-sidebar-fg: #cbd5e1;
    --erms-sidebar-active: #1e293b;
    --erms-surface: #ffffff;
    --erms-body: #f1f5f9;
    --erms-border: #e2e8f0;
}

[data-bs-theme="dark"] {
    --erms-surface: #1e293b;
    --erms-body: #0b1120;
    --erms-border: #334155;
    --erms-sidebar-bg: #0b1120;
}

/* ---------- base ---------- */
body {
    background: var(--erms-body);
    min-height: 100vh;
}
.btn-icon {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: inherit;
    border-radius: 50%; font-size: 1.15rem;
}
.btn-icon:hover { background: rgba(var(--erms-brand-rgb), .12); color: var(--erms-brand); }

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

.sidebar {
    width: var(--erms-sidebar-w);
    background: var(--erms-sidebar-bg);
    color: var(--erms-sidebar-fg);
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    display: flex; flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-brand {
    height: var(--erms-topbar-h);
    display: flex; align-items: center; gap: .5rem;
    padding: 0 1.25rem; font-weight: 700; font-size: 1.25rem;
    color: #fff; border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand i { color: var(--erms-brand); }
.sidebar-nav { padding: .75rem; overflow-y: auto; flex: 1; }
.sidebar-nav .nav-link {
    color: var(--erms-sidebar-fg);
    border-radius: var(--erms-radius);
    padding: .6rem .85rem; margin-bottom: .15rem;
    display: flex; align-items: center; gap: .65rem;
    font-size: .925rem; transition: background .15s;
}
.sidebar-nav .nav-link:hover { background: var(--erms-sidebar-active); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--erms-brand); color: #fff; }
.sidebar-nav .nav-link i { font-size: 1.05rem; }
.nav-section {
    text-transform: uppercase; font-size: .7rem; letter-spacing: .08em;
    color: #64748b; padding: 1rem .85rem .35rem;
}

.main {
    flex: 1; margin-left: var(--erms-sidebar-w);
    display: flex; flex-direction: column; min-width: 0;
}
.topbar {
    height: var(--erms-topbar-h);
    background: var(--erms-surface);
    border-bottom: 1px solid var(--erms-border);
    display: flex; align-items: center; gap: .75rem;
    padding: 0 1.25rem; position: sticky; top: 0; z-index: 1030;
}
.content { padding: 1.5rem; flex: 1; }

/* ---------- global search ---------- */
.search-wrap { position: relative; flex: 1; max-width: 520px; }
.search-results {
    position: absolute; top: 110%; left: 0; right: 0;
    background: var(--erms-surface);
    border: 1px solid var(--erms-border);
    border-radius: var(--erms-radius);
    box-shadow: 0 12px 28px rgba(0,0,0,.12);
    max-height: 380px; overflow-y: auto; display: none; z-index: 1050;
}
.search-results.show { display: block; }
.search-results a {
    display: block; padding: .6rem .85rem; text-decoration: none;
    color: inherit; border-bottom: 1px solid var(--erms-border);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--erms-body); }

/* ---------- notifications ---------- */
.notif-badge { position: absolute; top: 4px; right: 4px; font-size: .6rem; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { padding: .7rem .9rem; border-bottom: 1px solid var(--erms-border); }
.notif-item.unread { background: rgba(var(--erms-brand-rgb), .06); }
.notif-item:last-child { border-bottom: none; }

/* ---------- avatar ---------- */
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--erms-brand); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .9rem;
}

/* ---------- cards & stats ---------- */
.card { border: 1px solid var(--erms-border); border-radius: var(--erms-radius); }
.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: var(--erms-radius);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { color: #64748b; font-size: .825rem; }

.bg-soft-primary { background: rgba(var(--erms-brand-rgb), .12); color: var(--erms-brand); }
.bg-soft-warning { background: rgba(245, 158, 11, .15); color: #d97706; }
.bg-soft-info    { background: rgba(6, 182, 212, .15);  color: #0891b2; }
.bg-soft-success { background: rgba(16, 185, 129, .15); color: #059669; }
.bg-soft-danger  { background: rgba(239, 68, 68, .15);  color: #dc2626; }
.bg-soft-dark    { background: rgba(100, 116, 139, .18); color: #475569; }

/* ---------- timeline (GitHub / Facebook style) ---------- */
.timeline { position: relative; padding-left: 2.25rem; }
.timeline::before {
    content: ""; position: absolute; left: 11px; top: 4px; bottom: 4px;
    width: 2px; background: var(--erms-border);
}
.timeline-item { position: relative; padding-bottom: 1.5rem; }
.timeline-dot {
    position: absolute; left: -2.25rem; top: 2px;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--erms-surface); border: 2px solid var(--erms-brand);
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem; color: var(--erms-brand);
}
.timeline-card {
    background: var(--erms-surface); border: 1px solid var(--erms-border);
    border-radius: var(--erms-radius); padding: .85rem 1rem;
}
.timeline-meta { font-size: .8rem; color: #64748b; }
.timeline-thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.timeline-thumbs img {
    width: 70px; height: 70px; object-fit: cover;
    border-radius: .4rem; border: 1px solid var(--erms-border); cursor: pointer;
}

/* ---------- attachments gallery ---------- */
.attach-grid { display: flex; flex-wrap: wrap; gap: .6rem; }
.attach-grid img {
    width: 100px; height: 100px; object-fit: cover;
    border-radius: .5rem; border: 1px solid var(--erms-border); cursor: pointer;
}
.attach-file {
    width: 100px; height: 100px; border-radius: .5rem;
    border: 1px solid var(--erms-border); display: flex;
    flex-direction: column; align-items: center; justify-content: center;
    gap: .25rem; font-size: .7rem; text-decoration: none; color: inherit;
    text-align: center; padding: .35rem;
}

/* ---------- auth ---------- */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%); padding: 1.5rem;
}
.auth-card {
    width: 100%; max-width: 410px; background: var(--erms-surface);
    border-radius: 1rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); padding: 2.25rem;
}
.auth-logo { font-size: 2rem; color: var(--erms-brand); }

/* ---------- misc ---------- */
.qr-box { display: inline-block; padding: .75rem; background: #fff; border-radius: var(--erms-radius); }
.table-wrap { background: var(--erms-surface); border-radius: var(--erms-radius); padding: 1rem; }
.cursor-pointer { cursor: pointer; }

/* ---------- responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .search-wrap { max-width: none; }
}
