/* ==========================================================================
   HISUN MIS - application shell
   Bootstrap 5.3 is loaded first; this file only adds the layout and the
   house style on top of it.
   ========================================================================== */

:root {
    --sidebar-w: 256px;
    --topbar-h: 60px;

    --brand: #1d4ed8;
    --brand-dark: #1e40af;
    --brand-soft: #eff4ff;

    --side-bg: #0f172a;
    --side-fg: #cbd5e1;
    --side-fg-muted: #64748b;
    --side-active: #1d4ed8;

    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --line: #e2e8f0;
    --ink: #0f172a;
    --ink-soft: #475569;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9rem;
    background: var(--body-bg);
    color: var(--ink);
}

/* ------------------------------------------------------------------ layout */

.layout { display: flex; min-height: 100vh; }

.layout-main {
    flex: 1;
    min-width: 0;                 /* lets wide tables scroll instead of stretching the page */
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-w);
    transition: margin-left .2s ease;
}

.content { flex: 1; }

.app-footer {
    border-top: 1px solid var(--line);
    background: #fff;
    padding: .75rem 0;
    font-size: .8rem;
    color: var(--ink-soft);
}

/* ----------------------------------------------------------------- sidebar */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--side-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    height: var(--topbar-h);
    padding: 0 1rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    flex-shrink: 0;
}

.brand-mark {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 8px;
    background: var(--brand);
    font-size: 1rem;
}

.brand-logo { max-height: 32px; max-width: 120px; object-fit: contain; }
.brand-text { font-weight: 700; font-size: .98rem; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem 0 1.5rem; }

/* Thin scrollbar so the dark sidebar stays clean */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.sidebar-heading {
    padding: 1rem 1rem .35rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--side-fg-muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem 1rem;
    color: var(--side-fg);
    text-decoration: none;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background-color .15s, color .15s;
}

.sidebar-link i { font-size: 1.02rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.sidebar-link.active {
    background: rgba(29, 78, 216, .18);
    border-left-color: var(--side-active);
    color: #fff;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar-toggle {
    display: none;
    font-size: 1.4rem;
    color: var(--ink);
    padding: 0 .25rem;
    text-decoration: none;
}

.topbar-search { position: relative; flex: 1; max-width: 420px; }
.topbar-search i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.topbar-search .form-control { padding-left: 2.1rem; background: var(--body-bg); border-color: transparent; }
.topbar-search .form-control:focus { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(29, 78, 216, .12); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .35rem; }

.topbar-icon {
    position: relative;
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: 1.1rem;
    text-decoration: none;
}
.topbar-icon:hover { background: var(--body-bg); color: var(--ink); }
.topbar-icon .badge { position: absolute; top: 2px; right: 0; font-size: .62rem; padding: .18em .4em; }

.user-btn {
    display: flex; align-items: center; gap: .55rem;
    background: none; border: 0; padding: .25rem .4rem;
    border-radius: 8px; text-decoration: none; color: var(--ink);
}
.user-btn:hover { background: var(--body-bg); }
.user-btn::after { margin-left: .15rem; }

.avatar {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-weight: 700; font-size: .78rem;
    flex-shrink: 0;
}

.user-meta { text-align: left; line-height: 1.15; }
.user-name { display: block; font-weight: 600; font-size: .84rem; }
.user-role { display: block; font-size: .72rem; color: var(--ink-soft); }

/* -------------------------------------------------------------- page head */

.page-title { font-size: 1.3rem; font-weight: 700; margin: 0; }
.breadcrumb { font-size: .8rem; margin-top: .15rem; }
.breadcrumb-item + .breadcrumb-item::before { content: "\203A"; }

/* ------------------------------------------------------------------ cards */

.card {
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: .75rem 1rem;
    font-weight: 600;
    border-radius: 10px 10px 0 0 !important;
}

/* Statistic tile used across the dashboard */
.stat-card { display: flex; align-items: center; gap: .9rem; padding: 1rem; height: 100%; }
.stat-icon {
    width: 46px; height: 46px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 10px; font-size: 1.25rem;
}
.stat-label { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }
.stat-sub { font-size: .75rem; color: var(--ink-soft); }

/* ----------------------------------------------------------------- tables */

.table { font-size: .855rem; }
.table > thead > tr > th {
    background: #f8fafc;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table > tbody > tr > td { vertical-align: middle; }

/* Serial numbers read better in a monospace pill */
.serial {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .8rem;
    background: #f1f5f9;
    border: 1px solid var(--line);
    padding: .12rem .4rem;
    border-radius: 4px;
    white-space: nowrap;
}

/* Colour chip next to a serial, because serial alone is not a unique unit */
.color-chip { display: inline-flex; align-items: center; gap: .3rem; }
.color-dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .18); display: inline-block; }

.empty-state { padding: 3rem 1rem; text-align: center; color: var(--ink-soft); }
.empty-state i { font-size: 2.6rem; opacity: .35; display: block; margin-bottom: .6rem; }

/* ------------------------------------------------------------------ forms */

.form-label { font-weight: 600; font-size: .8rem; margin-bottom: .25rem; }
.form-control, .form-select { font-size: .875rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(29, 78, 216, .12);
}
.required::after { content: " *"; color: #dc2626; }

.btn { font-size: .875rem; font-weight: 500; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }

.badge { font-weight: 600; }

/* ------------------------------------------------------------------ login */

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.auth-card { width: 100%; max-width: 410px; border: 0; border-radius: 14px; box-shadow: 0 20px 45px rgba(0, 0, 0, .3); }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand .brand-mark { width: 52px; height: 52px; margin: 0 auto .6rem; font-size: 1.6rem; }

/* ------------------------------------------------------------- responsive */

.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 1035;
    display: none;
}
body.sidebar-open .sidebar-backdrop { display: block; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .layout-main { margin-left: 0; }
    .topbar-toggle { display: block; }
    .topbar-search { max-width: none; }
}

@media (max-width: 575.98px) {
    .page-title { font-size: 1.1rem; }
    .stat-value { font-size: 1.2rem; }
}

@media print {
    .sidebar, .topbar, .app-footer, .page-actions, .no-print { display: none !important; }
    .layout-main { margin-left: 0; }
    .card { border: 0; box-shadow: none; }
    body { background: #fff; }
}
