/* ============================================================================
   COL TMS — admin panel design system
   Modern, COL-branded theme layered on Bootstrap 5.3. Restyles every page:
   shell (sidebar/topbar), cards, tables (bootstrap-table), forms, buttons,
   badges, and dashboard widgets. Supports light + dark (data-bs-theme).
   Brand: navy #152F52 primary, teal #1CB08F accent.
   ============================================================================ */

:root {
    --tms-sidebar-width: 262px;

    --col-primary: #152F52;       /* COL navy */
    --col-primary-dark: #0E2340;  /* COL navy (darker) */
    --col-accent: #1CB08F;        /* COL teal */
    --col-accent-dark: #03807C;   /* COL teal (darker) */

    --tms-radius: 14px;
    --tms-radius-sm: 10px;
    --tms-shadow: 0 6px 24px rgba(16, 24, 40, .06);
    --tms-shadow-hover: 0 12px 32px rgba(16, 24, 40, .12);

    /* light surface */
    --tms-bg: #F4F6FA;
    --tms-surface: #FFFFFF;
    --tms-border: #E6E9F0;
    --tms-text: #1A202C;
    --tms-muted: #6C7278;
    --tms-sidebar-bg: #0E1726;      /* deep navy sidebar */
    --tms-sidebar-text: #AEB8C9;
    --tms-sidebar-active: #FFFFFF;

    --bs-primary: var(--col-primary);
    --bs-primary-rgb: 21, 47, 82;
    --bs-link-color: var(--col-primary);
    --bs-link-hover-color: var(--col-primary-dark);
}

[data-bs-theme="dark"] {
    --tms-bg: #0B1220;
    --tms-surface: #131C2B;
    --tms-border: #223049;
    --tms-text: #E7ECF3;
    --tms-muted: #8A97AC;
    --tms-sidebar-bg: #0A101C;
    --tms-sidebar-text: #93A1B8;
}

html, body { height: 100%; }

body {
    min-height: 100vh;
    background-color: var(--tms-bg);
    color: var(--tms-text);
    font-family: "Montserrat", "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: .925rem;
}

/* ------------------------------------------------------------------ Topbar */
.tms-navbar {
    z-index: 1040;
    background: var(--tms-surface) !important;
    border-bottom: 1px solid var(--tms-border);
    box-shadow: 0 1px 3px rgba(16,24,40,.04);
    min-height: 62px;
}
.tms-navbar .navbar-brand {
    color: var(--col-primary) !important;
    font-weight: 800;
    letter-spacing: .06em;
    display: flex;
    align-items: center;
    gap: .55rem;
}
[data-bs-theme="dark"] .tms-navbar .navbar-brand { color: #E7ECF3 !important; }
.tms-navbar .navbar-brand img.tms-brand-logo { height: 26px; width: auto; }
/* logo theme swap (light shows navy logo, dark shows white logo) */
.tms-logo-dark { display: none; }
[data-bs-theme="dark"] .tms-logo-light { display: none; }
[data-bs-theme="dark"] .tms-logo-dark { display: inline-block; }

/* topbar icon buttons + avatar */
.tms-topbar-btn {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px; border: 1px solid var(--tms-border);
    background: var(--tms-surface); color: var(--tms-muted);
    transition: all .15s;
}
.tms-topbar-btn:hover { color: var(--col-primary); border-color: var(--col-primary); }
.tms-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--col-primary), var(--col-accent));
    color: #fff; font-weight: 700; font-size: .85rem;
    display: inline-flex; align-items: center; justify-content: center;
}

/* ------------------------------------------------------------------ Sidebar */
.tms-sidebar {
    width: var(--tms-sidebar-width);
    flex-shrink: 0;
    transition: margin-left .2s ease-in-out;
    overflow-y: auto;
    background: var(--tms-sidebar-bg) !important;
    border-right: 0 !important;
    padding: 1rem .75rem !important;
    height: calc(100vh - 62px);
    position: sticky; top: 62px;
}
.tms-sidebar::-webkit-scrollbar { width: 6px; }
.tms-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }

