/* ==========================================================================
   HR Manager – application shell styling
   All themeable colours come from CSS custom properties emitted by
   App\Services\ThemeService (see <style id="hris-theme"> in the layout head).
   ========================================================================== */

:root {
    --hris-primary: #4f46e5;
    --hris-primary-rgb: 79, 70, 229;
    --hris-primary-hover: #4238c9;
    --hris-primary-soft: #eef2ff;
    --hris-secondary: #64748b;
    --hris-accent: #0ea5e9;
    --hris-success: #16a34a;
    --hris-warning: #f59e0b;
    --hris-danger: #dc2626;
    --hris-sidebar-bg: #1e293b;
    --hris-sidebar-text: #cbd5e1;
    --hris-navbar-bg: #ffffff;
    --hris-body-bg: #f1f5f9;
    --hris-radius: 0.5rem;

    --hris-sidebar-width: 264px;
    --hris-sidebar-collapsed-width: 76px;
    --hris-topbar-height: 62px;
}

/* ----- base ----- */
body {
    background-color: var(--hris-body-bg);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1e293b;
    min-height: 100vh;
}

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

a { text-decoration: none; }

.btn-primary {
    --bs-btn-bg: var(--hris-primary);
    --bs-btn-border-color: var(--hris-primary);
    --bs-btn-hover-bg: var(--hris-primary-hover);
    --bs-btn-hover-border-color: var(--hris-primary-hover);
    --bs-btn-active-bg: var(--hris-primary-hover);
    --bs-btn-active-border-color: var(--hris-primary-hover);
    --bs-btn-disabled-bg: var(--hris-primary);
    --bs-btn-disabled-border-color: var(--hris-primary);
}

.btn-outline-primary {
    --bs-btn-color: var(--hris-primary);
    --bs-btn-border-color: var(--hris-primary);
    --bs-btn-hover-bg: var(--hris-primary);
    --bs-btn-hover-border-color: var(--hris-primary);
    --bs-btn-active-bg: var(--hris-primary);
    --bs-btn-active-border-color: var(--hris-primary);
}

.text-primary { color: var(--hris-primary) !important; }
.bg-primary { background-color: var(--hris-primary) !important; }
.link-primary { color: var(--hris-primary) !important; }

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: rgba(var(--hris-primary-rgb), 0.55);
    box-shadow: 0 0 0 0.2rem rgba(var(--hris-primary-rgb), 0.18);
}
.form-check-input:checked {
    background-color: var(--hris-primary);
    border-color: var(--hris-primary);
}

/* ==========================================================================
   Layout: sidebar + topbar + content
   ========================================================================== */
.app {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--hris-sidebar-width);
    background-color: var(--hris-sidebar-bg);
    color: var(--hris-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1045;
    transition: width .2s ease, transform .2s ease;
    overflow: hidden;
}
.app-sidebar.is-light {
    background-color: #ffffff;
    color: #475569;
    border-right: 1px solid #e2e8f0;
}

.app-sidebar__brand {
    height: var(--hris-topbar-height);
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.1rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    flex-shrink: 0;
    white-space: nowrap;
}
.app-sidebar.is-light .app-sidebar__brand { color: #0f172a; }
.app-sidebar__brand img { height: 30px; width: auto; }
.app-sidebar__brand-badge {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--hris-primary);
    color: #fff; display: grid; place-items: center;
    font-size: 1.05rem; flex-shrink: 0;
}

.app-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .5rem .6rem 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.app-sidebar__nav::-webkit-scrollbar { width: 6px; }
.app-sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 3px; }

.app-sidebar__heading {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    opacity: .5;
    padding: 1rem .8rem .35rem;
    white-space: nowrap;
}

