/* ASSETTAG 2.0 - App-wide styling
   Loaded on every admin/superadmin page, right after Bootstrap.
   Bootstrap 5.3 exposes its palette as CSS variables, so overriding
   these here reskins buttons, links, focus rings, etc. everywhere
   at once - no need to touch class names in every screen. */

:root {
    --at-ink: #16232E;
    --at-ledger: #1F4B3F;
    --at-ledger-dark: #163A31;
    --at-brass: #C98A3B;
    --at-paper: #F7F5F0;
    --at-line: #DDD8CC;
    --at-slate: #5B6570;

    --bs-primary: var(--at-ledger);
    --bs-primary-rgb: 31, 75, 63;
    --bs-link-color: var(--at-ledger);
    --bs-link-hover-color: var(--at-ledger-dark);
    --bs-link-color-rgb: 31, 75, 63;
    --bs-body-font-family: 'Inter', -apple-system, sans-serif;
    --bs-border-radius: .5rem;
    --bs-border-radius-sm: .375rem;
    --bs-border-radius-lg: .65rem;
}

body {
    background: var(--at-paper);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-weight: 700;
    color: var(--at-ink);
}

/* Navbar */
.navbar.bg-dark, nav.navbar.bg-dark {
    background-color: var(--at-ink) !important;
}