.tms-sidebar .nav > .nav-item { margin-top: .15rem; }
.tms-sidebar .tms-sidebar-group-toggle {
    border: 0; background: none;
    color: #5D6B84 !important;
    font-weight: 700; font-size: .68rem;
    letter-spacing: .08em; text-transform: uppercase;
    padding: .55rem .6rem !important;
    border-radius: 8px;
    transition: background .15s ease, color .15s ease;
}
.tms-sidebar .tms-sidebar-group-toggle:hover {
    background: rgba(255,255,255,.05);
    color: #cdd5e4 !important;
}
.tms-sidebar .tms-sidebar-group-toggle .tms-sidebar-group-label { display: inline-flex; align-items: center; }
/* The group that contains the current page is highlighted (brighter text + teal dot + accent). */
.tms-sidebar .tms-sidebar-group-toggle.has-active {
    color: #e7ebf3 !important;
    background: rgba(28,176,143,.12);
}
.tms-sidebar .tms-sidebar-group-toggle.has-active .tms-sidebar-group-label::after {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: var(--col-accent); margin-left: .45rem; display: inline-block;
}
.tms-sidebar .tms-sidebar-group { padding-left: .15rem; margin-bottom: .1rem; }
.tms-sidebar-chevron { display: inline-block; transition: transform .15s ease-in-out; color: #5D6B84; font-size: .7rem; }
.tms-sidebar-group-toggle.collapsed .tms-sidebar-chevron { transform: rotate(-90deg); }

.tms-sidebar .nav-link {
    border-radius: 10px;
    margin-bottom: .15rem;
    padding: .6rem .75rem;
    color: var(--tms-sidebar-text);
    font-weight: 500;
    display: flex; align-items: center; gap: .7rem;
    transition: all .15s;
}
.tms-sidebar .nav-link .tms-nav-ico {
    width: 20px; height: 20px; flex-shrink: 0; opacity: .85;
}
.tms-sidebar .nav-link:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}
.tms-sidebar .nav-link.active {
    background: linear-gradient(135deg, var(--col-accent), var(--col-accent-dark));
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(28,176,143,.35);
}

/* ------------------------------------------------ Permission grid (UserGroups) */
.tms-perm-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--bs-body-bg); border-bottom: 2px solid var(--bs-border-color); font-size: .8rem; }
.tms-perm-grid thead th .js-col-all { margin-top: .2rem; }
.tms-perm-grid tbody tr:hover { background: rgba(0,0,0,.02); }
.tms-perm-grid .tms-perm-area td {
    background: var(--bs-tertiary-bg);
    font-weight: 600; letter-spacing: .02em;
    text-transform: uppercase; font-size: .72rem; color: var(--bs-secondary-color);
}
.tms-perm-grid .form-check-input { width: 1.15rem; height: 1.15rem; cursor: pointer; }
.tms-perm-grid td { border-color: var(--bs-border-color); }

/* ------------------------------------------------------------------ Content */
.tms-content { min-width: 0; flex-grow: 1; padding: 1.5rem !important; }

.tms-page-header { margin-bottom: 1.25rem; }
.tms-page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.tms-breadcrumb { font-size: .8rem; color: var(--tms-muted); }

/* ------------------------------------------------------------------ Cards */
.card {
    background: var(--tms-surface);
    border: 1px solid var(--tms-border);
    border-radius: var(--tms-radius);
    box-shadow: var(--tms-shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--tms-border);
    font-weight: 600;
    padding: 1rem 1.25rem;
}
.card-body { padding: 1.25rem; }

.dashboard-card {
    transition: transform .15s ease-in-out, box-shadow .15s ease-in-out;
    border-radius: var(--tms-radius);
    overflow: hidden;
}
.dashboard-card:hover { transform: translateY(-3px); box-shadow: var(--tms-shadow-hover); }