.nav-link-hris {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .58rem .8rem;
    border-radius: var(--hris-radius);
    color: inherit;
    font-size: .9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .12s ease, color .12s ease;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
}
.nav-link-hris .bi:first-child {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}
.nav-link-hris:hover {
    background-color: rgba(255, 255, 255, .08);
    color: #fff;
}
.app-sidebar.is-light .nav-link-hris:hover {
    background-color: var(--hris-primary-soft);
    color: var(--hris-primary);
}
.nav-link-hris.is-active {
    background-color: var(--hris-primary);
    color: #fff;
    box-shadow: 0 6px 16px -6px rgba(var(--hris-primary-rgb), .6);
}
.nav-link-hris.is-disabled {
    opacity: .45;
    cursor: not-allowed;
}
.nav-link-hris__chevron {
    margin-left: auto;
    font-size: .8rem;
    transition: transform .18s ease;
}
.nav-group.is-open .nav-link-hris__chevron { transform: rotate(90deg); }

.nav-group__items {
    display: none;
    padding: .15rem 0 .15rem 2.35rem;
}
.nav-group.is-open .nav-group__items { display: block; }
.nav-group__items .nav-link-hris {
    padding: .45rem .7rem;
    font-size: .85rem;
    font-weight: 500;
}

.badge-soon {
    margin-left: auto;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: rgba(255,255,255,.12);
    color: inherit;
    padding: .18rem .4rem;
    border-radius: 6px;
}
.app-sidebar.is-light .badge-soon { background: #f1f5f9; color: #64748b; }

/* main column */
.app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--hris-sidebar-width);
    display: flex;
    flex-direction: column;
    transition: margin-left .2s ease;
}

.app-topbar {
    height: var(--hris-topbar-height);
    background-color: var(--hris-navbar-bg);
    border-bottom: 1px solid rgba(15, 23, 42, .08);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}
[data-bs-theme="dark"] .app-topbar {
    background-color: #0f172a;
    border-bottom-color: rgba(255,255,255,.06);
}

.app-content {
    padding: 1.4rem 1.4rem 3rem;
    flex: 1;
}
@media (min-width: 992px) {
    .app-content { padding: 1.75rem 2rem 3rem; }
}

/* collapsed (desktop) */
@media (min-width: 992px) {
    .app.is-collapsed .app-sidebar { width: var(--hris-sidebar-collapsed-width); }
    .app.is-collapsed .app-main { margin-left: var(--hris-sidebar-collapsed-width); }
    .app.is-collapsed .app-sidebar__nav-text,
    .app.is-collapsed .app-sidebar__heading,
    .app.is-collapsed .nav-link-hris__chevron,
    .app.is-collapsed .badge-soon,
    .app.is-collapsed .app-sidebar__brand-text { display: none; }
    .app.is-collapsed .nav-link-hris { justify-content: center; gap: 0; }
    .app.is-collapsed .nav-group__items { display: none !important; }
}

/* mobile: off-canvas sidebar */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 45px rgba(0,0,0,.35);
    }
    .app.is-mobile-open .app-sidebar { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .5);
        z-index: 1040;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }
    .app.is-mobile-open .app-backdrop { opacity: 1; pointer-events: auto; }
}

/* ==========================================================================
   Components
   ========================================================================== */
.hris-card {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .07);
    border-radius: calc(var(--hris-radius) + .15rem);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
[data-bs-theme="dark"] .hris-card {
    background: #0f172a;
    border-color: rgba(255,255,255,.07);
}
.hris-card__body { padding: 1.15rem 1.25rem; }
.hris-card__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(15, 23, 42, .07);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
}
[data-bs-theme="dark"] .hris-card__header { border-bottom-color: rgba(255,255,255,.07); }

