/* =========================================================
   NewLifeCRM — Custom Stylesheet
   ========================================================= */

:root {
    --nlc-primary:        #3b5bdb;
    --nlc-body-bg:        #f4f6fb;
    --nlc-card-radius:    0.75rem;
    --nlc-border:         #dee2e6;

    --sidebar-width:      260px;
    --sidebar-bg:         #1c1f27;
    --sidebar-text:       rgba(255, 255, 255, 0.60);
    --sidebar-hover-bg:   rgba(255, 255, 255, 0.06);
    --sidebar-active-bg:  rgba(59, 91, 219, 0.22);
    --sidebar-active-txt: #ffffff;
    --sidebar-accent:     #7da9ff;
    --topbar-height:      60px;
}

/* ── Base ──────────────────────────────────────────────────── */
body {
    background-color: var(--nlc-body-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Sidebar (Bootstrap offcanvas-lg) ───────────────────────── */

/* offcanvas: override Bootstrap variables + guard against nav-link color bleed */
.sidebar-nav-wrapper {
    --bs-offcanvas-width:   var(--sidebar-width);
    --bs-offcanvas-bg:      var(--sidebar-bg);
    --bs-offcanvas-color:   var(--sidebar-text);
    --bs-nav-link-color:    var(--sidebar-text);   /* belt-and-suspenders guard */
    scrollbar-width: none;
}
.sidebar-nav-wrapper::-webkit-scrollbar { display: none; }

/* Desktop: Bootstrap's offcanvas-lg sets transparent bg, flex-grow:1, overflow-y:visible,
   and border:0 — all with !important. We must counter every one of them. */
@media (min-width: 992px) {
    .sidebar-nav-wrapper {
        position: sticky !important;
        top: 0 !important;
        bottom: auto !important;
        height: 100vh !important;
        width: var(--sidebar-width) !important;
        min-width: var(--sidebar-width) !important;
        flex-grow: 0 !important;
        flex-shrink: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        background-color: var(--sidebar-bg) !important;
        border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
        border-top: none !important;
        z-index: 1 !important;
    }
}

/* ── Brand row ───────────────────────────────────────────────── */
.sidebar-brand-header {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    padding: 0 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.02em;
    text-decoration: none;
    white-space: nowrap;
}
.sidebar-brand:hover { color: #ffffff; text-decoration: none; }

.sidebar-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--nlc-primary);
    border-radius: 9px;
    font-size: 1rem;
    color: #ffffff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(59, 91, 219, 0.45);
}

/* ── Section labels ──────────────────────────────────────────── */
.sidebar-section-label {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    color: rgba(255, 255, 255, 0.28);
    padding: 1.35rem 1.25rem 0.45rem;
    white-space: nowrap;
    list-style: none;
}

/* ── Nav links ───────────────────────────────────────────────── */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.9rem;
    margin: 2px 10px;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 400;
    text-decoration: none;
    border-radius: 8px;
    white-space: nowrap;
    transition: background 0.14s ease, color 0.14s ease;
}
.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color: rgba(255, 255, 255, 0.90);
    text-decoration: none;
}
.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-txt);
    font-weight: 500;
    box-shadow: inset 0 0 0 1px rgba(59, 91, 219, 0.30);
    text-decoration: none;
}

/* ── Icons ───────────────────────────────────────────────────── */
.sidebar-icon {
    flex-shrink: 0;
    font-size: 1.05rem;
    width: 18px;
    text-align: center;
    line-height: 1;
    color: rgba(255, 255, 255, 0.45);
    transition: color 0.14s ease;
}
.sidebar-link:hover .sidebar-icon  { color: rgba(255, 255, 255, 0.80); }
.sidebar-link.active .sidebar-icon { color: var(--sidebar-accent); }

/* ── Footer ──────────────────────────────────────────────────── */
.sidebar-footer {
    padding: 0.9rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.70rem;
    color: rgba(255, 255, 255, 0.18);
    white-space: nowrap;
}

/* ── Main wrapper ────────────────────────────────────────────── */
.main-wrapper {
    min-width: 0; /* prevent flex overflow */
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    gap: 0.75rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

#sidebarToggle {
    background: none;
    border: none;
    padding: 0.3rem 0.4rem;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 0.4rem;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
#sidebarToggle:hover { background: #f0f2f5; color: #212529; }

/* ── Dashboard stat cards (MES-style) ───────────────────────── */
.stat-card { transition: transform .15s, box-shadow .15s; }
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12) !important;
}
.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: #212529;
}
.stat-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6c757d;
    margin-top: .15rem;
}

/* ── Dashboard recent actions list ──────────────────────────── */
.recent-action-item + .recent-action-item {
    border-top: 1px solid #f0f2f5;
}
.dashboard-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
    border-radius: var(--nlc-card-radius);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .08);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn { border-radius: 0.5rem; font-weight: 500; }

/* ── Form controls ───────────────────────────────────────────── */
.form-control,
.form-select {
    border-radius: 0.5rem;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--nlc-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* ── Modals ──────────────────────────────────────────────────── */
.modal-content { border-radius: var(--nlc-card-radius); border: none; }

/* ── Tables ──────────────────────────────────────────────────── */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    border-top: none;
}
.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.04);
}

/* ── Badge ───────────────────────────────────────────────────── */
.badge { font-weight: 500; letter-spacing: 0.02em; }

/* ── Utilities ───────────────────────────────────────────────── */
.letter-spacing-1 { cursor: pointer; }
.cursor-pointer   { cursor: pointer; }

/* ── Loading overlay ─────────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ── Footer ──────────────────────────────────────────────────── */
footer { font-size: 0.8rem; color: #adb5bd; }

/* ── Responsive tweaks ───────────────────────────────────────── */
@media (max-width: 576px) {
    .card-body { padding: 1rem; }
}
