/* ==========================================================================
   HRM & Payroll — Admin theme
   Built on Bootstrap 5.3 (uses its native data-bs-theme dark mode).
   Only design tokens and layout chrome live here; components stay Bootstrap.
   ========================================================================== */

:root {
    --hrm-sidebar-width: 260px;
    --hrm-sidebar-collapsed: 74px;
    --hrm-header-height: 62px;
    /* ---- IGON SOFT brand palette (sampled from the logo) ----
       Blue = primary, Green = accent. */
    --hrm-brand: #37739d;
    --hrm-brand-rgb: 55, 115, 157;
    --hrm-brand-dark: #2c5f84;
    --hrm-accent: #77b541;
    --hrm-accent-rgb: 119, 181, 65;
    --hrm-accent-dark: #629a33;
    --hrm-sidebar-bg: #1e293b;
    --hrm-sidebar-color: #cbd5e1;
    --hrm-sidebar-active: #ffffff;
    --hrm-transition: 0.2s ease;
    /* Push the brand blue into Bootstrap's primary so links, checks, ranges,
       spinners, focus rings, etc. all pick it up. */
    --bs-primary: #37739d;
    --bs-primary-rgb: 55, 115, 157;
    --bs-link-color: #37739d;
    --bs-link-color-rgb: 55, 115, 157;
    --bs-link-hover-color: #2c5f84;
    /* Shared horizontal gutter for header + content; grows on wider screens so
       there's a proper margin on both sides instead of hugging the edge. */
    --hrm-gutter: 1.25rem;
}
@media (min-width: 992px) {
    :root { --hrm-gutter: 2rem; }
}
@media (min-width: 1400px) {
    :root { --hrm-gutter: 3rem; }
}
@media (min-width: 1800px) {
    :root { --hrm-gutter: 4rem; }
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    background-color: #f1f4f9;
    overflow-x: hidden;
}

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

/* ---- App shell -------------------------------------------------------- */
.hrm-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--hrm-sidebar-width);
    background: var(--hrm-sidebar-bg);
    color: var(--hrm-sidebar-color);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform var(--hrm-transition), width var(--hrm-transition);
}

.hrm-sidebar__brand {
    height: var(--hrm-header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 0 1rem;
    /* White band so the dark IGON SOFT wordmark stays legible on the dark rail. */
    background: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
}

/* Full logo (expanded sidebar) */
.hrm-brand-logo {
    height: 38px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

/* Compact mark (collapsed sidebar) — hidden by default */
.hrm-brand-mark {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--hrm-brand);
    color: #fff;
    font-size: 1.3rem;
    place-items: center;
}

.hrm-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem 0.65rem 1.5rem;
}

.hrm-sidebar__heading {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #64748b;
    padding: 1rem 0.9rem 0.35rem;
    white-space: nowrap;
}

.hrm-nav-link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.62rem 0.9rem;
    margin-bottom: 2px;
    border-radius: 9px;
    color: var(--hrm-sidebar-color);
    text-decoration: none;
    font-size: 0.925rem;
    white-space: nowrap;
    transition: background var(--hrm-transition), color var(--hrm-transition);
}

.hrm-nav-link i {
    font-size: 1.15rem;
    flex: 0 0 auto;
    width: 22px;
    text-align: center;
}

.hrm-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.hrm-nav-link.active {
    background: var(--hrm-brand);
    color: var(--hrm-sidebar-active);
    box-shadow: 0 6px 16px rgba(var(--hrm-brand-rgb), 0.35);
}

.hrm-nav-link .badge {
    margin-left: auto;
}

/* Main column offset by the sidebar */
.hrm-main {
    margin-left: var(--hrm-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--hrm-transition);
}

.hrm-header {
    height: var(--hrm-header-height);
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 var(--hrm-gutter);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.hrm-content {
    flex: 1;
    /* Horizontal gutter is shared with the header (via --hrm-gutter) so the page
       title and content align, and both keep a comfortable margin from the edge. */
    padding: 1.5rem var(--hrm-gutter);
}

.hrm-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    border: 1px solid var(--bs-border-color);
    background: transparent;
    color: var(--bs-body-color);
    font-size: 1.15rem;
    transition: background var(--hrm-transition);
}

.hrm-icon-btn:hover {
    background: var(--bs-secondary-bg);
}