/* Buttons */
.btn-primary {
    background-color: var(--at-ledger);
    border-color: var(--at-ledger);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--at-ledger-dark);
    border-color: var(--at-ledger-dark);
}
.btn-outline-primary {
    color: var(--at-ledger);
    border-color: var(--at-ledger);
}
.btn-outline-primary:hover {
    background-color: var(--at-ledger);
    border-color: var(--at-ledger);
}
.btn-outline-danger { --bs-btn-color: #b3392f; --bs-btn-border-color: #b3392f; }

/* Cards */
.card {
    border: 1px solid var(--at-line);
    box-shadow: 0 1px 3px rgba(22, 35, 46, .04);
}
.card-header {
    background-color: #FBFAF7;
    font-weight: 600;
    border-bottom: 1px solid var(--at-line);
}

/* Tables */
.table > :not(caption) > * > * {
    border-bottom-color: var(--at-line);
}
.table-light, thead.table-light {
    --bs-table-bg: #F0EEE6;
}
.table-danger { --bs-table-bg: #FBEAE8; }
.table-warning { --bs-table-bg: #FBF3E3; }

/* Badges */
.badge.bg-secondary { background-color: var(--at-slate) !important; }
.badge.bg-success { background-color: var(--at-ledger) !important; }

/* Forms */
.form-control:focus, .form-select:focus {
    border-color: var(--at-ledger);
    box-shadow: 0 0 0 .2rem rgba(31, 75, 63, .15);
}
.form-label {
    font-weight: 500;
    font-size: .9rem;
}

/* Sidebar (used across all admin/superadmin screens via layout-top.php) */
.border-end.bg-white a {
    color: var(--at-ink);
}
.border-end.bg-white a:hover {
    color: var(--at-ledger);
}

/* ---------------------------------------------------------------
   Icon-based stat cards (dashboard KPIs) - replaces the plain
   text-in-a-box treatment. Each card gets a colored top accent and
   an icon in a tinted circle, matching the visual language a modern
   SaaS dashboard is expected to have - this was the single biggest
   gap flagged: numbers alone, no icon, no color, no hierarchy.
   ------------------------------------------------------------ */
.stat-card {
    background: #fff;
    border: 1px solid var(--at-line);
    border-radius: 14px;
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(22,35,46,.04), 0 8px 20px -12px rgba(22,35,46,.10);
    transition: transform .15s ease, box-shadow .15s ease;
    height: 100%;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--stat-accent, var(--at-ledger));
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(22,35,46,.06), 0 14px 28px -14px rgba(22,35,46,.16); }
.stat-card .stat-icon {
    width: 42px; height: 42px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--stat-accent, var(--at-ledger)) 14%, white);
    color: var(--stat-accent, var(--at-ledger));
    margin-bottom: 14px;
}
.stat-card .stat-icon svg { width: 22px; height: 22px; }
.stat-card .stat-label { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--at-slate); margin-bottom: 2px; }
.stat-card .stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 30px; font-weight: 700; color: var(--at-ink); line-height: 1.1; }
.stat-card .stat-sub { font-size: 12px; color: var(--at-slate); margin-top: 4px; }
.stat-card .stat-link { font-size: 12px; font-weight: 600; color: var(--at-ledger); text-decoration: none; display: inline-block; margin-top: 10px; }
.stat-card .stat-link:hover { text-decoration: underline; }
.stat-card--ledger { --stat-accent: var(--at-ledger); }
.stat-card--brass  { --stat-accent: var(--at-brass); }
.stat-card--navy   { --stat-accent: var(--at-ink); }
.stat-card--slate  { --stat-accent: #6B7A8F; }
.stat-card--danger { --stat-accent: #C0392B; }

/* Plan-breakdown mini-list inside a stat card, when a card shows more
   than one number (e.g. Plans in Use) */
.stat-card .mini-list { margin-top: 4px; }
.stat-card .mini-list .row-item { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; color: var(--at-ink); }
.stat-card .mini-list .row-item span:first-child { color: var(--at-slate); }

/* Navbar avatar chip - replaces plain "Name (role)" text with a
   proper identity treatment: initials in a colored circle, name,
   role as a small pill underneath. */
.navbar-identity { display: flex; align-items: center; gap: 10px; }
.navbar-identity .avatar-circle {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--at-brass);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.navbar-identity .identity-text { line-height: 1.25; text-align: left; }
.navbar-identity .identity-name { font-size: 13.5px; font-weight: 600; color: #fff; }
.navbar-identity .identity-role {
    font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--at-brass-light, #E0AA5F);
}

/* Section heading with icon - used above dashboard tables/blocks so
   each section reads as a distinct, labelled zone. */
.section-heading { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--at-ink); margin-bottom: 12px; }
.section-heading svg { width: 18px; height: 18px; color: var(--at-ledger); }

/* Polished table card wrapper - rounded container with its own
   header bar, instead of a bare Bootstrap card-header */
.data-card { background: #fff; border: 1px solid var(--at-line); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 2px rgba(22,35,46,.04), 0 8px 20px -12px rgba(22,35,46,.08); }

/* Form card - richer treatment for Add/Edit forms, matching the
   data-card standard set for tables. A colored top accent plus more
   breathing room, so a form reads as a deliberate "task" rather than
   a plain bordered box. */
.form-card {
    background: #fff;
    border: 1px solid var(--at-line);
    border-radius: 14px;
    padding: 28px 30px;
    box-shadow: 0 1px 2px rgba(22,35,46,.04), 0 8px 20px -12px rgba(22,35,46,.10);
    position: relative;
    overflow: hidden;
}
.form-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--at-ledger);
}
/* Section labels inside a form ("Identity", "Purchase", etc.) - was
   plain text-muted uppercase before, now gets a small icon-style dot
   and a rule, reading as a distinct step rather than a stray label */
.form-card h6.text-uppercase {
    display: flex; align-items: center; gap: 8px;
    padding-bottom: 8px; margin-bottom: 16px !important;
    border-bottom: 1px solid var(--at-line);
    color: var(--at-ledger) !important;
    font-weight: 700 !important;
}
.form-card h6.text-uppercase::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--at-brass); flex-shrink: 0;
}
.form-card .form-label { font-weight: 500; font-size: 14px; color: var(--at-ink); margin-bottom: 5px; }
.form-card .form-control, .form-card .form-select { border-color: var(--at-line); }
.form-card .form-control:focus, .form-card .form-select:focus { border-color: var(--at-ledger); box-shadow: 0 0 0 3px rgba(31,75,63,.10); }
.data-card .data-card-header { padding: 14px 18px; border-bottom: 1px solid var(--at-line); display: flex; justify-content: space-between; align-items: center; background: #FBFAF6; }
.data-card .data-card-header h6 { margin: 0; font-weight: 600; }
.data-card table { margin-bottom: 0; }
.data-card table th { border-top: none; background: #FBFAF6; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--at-slate); }

/* Icon action buttons - compact circular buttons for row actions
   (view/edit), matching a denser, more information-rich table style */
.btn-icon {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--at-line);
    background: #fff;
    color: var(--at-ink);
    transition: background .15s ease, border-color .15s ease;
}
.btn-icon:hover { background: #F3F1E9; border-color: var(--at-ledger); color: var(--at-ledger); }
.btn-icon svg { width: 16px; height: 16px; }

/* Utility */
.text-muted { color: var(--at-slate) !important; }

/* ---------------------------------------------------------------
   UI/UX polish pass - app-wide, not just landing page/navbar.
   Everything below rides on the design tokens already defined
   above, so it applies consistently across every screen that
   loads this file without touching individual page markup.
   ------------------------------------------------------------ */

/* Page heading - a bit more breathing room and a subtle rule so
   every screen reads as a distinct "page", not a floating h4.
   (Superseded by .at-page-header below, which wraps the h4 as of the
   breadcrumb/page-header system - rule kept harmless as a fallback for
   any page that somehow renders an h4 outside that wrapper.) */
.p-4.flex-grow-1 > h4:first-child {
    padding-bottom: .65rem;
    margin-bottom: 1.25rem !important;
    border-bottom: 1px solid var(--at-line);
}

/* Cards: soften the corners a touch more, give card bodies consistent breathing room */
.card { border-radius: var(--bs-border-radius-lg); }
.card-header { border-radius: var(--bs-border-radius-lg) var(--bs-border-radius-lg) 0 0 !important; letter-spacing: .01em; }

/* Tables: friendlier row hover + slightly larger tap targets, still compact for print */
.table-hover > tbody > tr:hover > * { background-color: #F3F1E9; }
.table th { font-weight: 600; color: var(--at-ink); }
.table td, .table th { vertical-align: middle; }

/* Buttons: consistent letter-spacing and weight so CTAs feel intentional, not default-Bootstrap */
.btn { font-weight: 500; letter-spacing: .01em; }
.btn-sm { border-radius: var(--bs-border-radius-sm); }

/* Badges: slightly larger, consistent padding so status is scannable at a glance */
.badge { font-weight: 500; padding: .4em .65em; letter-spacing: .01em; }

/* Sidebar active-link state - was missing entirely, made every screen's
   nav look the same regardless of where you actually were */
.border-end.bg-white a.active-link {
    color: var(--at-ledger);
    font-weight: 600;
    position: relative;
}
.border-end.bg-white a.active-link::before {
    content: '';
    position: absolute;
    left: -12px; top: 2px; bottom: 2px;
    width: 3px;
    background: var(--at-brass);
    border-radius: 2px;
}

/* Alerts: align to brand palette instead of default Bootstrap red/green */
.alert-success { background-color: #EAF2EC; border-color: #BFDACB; color: var(--at-ledger-dark); }
.alert-danger { background-color: #FBEAE8; border-color: #F0C9C4; color: #7A2820; }
.alert-warning { background-color: #FBF3E3; border-color: #EBD9AE; color: #7A5A18; }

/* ---------------------------------------------------------------
   Mobile-responsive sidebar
   Below 768px the fixed 240px sidebar used to just squeeze the
   page content into a sliver. Asset Auditors specifically use this
   app in the field on a phone, so this isn't a nice-to-have.
   Sidebar becomes an off-canvas drawer, toggled by a hamburger
   button injected into the navbar (see layout-top.php).
   ------------------------------------------------------------ */
.at-sidebar-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255,255,255,.35);
    color: #fff;
    border-radius: .375rem;
    padding: .3rem .6rem;
    font-size: 1.1rem;
    line-height: 1;
}

@media (max-width: 767.98px) {
    .at-sidebar-toggle { display: inline-block; }

    .at-app-sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 1045;
        width: 250px;
        transform: translateX(-100%);
        transition: transform .2s ease-in-out;
        overflow-y: auto;
        padding-top: 60px !important;
    }
    .at-app-sidebar.at-sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 18px rgba(22,35,46,.25);
    }
    .at-sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(22,35,46,.45);
        z-index: 1040;
    }
    .at-sidebar-backdrop.at-sidebar-open { display: block; }

    .p-4.flex-grow-1 { padding: 1rem !important; width: 100%; }

    /* Tables scroll horizontally instead of squeezing off-screen on a phone */
    .table-responsive-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Filter/search forms stack full-width on phones instead of cramped columns */
    form.row.g-2 > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
}

/* ---------------------------------------------------------------
   Breadcrumb + Page Header system
   New wrapper around the old bare <h4> - every page now gets a
   breadcrumb trail, the title, an optional one-line description,
   and an optional right-aligned action button area, without any
   existing page needing to change (defaults kick in automatically).
   ------------------------------------------------------------ */
.at-breadcrumb {
    font-size: 12.5px;
    color: var(--at-slate);
    margin-bottom: 10px;
}
.at-breadcrumb a { color: var(--at-slate); text-decoration: none; }
.at-breadcrumb a:hover { color: var(--at-ledger); text-decoration: underline; }
.at-breadcrumb-sep { margin: 0 6px; color: var(--at-line); }
.at-breadcrumb-current { color: var(--at-ink); font-weight: 600; }

.at-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: .75rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--at-line);
}
.at-page-header h4 { margin-bottom: 2px; }
.at-page-description { color: var(--at-slate); font-size: 14px; margin: 0; max-width: 620px; }
.at-page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------
   Sidebar accordion groups
   Each menu section is now a <details><summary> block - collapsible,
   with an icon, instead of a bare uppercase <h6>. Uses the browser's
   native disclosure widget so it works with zero JS as a baseline;
   the JS in layout-bottom.php only adds persistence + auto-expand of
   whichever group the current page belongs to.
   ------------------------------------------------------------ */
