/* =====================================================================
   Truck Parts ERP — application theme
   Palette: dark navy blue (brand/sidebar), slate gray (surfaces), white
   (cards), orange (accent / calls-to-action) — tuned for RTL Arabic UI.
   ===================================================================== */

:root {
    --tpe-navy: #0f2942;
    --tpe-navy-dark: #0a1c2e;
    --tpe-navy-light: #16395c;
    --tpe-gray-bg: #f2f4f7;
    --tpe-gray-border: #e3e7ee;
    --tpe-orange: #f5821f;
    --tpe-orange-dark: #d96c0f;
    --tpe-text-muted: #6b7280;
    --tpe-sidebar-width: 260px;
}

body {
    background-color: var(--tpe-gray-bg);
    font-family: "Segoe UI", "Tahoma", system-ui, sans-serif;
    font-size: 0.925rem;
    color: #1f2937;
}

a { text-decoration: none; }

/* ---------------------------------------------------------------- Layout */
.tpe-wrapper {
    display: flex;
    min-height: 100vh;
}

.tpe-sidebar {
    width: var(--tpe-sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--tpe-navy) 0%, var(--tpe-navy-dark) 100%);
    color: #cfd8e3;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: margin-inline-start .2s ease;
    z-index: 1030;
}

.tpe-sidebar-brand {
    padding: 1.1rem .75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.tpe-sidebar-brand img { height: 44px; max-width: 100%; object-fit: contain; }

/* ---------------------------------------------------- Collapsed icon rail
   Desktop-only mini sidebar: the full sidebar shrinks to an icon column
   instead of disappearing, so navigation stays reachable without needing
   the labels. Mobile keeps the separate show/hide drawer defined below. */
.tpe-sidebar.collapsed { width: 76px; }
.tpe-sidebar.collapsed .tpe-nav-heading,
.tpe-sidebar.collapsed .tpe-nav-link span:not(.tpe-nav-icon):not(.badge),
.tpe-sidebar.collapsed .tpe-nav-toggle-label,
.tpe-sidebar.collapsed .tpe-nav-chevron {
    display: none;
}
.tpe-sidebar.collapsed .tpe-nav-link,
.tpe-sidebar.collapsed .tpe-nav-toggle {
    justify-content: center;
    position: relative;
}
.tpe-sidebar.collapsed .tpe-nav-link .badge {
    position: absolute;
    top: .3rem;
    inset-inline-end: .5rem;
    margin: 0 !important;
}
.tpe-sidebar.collapsed .tpe-nav-icon {
    width: 32px;
    height: 32px;
    font-size: .95rem;
}
.tpe-sidebar.collapsed .tpe-nav-group .collapse {
    display: block !important; /* flatten grouped sub-items into visible icons */
}
.tpe-sidebar.collapsed .tpe-nav-group .collapse .tpe-nav-link {
    padding-inline-start: .6rem;
}

.tpe-nav { padding: .75rem .65rem; }

.tpe-nav .tpe-nav-heading {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
    padding: 1rem .6rem .4rem;
}

.tpe-nav a.tpe-nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem .6rem;
    margin: .05rem 0;
    border-radius: .55rem;
    color: #c3cee0;
    font-size: .845rem;
    transition: background .15s ease, color .15s ease;
}

.tpe-nav a.tpe-nav-link:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
}

.tpe-nav a.tpe-nav-link.active {
    background: rgba(245,130,31,.18);
    color: #fff;
    font-weight: 600;
    box-shadow: inset -3px 0 0 var(--tpe-orange);
}

/* Icon badge: small rounded chip instead of a bare glyph */
.tpe-nav-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: .45rem;
    background: rgba(255,255,255,.06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    color: #93a5c2;
    transition: background .15s ease, color .15s ease;
}