/* ---- Collapsed sidebar (desktop) ------------------------------------- */
body.hrm-sidebar-collapsed .hrm-sidebar {
    width: var(--hrm-sidebar-collapsed);
}
body.hrm-sidebar-collapsed .hrm-sidebar .hrm-brand-text,
body.hrm-sidebar-collapsed .hrm-sidebar .hrm-nav-link span,
body.hrm-sidebar-collapsed .hrm-sidebar .hrm-sidebar__heading {
    display: none;
}
body.hrm-sidebar-collapsed .hrm-sidebar .hrm-nav-link {
    justify-content: center;
    padding-inline: 0;
}
/* Collapsed rail: hide the full wordmark, show the compact square mark. */
body.hrm-sidebar-collapsed .hrm-sidebar .hrm-brand-logo {
    display: none;
}
body.hrm-sidebar-collapsed .hrm-sidebar .hrm-brand-mark {
    display: grid;
}
body.hrm-sidebar-collapsed .hrm-main {
    margin-left: var(--hrm-sidebar-collapsed);
}

/* ---- Cards & widgets -------------------------------------------------- */
.hrm-card {
    /* .hrm-card is a custom card, NOT Bootstrap's .card, so Bootstrap never sets
       the --bs-card-* spacer vars its child .card-body / .card-header / .card-footer
       rely on. Define them here so those elements get proper symmetric padding
       (otherwise .card-body collapses to 0 padding and content hugs the edges). */
    --bs-card-spacer-y: 1.25rem;
    --bs-card-spacer-x: 1.25rem;
    --bs-card-cap-padding-y: 0.85rem;
    --bs-card-cap-padding-x: 1.25rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 14px;
    background: var(--bs-body-bg);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* Fallback padding in case Bootstrap's .card-body rule (which consumes the vars
   above) isn't present — guarantees the internal gutter on every side. */
.hrm-card > .card-body {
    padding: var(--bs-card-spacer-y) var(--bs-card-spacer-x);
}
.hrm-card > .card-header,
.hrm-card > .card-footer {
    padding: var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x);
}

.hrm-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
}

.hrm-stat__icon {
    width: 54px;
    height: 54px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    flex: 0 0 auto;
}

.hrm-stat__value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}

.hrm-stat__label {
    color: var(--bs-secondary-color);
    font-size: 0.85rem;
}