/* KPI / stat tile */
.tms-stat { display: flex; align-items: center; gap: 1rem; }
.tms-stat-ico {
    width: 52px; height: 52px; border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.35rem;
}
.tms-stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.tms-stat-label { color: var(--tms-muted); font-size: .8rem; margin-top: .2rem; }
.tms-tint-red   { background: rgba(21,47,82,.12);   color: var(--col-primary); }
.tms-tint-blue  { background: rgba(37,99,176,.12);  color: #2563B0; }
.tms-tint-green { background: rgba(28,176,143,.14); color: var(--col-accent-dark); }
.tms-tint-amber { background: rgba(245,166,35,.16); color: #d98c0a; }
.tms-tint-grey  { background: rgba(108,114,120,.14);color: #566072; }

/* ------------------------------------------------------------------ Tables */
.table { color: var(--tms-text); --bs-table-bg: transparent; }
.table > thead th {
    background: var(--tms-bg);
    color: var(--tms-muted);
    font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
    font-weight: 700; border-bottom: 1px solid var(--tms-border);
    padding: .8rem 1rem; white-space: nowrap;
}
.table > tbody td { padding: .8rem 1rem; vertical-align: middle; border-color: var(--tms-border); }
.table-hover > tbody > tr:hover > * { background: rgba(21,47,82,.03); }
.bootstrap-table .fixed-table-container { border-radius: var(--tms-radius-sm); }
.fixed-table-toolbar .search input { border-radius: 10px; }
.page-item.active .page-link { background: var(--col-primary); border-color: var(--col-primary); }
.page-link { color: var(--col-primary); }

/* ------------------------------------------------------------------ Buttons */
.btn { border-radius: 10px; font-weight: 600; padding: .5rem 1rem; }
.btn-primary { background: var(--col-primary); border-color: var(--col-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--col-primary-dark); border-color: var(--col-primary-dark); }
.btn-outline-primary { color: var(--col-primary); border-color: var(--col-primary); }
.btn-outline-primary:hover { background: var(--col-primary); border-color: var(--col-primary); color: #fff; }
.btn-success { background: var(--col-accent); border-color: var(--col-accent); }
.btn-success:hover, .btn-success:focus { background: var(--col-accent-dark); border-color: var(--col-accent-dark); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }

/* ------------------------------------------------------------------ Forms */
.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--tms-border);
    background: var(--tms-surface);
    color: var(--tms-text);
    padding: .55rem .8rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--col-primary);
    box-shadow: 0 0 0 .2rem rgba(21,47,82,.14);
}
.form-label { font-weight: 600; font-size: .82rem; color: var(--tms-text); margin-bottom: .35rem; }

/* ------------------------------------------------------------------ Badges */
.badge { font-weight: 600; padding: .4em .7em; border-radius: 30px; }
.tms-badge-soft { display:inline-flex; align-items:center; gap:.35rem; padding:.35rem .7rem; border-radius:30px; font-weight:600; font-size:.75rem; }
.tms-dot { width:7px; height:7px; border-radius:50%; display:inline-block; }

/* ------------------------------------------------------------------ Timeline (markings) */
.tms-timeline { position: relative; padding-left: 1.5rem; }
.tms-timeline::before { content:""; position:absolute; left:7px; top:4px; bottom:4px; width:2px; background:var(--tms-border); }
.tms-timeline-item { position: relative; padding: 0 0 1rem .25rem; }
.tms-timeline-item::before {
    content:""; position:absolute; left:-1.5rem; top:2px; width:14px; height:14px;
    border-radius:50%; background:var(--tms-surface); border:3px solid var(--col-accent);
}
.tms-timeline-item.muted::before { border-color: var(--tms-border); }

/* ------------------------------------------------------------------ Misc / responsive */
.tms-navbar { z-index: 1040; }
@media (max-width: 991.98px) {
    .tms-sidebar {
        position: fixed; top: 0; bottom: 0; left: 0; height: 100vh;
        margin-left: calc(var(--tms-sidebar-width) * -1);
        z-index: 1050;
    }
    .tms-sidebar.show { margin-left: 0; box-shadow: 0 0 1rem rgba(0,0,0,.35); }
    .tms-sidebar-backdrop { display:none; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:1045; }
    .tms-sidebar-backdrop.show { display:block; }
}
@media (min-width: 992px) {
    body.sidebar-collapsed .tms-sidebar { margin-left: calc(var(--tms-sidebar-width) * -1); }
}

#tmsLoadingOverlay {
    position: fixed; inset: 0; z-index: 2000; display: none;
    align-items: center; justify-content: center; background: rgba(11,18,32,.35);
}
#tmsLoadingOverlay.show { display: flex; }
.tms-toast-container { z-index: 2100; }

/* ------------------------------------------------------------------ Auth (login) */
.tms-auth-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
    background: radial-gradient(1200px 500px at 50% -10%, rgba(21,47,82,.12), transparent), var(--tms-bg);
}
.tms-auth-card { width: 100%; max-width: 420px; border-radius: 18px; }
.tms-auth-logo { width: 250px; max-width: 80%; height: auto; }