.stat-card { position: relative; overflow: hidden; }
.stat-card__icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}
.stat-card__value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat-card__label { font-size: .82rem; color: #64748b; font-weight: 500; }
[data-bs-theme="dark"] .stat-card__label { color: #94a3b8; }
.stat-card__hint { font-size: .72rem; color: #94a3b8; }

.tone-primary   { background: rgba(var(--hris-primary-rgb), .12);  color: var(--hris-primary); }
.tone-success   { background: rgba(22, 163, 74, .12);  color: #16a34a; }
.tone-warning   { background: rgba(245, 158, 11, .15); color: #b45309; }
.tone-danger    { background: rgba(220, 38, 38, .12);  color: #dc2626; }
.tone-accent    { background: rgba(14, 165, 233, .12); color: #0ea5e9; }
.tone-secondary { background: rgba(100, 116, 139, .14); color: #475569; }

.page-header { margin-bottom: 1.4rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-header p { color: #64748b; margin: .2rem 0 0; font-size: .9rem; }

.breadcrumb { --bs-breadcrumb-divider: '›'; font-size: .82rem; margin: 0; }
.breadcrumb a { color: #64748b; }
.breadcrumb .active { color: #0f172a; }
[data-bs-theme="dark"] .breadcrumb .active { color: #e2e8f0; }

.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--hris-primary);
    color: #fff;
    display: grid; place-items: center;
    font-size: .8rem; font-weight: 700;
    flex-shrink: 0;
    object-fit: cover;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }

.icon-btn {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: #475569;
    display: grid; place-items: center;
    font-size: 1.1rem;
}
.icon-btn:hover { background: rgba(15,23,42,.06); }
[data-bs-theme="dark"] .icon-btn { color: #cbd5e1; }
[data-bs-theme="dark"] .icon-btn:hover { background: rgba(255,255,255,.08); }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}
.empty-state .bi { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .6; }

.swatch {
    width: 100%; height: 46px;
    border-radius: 10px;
    border: 1px solid rgba(15,23,42,.12);
}

.color-field { display: flex; align-items: center; gap: .6rem; }
.color-field input[type="color"] {
    width: 46px; height: 38px; padding: 2px;
    border-radius: 8px; border: 1px solid rgba(15,23,42,.15);
    background: #fff; cursor: pointer; flex-shrink: 0;
}

/* login / guest */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
}
@media (min-width: 992px) {
    .auth-wrap { grid-template-columns: 1.1fr 1fr; }
}
.auth-hero {
    display: none;
    padding: 3rem;
    color: #fff;
    background: linear-gradient(150deg, var(--hris-primary), var(--hris-primary-hover) 55%, #0b1120);
    flex-direction: column;
    justify-content: space-between;
}
@media (min-width: 992px) { .auth-hero { display: flex; } }
.auth-hero h2 { font-weight: 700; font-size: 1.9rem; }
.auth-hero ul { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.auth-hero li { padding: .35rem 0; opacity: .92; }
.auth-hero li .bi { margin-right: .55rem; }

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-brand {
    display: flex; align-items: center; gap: .6rem;
    font-weight: 700; font-size: 1.15rem; margin-bottom: 1.75rem;
}

.demo-creds { font-size: .8rem; }
.demo-creds button {
    border: 1px dashed rgba(15,23,42,.18);
    background: #f8fafc;
    border-radius: 8px;
    padding: .5rem .7rem;
    width: 100%;
    text-align: left;
    color: inherit;
}
.demo-creds button:hover { border-color: var(--hris-primary); background: var(--hris-primary-soft); }
[data-bs-theme="dark"] .demo-creds button { background: #1e293b; border-color: rgba(255,255,255,.14); }

/* Alpine: hide cloaked elements until the component initialises */
[x-cloak] { display: none !important; }

/* Print — used by the analytics reports "Print" button */
@media print {
    .app-sidebar,
    .app-topbar,
    .app-backdrop,
    footer,
    .analytics-no-print { display: none !important; }

    .app-main { margin-left: 0 !important; }
    .app-content { padding: 0 !important; }

    .hris-card { border: 1px solid #cbd5e1 !important; box-shadow: none !important; break-inside: avoid; }
    .page-header h1 { font-size: 18px; }
    a[href]::after { content: ""; }
    canvas { max-height: 260px; }
}

/* error pages */
.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 2rem;
}
.error-page__code {
    font-size: clamp(4rem, 14vw, 8rem);
    font-weight: 800;
    line-height: 1;
    color: var(--hris-primary);
}