.tint-primary { background: rgba(var(--hrm-brand-rgb), 0.12); color: var(--hrm-brand); }
.tint-success { background: rgba(var(--hrm-accent-rgb), 0.15); color: var(--hrm-accent-dark); }
.tint-warning { background: rgba(217, 119, 6, 0.14); color: #d97706; }
.tint-info    { background: rgba(2, 132, 199, 0.12); color: #0284c7; }
.tint-accent  { background: rgba(var(--hrm-accent-rgb), 0.15); color: var(--hrm-accent-dark); }

/* ---- Brand overrides for Bootstrap components -------------------------
   Bootstrap compiles .btn-primary / .text-bg-primary / .bg-primary with literal
   hex, so overriding --bs-primary alone isn't enough — re-point them at the
   IGON brand blue here. */
.btn-primary {
    --bs-btn-bg: var(--hrm-brand);
    --bs-btn-border-color: var(--hrm-brand);
    --bs-btn-hover-bg: var(--hrm-brand-dark);
    --bs-btn-hover-border-color: var(--hrm-brand-dark);
    --bs-btn-active-bg: var(--hrm-brand-dark);
    --bs-btn-active-border-color: var(--hrm-brand-dark);
    --bs-btn-disabled-bg: var(--hrm-brand);
    --bs-btn-disabled-border-color: var(--hrm-brand);
    --bs-btn-focus-shadow-rgb: var(--hrm-brand-rgb);
}
.btn-outline-primary {
    --bs-btn-color: var(--hrm-brand);
    --bs-btn-border-color: var(--hrm-brand);
    --bs-btn-hover-bg: var(--hrm-brand);
    --bs-btn-hover-border-color: var(--hrm-brand);
    --bs-btn-active-bg: var(--hrm-brand);
    --bs-btn-active-border-color: var(--hrm-brand);
    --bs-btn-focus-shadow-rgb: var(--hrm-brand-rgb);
}
.btn-success {
    --bs-btn-bg: var(--hrm-accent);
    --bs-btn-border-color: var(--hrm-accent);
    --bs-btn-hover-bg: var(--hrm-accent-dark);
    --bs-btn-hover-border-color: var(--hrm-accent-dark);
    --bs-btn-active-bg: var(--hrm-accent-dark);
    --bs-btn-active-border-color: var(--hrm-accent-dark);
    --bs-btn-disabled-bg: var(--hrm-accent);
    --bs-btn-disabled-border-color: var(--hrm-accent);
}
.text-bg-primary {
    background-color: rgba(var(--hrm-brand-rgb), var(--bs-bg-opacity, 1)) !important;
    color: #fff !important;
}
.text-bg-success {
    background-color: rgba(var(--hrm-accent-rgb), var(--bs-bg-opacity, 1)) !important;
    color: #fff !important;
}
.bg-primary { background-color: var(--hrm-brand) !important; }
.bg-success { background-color: var(--hrm-accent) !important; }
.text-primary { color: var(--hrm-brand) !important; }
.text-success { color: var(--hrm-accent-dark) !important; }
.border-primary { border-color: var(--hrm-brand) !important; }
.progress-bar.bg-primary { background-color: var(--hrm-brand) !important; }
.progress-bar.bg-success { background-color: var(--hrm-accent) !important; }
a { color: var(--hrm-brand); }
a:hover { color: var(--hrm-brand-dark); }
.link-primary { color: var(--hrm-brand) !important; }
.form-check-input:checked {
    background-color: var(--hrm-brand);
    border-color: var(--hrm-brand);
}
.form-control:focus,
.form-select:focus {
    border-color: rgba(var(--hrm-brand-rgb), 0.5);
    box-shadow: 0 0 0 0.2rem rgba(var(--hrm-brand-rgb), 0.2);
}

/* ---- Auth screen ------------------------------------------------------ */
.hrm-auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    /* IGON brand: blue glow top-right, green glow bottom-left. */
    background:
        radial-gradient(1200px 600px at 100% 0%, rgba(var(--hrm-brand-rgb), 0.28), transparent 60%),
        radial-gradient(1000px 500px at 0% 100%, rgba(var(--hrm-accent-rgb), 0.22), transparent 55%),
        #0f172a;
}

.hrm-auth__card {
    width: 100%;
    max-width: 420px;
    border-radius: 18px;
    background: var(--bs-body-bg);
    box-shadow: 0 24px 60px rgba(2, 6, 23, 0.45);
    overflow: hidden;
}

.hrm-auth__head {
    padding: 2rem 2rem 0.5rem;
    text-align: center;
}

.hrm-auth__logo {
    width: 56px;
    height: 56px;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--hrm-brand), #7c3aed);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.7rem;
    margin: 0 auto 0.85rem;
    box-shadow: 0 10px 24px rgba(var(--hrm-brand-rgb), 0.4);
}

.hrm-auth__body {
    padding: 1.25rem 2rem 2rem;
}

/* ---- Sidebar overlay (mobile) ---------------------------------------- */
.hrm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.5);
    z-index: 1035;
    display: none;
}

@media (max-width: 991.98px) {
    .hrm-sidebar {
        transform: translateX(-100%);
    }
    body.hrm-sidebar-open .hrm-sidebar {
        transform: translateX(0);
    }
    body.hrm-sidebar-open .hrm-backdrop {
        display: block;
    }
    .hrm-main {
        margin-left: 0;
    }
}

/* Thin scrollbar for the sidebar */
.hrm-sidebar__nav::-webkit-scrollbar { width: 6px; }
.hrm-sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

/* ---- Auto-fit card grid ----------------------------------------------- */
/* Cards/items stretch to fill the row no matter how many there are, so a
   couple of items never leave a big empty gap on the right. They wrap and keep
   a sensible minimum width instead. */
.hrm-autogrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--hrm-grid-min, 280px)), 1fr));
    gap: 1rem;
}
.hrm-autogrid.hrm-autogrid--sm {
    --hrm-grid-min: 220px;
}

/* ---- Filter forms ----------------------------------------------------- */
/* Bottom-align every column so labelled and unlabelled fields (and the
   Filter/Reset buttons) line up on their baseline across all index pages. */
.hrm-filter-form {
    align-items: flex-end;
}
.hrm-filter-form .form-label {
    margin-bottom: 0.25rem;
}

/* ---- Print ------------------------------------------------------------ */
@media print {
    .hrm-sidebar,
    .hrm-header,
    .hrm-backdrop,
    footer,
    .no-print,
    .dropdown,
    .pagination,
    form.hrm-filter-form { display: none !important; }

    .hrm-main { margin-left: 0 !important; }
    .hrm-content { padding: 0 !important; }
    .hrm-card { border: none !important; box-shadow: none !important; }
    body { background: #fff !important; }
    a[href]::after { content: none !important; }
}