.tpe-nav a.tpe-nav-link:hover .tpe-nav-icon { background: rgba(255,255,255,.12); color: #fff; }
.tpe-nav a.tpe-nav-link.active .tpe-nav-icon { background: var(--tpe-orange); color: #fff; }

/* Collapsible groups (Finance / Reports) */
.tpe-nav-group { margin: .05rem 0; }

.tpe-nav-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .65rem;
    background: none;
    border: none;
    padding: .5rem .6rem;
    margin-top: .4rem;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
    color: #93a5c2;
    cursor: pointer;
    border-radius: .55rem;
}

.tpe-nav-toggle:hover { color: #fff; background: rgba(255,255,255,.07); }

.tpe-nav-toggle-label { flex-grow: 1; text-align: start; }

.tpe-nav-chevron {
    font-size: .65rem;
    transition: transform .2s ease;
    flex-shrink: 0;
}

.tpe-nav-toggle[aria-expanded="true"] .tpe-nav-chevron { transform: rotate(180deg); }
.tpe-nav-toggle[aria-expanded="true"] { color: #b9c6dc; }

.tpe-main {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tpe-topbar {
    background: #fff;
    border-bottom: 1px solid var(--tpe-gray-border);
    padding: .6rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.tpe-alerts-menu {
    width: 340px;
    max-width: calc(100vw - 2rem);
    max-height: 420px;
    overflow-y: auto;
}

.tpe-topbar .tpe-clock {
    font-size: .8rem;
    color: var(--tpe-text-muted);
}

.tpe-content { padding: 1.25rem; flex-grow: 1; }

.tpe-footer {
    padding: .85rem 1.25rem;
    font-size: .8rem;
    color: var(--tpe-text-muted);
    border-top: 1px solid var(--tpe-gray-border);
    background: #fff;
}

/* ----------------------------------------------------------------- Cards */
.tpe-card {
    background: #fff;
    border: 1px solid var(--tpe-gray-border);
    border-radius: .6rem;
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}

.tpe-stat-card {
    padding: 1.1rem 1.25rem;
    border-radius: .6rem;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.tpe-stat-card .tpe-stat-icon {
    width: 46px;
    height: 46px;
    border-radius: .6rem;
    background: rgba(255,255,255,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.tpe-stat-card .tpe-stat-value { font-size: 1.4rem; font-weight: 700; }
.tpe-stat-card .tpe-stat-label { font-size: .78rem; opacity: .9; }

.tpe-stat-card.bg-navy { background: linear-gradient(135deg, var(--tpe-navy), var(--tpe-navy-light)); }
.tpe-stat-card.bg-orange { background: linear-gradient(135deg, var(--tpe-orange), var(--tpe-orange-dark)); }
.tpe-stat-card.bg-teal { background: linear-gradient(135deg, #0f766e, #115e59); }
.tpe-stat-card.bg-rose { background: linear-gradient(135deg, #be123c, #9f1239); }

/* ------------------------------------------------------------- About modal */
.tpe-about-logo { max-width: 160px; max-height: 90px; object-fit: contain; }
.tpe-about-contacts { max-width: 260px; margin: 0 auto; }
.tpe-about-contacts li { padding: .25rem 0; }
.tpe-about-contacts i { color: var(--tpe-orange); width: 1.4rem; }
.tpe-about-contacts a { color: inherit; }
.tpe-about-contacts a:hover { color: var(--tpe-orange); }

/* ---------------------------------------------------------------- Forms */
.tpe-label-bilingual { font-weight: 600; font-size: .85rem; }
.tpe-label-bilingual small { color: var(--tpe-text-muted); font-weight: 400; }

.btn-orange { background: var(--tpe-orange); border-color: var(--tpe-orange); color: #fff; }
.btn-orange:hover { background: var(--tpe-orange-dark); border-color: var(--tpe-orange-dark); color: #fff; }

.btn-navy { background: var(--tpe-navy); border-color: var(--tpe-navy); color: #fff; }
.btn-navy:hover { background: var(--tpe-navy-dark); border-color: var(--tpe-navy-dark); color: #fff; }

/* --------------------------------------------------------------- Tables */
table.dataTable thead th { background: #f8fafc; font-size: .8rem; }
table.dataTable td, table.dataTable th { vertical-align: middle; }

/* ---------------------------------------------------------- Responsive */
@media (max-width: 991.98px) {
    .tpe-sidebar { position: fixed; inset-inline-start: 0; margin-inline-start: calc(var(--tpe-sidebar-width) * -1); }
    .tpe-sidebar.show { margin-inline-start: 0; }
    .tpe-backdrop {
        position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1025; display: none;
    }
    .tpe-backdrop.show { display: block; }
}

/* ------------------------------------------------------------- Dark theme
   Toggled explicitly via the header button (assets/js/app.js), persisted in
   localStorage, applied as data-bs-theme="dark" on <html> before first paint
   (see the inline script in the layout <head>) to avoid a flash of light mode.
   Bootstrap 5.3 itself reskins its own components (buttons, forms, dropdowns,
   modals) automatically from this same attribute; these rules only cover the
   app's own custom .tpe-* classes and hardcoded colors that Bootstrap doesn't
   touch. */
[data-bs-theme="dark"] {
    --tpe-gray-bg: #0b1220;
    --tpe-gray-border: #263447;
    --tpe-text-muted: #94a3b8;
}

[data-bs-theme="dark"] body { color: #e5e7eb; }

[data-bs-theme="dark"] .tpe-card,
[data-bs-theme="dark"] .tpe-topbar,
[data-bs-theme="dark"] .tpe-footer {
    background: #111827;
    border-color: var(--tpe-gray-border);
    color: #e5e7eb;
}

[data-bs-theme="dark"] table.dataTable thead th { background: #1f2937; color: #e5e7eb; }
[data-bs-theme="dark"] .tpe-about-modal { background: #111827; color: #e5e7eb; }
[data-bs-theme="dark"] .badge.text-bg-light { background-color: #1f2937 !important; color: #cbd5e1 !important; }

/* Global image lightbox (click-to-zoom) */
img.tpe-zoomable { cursor: zoom-in; }
body.tpe-lightbox-open { overflow: hidden; }
.tpe-lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, .88);
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.tpe-lightbox-overlay.show { display: flex; }
.tpe-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
    cursor: zoom-out;
}
.tpe-lightbox-close {
    position: absolute;
    top: 16px;
    inset-inline-end: 24px;
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 2.5rem;
    line-height: 1;
    cursor: pointer;
}
