/*
 * UI refresh — loaded after style.css and BEFORE theme-light.css, so the
 * light theme's overrides still win where both apply. Everything here is
 * either theme-neutral (translucent greys, no hard-coded surfaces) or scoped
 * to the dark theme with `body:not(.bipm-light)`.
 */

:root {
    --bipm-accent: #f59e0b;
    --bipm-accent-rgb: 245, 158, 11;
    --bipm-ring: rgba(245, 158, 11, 0.55);
}
body.bipm-light {
    --bipm-accent: #960000;
    --bipm-accent-rgb: 150, 0, 0;
    --bipm-ring: rgba(150, 0, 0, 0.45);
}

/* ---------- typography ---------- */
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3 { letter-spacing: -0.01em; }
td, th, .tabular { font-variant-numeric: tabular-nums; }

/* ---------- focus + invalid states ---------- */
:focus-visible { outline: 2px solid var(--bipm-ring); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
/* Only after the user has interacted with the field (never on a fresh form). */
input:user-invalid, select:user-invalid, textarea:user-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}
input:disabled, select:disabled, textarea:disabled, button:disabled { cursor: not-allowed; }
button:not(:disabled):active { transform: translateY(1px); }
button, a { transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease, transform .08s ease; }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, .35) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .3); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, .5); }

/* ---------- sidebar ---------- */
.nav-tab { position: relative; text-align: left; }
.nav-tab.active {
    background-color: rgba(var(--bipm-accent-rgb), .14) !important;
    color: #fbbf24 !important;
    border-color: rgba(var(--bipm-accent-rgb), .4) !important;
    box-shadow: inset 3px 0 0 var(--bipm-accent);
}
.nav-tab:not(.active):hover { transform: translateX(2px); }
body.bipm-light .nav-tab.active { color: #960000 !important; }

/* ---------- cards, tables ---------- */
body:not(.bipm-light) .bg-slate-900.rounded-2xl {
    box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 12px 28px -18px rgba(0, 0, 0, .65);
}
thead th {
    font-size: .66rem !important;
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
}
tbody tr { transition: background-color .12s ease; }
.overflow-x-auto { -webkit-overflow-scrolling: touch; }

/* Friendly empty states (see mod-ui.js, which adds the icon). */
td.bipm-empty { padding-top: 2rem !important; padding-bottom: 2rem !important; }
.bipm-empty-icon { display: block; font-size: 1.6rem; margin-bottom: .35rem; }

/* ---------- leave calendar: weekly offs and holidays ---------- */
.bipm-cal-off { background: rgba(148, 163, 184, .16) !important; }

/* ---------- loading skeletons ---------- */
@keyframes bipm-pulse { 0%, 100% { opacity: .35; } 50% { opacity: .9; } }
.bipm-skeleton-text {
    position: relative; color: transparent !important; min-height: 3.25rem;
    border-radius: .75rem; overflow: hidden; background: rgba(148, 163, 184, .12);
    animation: bipm-pulse 1.3s ease-in-out infinite;
}

/* ---------- modals ---------- */
@keyframes bipm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bipm-pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.fixed.inset-0:not(.hidden) { animation: bipm-fade .14s ease-out; }
.fixed.inset-0:not(.hidden) > div { animation: bipm-pop .18s ease-out; }

/* ---------- command palette ---------- */
#bipm-palette { animation: bipm-fade .1s ease-out; }
#bipm-palette .bipm-pal-item[aria-selected="true"] { background: rgba(var(--bipm-accent-rgb), .12); }
#bipm-palette kbd, .bipm-kbd {
    font-family: inherit; font-size: .62rem; font-weight: 700; padding: .1rem .4rem;
    border-radius: .35rem; border: 1px solid rgba(148, 163, 184, .35); color: #94a3b8;
}

/* ---------- dashboard hero ---------- */
.bipm-hero { position: relative; overflow: hidden; }
body:not(.bipm-light) .bipm-hero::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(600px 160px at 0% 0%, rgba(var(--bipm-accent-rgb), .10), transparent 70%);
}
.bipm-quick {
    display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border-radius: .75rem;
    font-size: .72rem; font-weight: 700; border: 1px solid rgba(148, 163, 184, .28);
    background: rgba(148, 163, 184, .08); color: #e2e8f0; cursor: pointer;
}
.bipm-quick:hover { border-color: rgba(var(--bipm-accent-rgb), .6); background: rgba(var(--bipm-accent-rgb), .12); }
body.bipm-light .bipm-quick { color: #334155; border-color: rgba(100, 116, 139, .35); background: #f8fafc; }
body.bipm-light .bipm-quick:hover { color: #960000; }

/* ---------- login ---------- */
body.bg-slate-950 > .max-w-md { box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .8), 0 0 0 1px rgba(var(--bipm-accent-rgb), .05); }

/* ---------- mobile: tables become stacked cards ----------
   mod-ui.js adds .bipm-stack and a data-label (from the column header) to every cell. */
@media (max-width: 640px) {
    table.bipm-stack, table.bipm-stack tbody, table.bipm-stack tfoot { display: block; width: 100%; }
    table.bipm-stack thead { display: none; }
    table.bipm-stack tr {
        display: block; margin-bottom: .65rem; padding: .35rem .75rem;
        border: 1px solid rgba(148, 163, 184, .2) !important; border-radius: .85rem;
        background: rgba(148, 163, 184, .06);
    }
    table.bipm-stack td {
        display: flex; align-items: center; justify-content: space-between; gap: 1rem;
        padding: .4rem 0 !important; border: 0 !important; text-align: right !important;
        white-space: normal !important; max-width: none !important;
    }
    table.bipm-stack td::before {
        content: attr(data-label); flex-shrink: 0; text-align: left;
        font-size: .64rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #64748b;
    }
    table.bipm-stack tr.hidden, table.bipm-stack td.hidden { display: none; }
    table.bipm-stack td[data-label=""]::before { display: none; }
    table.bipm-stack td[colspan] { display: block; text-align: center !important; }
    table.bipm-stack td > * { min-width: 0; }
    .overflow-x-auto { overflow-x: visible; }
    .bipm-table-tools { flex-wrap: wrap; }
    .bipm-table-tools .bipm-table-search { flex: 1 1 100%; }
    .bipm-table-tools .bipm-table-count { flex: 1 1 auto; }
    /* sub-tab bars: one scrollable row instead of four wrapped ones */
    #hr-subtabs, #crm-subtabs { flex-wrap: nowrap !important; overflow-x: auto; padding-bottom: .75rem; -webkit-overflow-scrolling: touch; }
    #hr-subtabs > button, #crm-subtabs > button { flex-shrink: 0; }
    main .p-6 { padding: 1rem !important; }
    #bipm-palette { padding-top: 4vh; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