.at-app-sidebar { transition: width .18s ease; }
.at-rail-toggle {
    width: 100%;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--at-slate);
    padding: 2px 4px 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--at-line);
}
.at-rail-toggle:hover { color: var(--at-ledger); }
.at-rail-toggle svg { width: 16px; height: 16px; transition: transform .18s ease; }

details.at-nav-group { margin-bottom: 4px; }
details.at-nav-group summary {
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
    cursor: pointer;
    padding: 8px 6px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--at-slate);
}
details.at-nav-group summary::-webkit-details-marker { display: none; }
details.at-nav-group summary:hover { background: #F3F1E9; color: var(--at-ink); }
details.at-nav-group summary::after {
    content: '';
    width: 7px; height: 7px;
    margin-left: auto;
    border-right: 1.6px solid currentColor;
    border-bottom: 1.6px solid currentColor;
    transform: rotate(45deg);
    transition: transform .15s ease;
    opacity: .6;
}
details.at-nav-group[open] > summary::after { transform: rotate(-135deg); }
.at-nav-icon { display: flex; flex-shrink: 0; color: var(--at-ledger); }
.at-nav-icon svg { width: 16px; height: 16px; }
details.at-nav-group ul { padding-left: 32px; margin-top: 2px; }
details.at-nav-group ul li a { display: block; padding: 5px 6px; border-radius: 6px; font-size: 14px; }
details.at-nav-group ul li a:hover { background: #F3F1E9; }

/* Desktop "rail" (icon-only) collapse mode */
@media (min-width: 768px) {
    .at-app-sidebar.at-sidebar-rail { width: 60px !important; padding-left: 8px !important; padding-right: 8px !important; }
    .at-sidebar-rail .at-nav-label,
    .at-sidebar-rail details.at-nav-group ul,
    .at-sidebar-rail summary::after { display: none; }
    .at-sidebar-rail .at-rail-toggle { justify-content: center; }
    .at-sidebar-rail .at-rail-toggle svg { transform: rotate(180deg); }
    .at-sidebar-rail details.at-nav-group summary { justify-content: center; padding: 10px 0; }
}

/* ---------------------------------------------------------------
   Dashboard intelligence panels - Attention Required, Recent
   Activity, Top Assets, Idle Assets, Under Repair. Shared visual
   language with the existing .data-card / .stat-card system already
   established above, so these read as part of the same product,
   not a bolted-on new style.
   ------------------------------------------------------------ */
.at-attention-list { list-style: none; margin: 0; padding: 0; }
.at-attention-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--at-line);
    font-size: 14px;
    text-decoration: none;
    color: var(--at-ink);
}
.at-attention-item:last-child { border-bottom: none; }
.at-attention-item:hover { background: #FBFAF6; }
.at-attention-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.at-attention-dot.red   { background: #C0392B; }
.at-attention-dot.amber { background: var(--at-brass); }
.at-attention-dot.blue  { background: #2E5F8A; }
.at-attention-empty { color: var(--at-slate); font-size: 14px; padding: 14px 4px; text-align: center; }

.at-activity-list { list-style: none; margin: 0; padding: 0; }
.at-activity-item { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--at-line); font-size: 14px; }
.at-activity-item:last-child { border-bottom: none; }
.at-activity-time { color: var(--at-slate); font-size: 11.5px; white-space: nowrap; flex-shrink: 0; width: 78px; padding-top: 1px; }
.at-activity-text { color: var(--at-ink); }

.at-mini-table { width: 100%; font-size: 14px; }
.at-mini-table th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--at-slate); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--at-line); text-align: left; }
.at-mini-table td { padding: 8px; border-bottom: 1px solid var(--at-line); vertical-align: middle; }
.at-mini-table tr:last-child td { border-bottom: none; }
.at-mini-table .text-danger-strong { color: #C0392B; font-weight: 600; }

/* Simple horizontal bar used inside location/category/vendor intelligence
   cards - a plain proportional bar, not a chart library instance, since
   these are small in-list indicators rather than standalone charts */
.at-bar-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px; font-size: 12.5px; }
.at-bar-label { width: 38%; color: var(--at-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.at-bar-track { flex: 1; height: 8px; background: #F0EEE6; border-radius: 4px; overflow: hidden; }
.at-bar-fill { height: 100%; background: var(--at-ledger); border-radius: 4px; }
/* Rotating palette so a panel with several ranked bars reads as
   distinct items at a glance, not one undifferentiated green block -
   reuses the exact same 4 brand colours already used on stat cards and
   charts elsewhere, just applied per-rank instead of always the same one. */
.at-bar-fill--0 { background: var(--at-ledger); }
.at-bar-fill--1 { background: var(--at-brass); }
.at-bar-fill--2 { background: var(--at-ink); }
.at-bar-fill--3 { background: #6B7A8F; }
.at-bar-fill--4 { background: #8FA998; }
.at-bar-fill--5 { background: #B37A2E; }
.at-bar-value { width: 90px; text-align: right; color: var(--at-slate); flex-shrink: 0; }

/* Small numbered rank badge - reuses the same rotating palette as the
   bar-fill classes above, for ranked lists (Highest Value Assets etc)
   that were previously plain unbadged text rows. */
.at-rank-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.at-rank-badge--0 { background: var(--at-ledger); }
.at-rank-badge--1 { background: var(--at-brass); }
.at-rank-badge--2 { background: var(--at-ink); }
.at-rank-badge--3 { background: #6B7A8F; }
.at-rank-badge--4 { background: #8FA998; }

.at-tab-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--at-line); margin-bottom: 14px; }
.at-tab-nav a { padding: 8px 14px; font-size: 14px; font-weight: 600; color: var(--at-slate); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.at-tab-nav a.active { color: var(--at-ledger); border-bottom-color: var(--at-ledger); }

/* Navbar global search box */
.at-navbar-search { margin-left: 24px; width: 280px; }
.at-navbar-search input { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.at-navbar-search input::placeholder { color: rgba(255,255,255,.6); }
.at-navbar-search input:focus { background: #fff; color: var(--at-ink); }
