/* =============================================================
   NinjaFMS — ERP Compact Theme
   Single-file override for Filament v5
   Covers: density, typography, sidebar, forms, badges, print
   ============================================================= */

/* ── 1. CSS Custom Properties ─────────────────────────────── */
:root {
    --fi-surface-03: rgba(0, 0, 0, 0.025);
    --fi-surface-04: rgba(0, 0, 0, 0.03);
    --fi-surface-05: rgba(0, 0, 0, 0.04);
    --fi-surface-08: rgba(0, 0, 0, 0.08);
    --fi-surface-15: rgba(0, 0, 0, 0.15);
    --fi-muted-text:  #6b7280;

    /* ── Type scale — 8 deliberate steps, each with one semantic role.
       Replaces 13+ near-duplicate ad hoc sizes previously scattered
       across this file, the Sale-flow blade views, and the dashboard. ── */
    --nfms-text-3xs:  0.6875rem;  /* 11px — micro uppercase labels: badges, table super-headers, field super-labels */
    --nfms-text-2xs:  0.75rem;    /* 12px — field labels, hints, breadcrumbs, secondary text */
    --nfms-text-xs:   0.8125rem;  /* 13px — body default: table cells, inputs, buttons */
    --nfms-text-sm:   0.875rem;   /* 14px — emphasized body, section headers, dashboard card values */
    --nfms-text-base: 1rem;       /* 16px — page sub-heading, card titles */
    --nfms-text-lg:   1.25rem;    /* 20px — page heading */
    --nfms-text-xl:   1.75rem;    /* 28px — rare hero numbers */
    --nfms-text-2xl:  2rem;       /* 32px — login wordmark only */

    /* Weight roles: 400 regular / 500 medium (table+input values) /
       600 semibold (labels, values, section headers, buttons) /
       700 bold (headings, table header cells, badges, active nav) /
       800 extrabold (brand wordmark + hero monetary figures only). */

    --nfms-tracking-normal: 0em;
    --nfms-tracking-wide:   0.06em;  /* all-caps micro labels */
    --nfms-tracking-wider:  0.14em;  /* login tagline only */
    --nfms-tracking-tight:  -0.02em; /* large display text */

    --nfms-leading-tight:  1.2;   /* headings */
    --nfms-leading-snug:   1.35;  /* dense table/UI text, badges */
    --nfms-leading-normal: 1.5;   /* body/hint copy */
}
.dark {
    --fi-surface-03: rgba(255, 255, 255, 0.03);
    --fi-surface-04: rgba(255, 255, 255, 0.04);
    --fi-surface-05: rgba(255, 255, 255, 0.05);
    --fi-surface-08: rgba(255, 255, 255, 0.08);
    --fi-surface-15: rgba(255, 255, 255, 0.15);
    --fi-muted-text:  #9ca3af;
}

/* ── Reusable typography utility classes ─────────────────────
   Bundle the multi-property patterns that were previously duplicated
   verbatim across the Sale-flow blade views and render-hook HTML. ── */
.nfms-label {
    font-size: var(--nfms-text-3xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--nfms-tracking-wide);
    color: var(--fi-muted-text);
    line-height: var(--nfms-leading-snug);
}
.nfms-value {
    font-size: var(--nfms-text-sm);
    font-weight: 600;
    line-height: var(--nfms-leading-snug);
}
.nfms-hint {
    font-size: var(--nfms-text-2xs);
    font-weight: 400;
    color: var(--fi-muted-text);
    line-height: var(--nfms-leading-normal);
}
.nfms-heading {
    font-size: var(--nfms-text-lg);
    font-weight: 700;
    line-height: var(--nfms-leading-tight);
}
.nfms-heading-sm {
    font-size: var(--nfms-text-sm);
    font-weight: 700;
    line-height: var(--nfms-leading-tight);
}


/* ── 2. Topbar ─────────────────────────────────────────────── */
.fi-topbar {
    border-bottom: 1px solid #e5e7eb !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04) !important;
}
.dark .fi-topbar {
    border-bottom-color: rgba(255,255,255,0.08) !important;
    box-shadow: 0 1px 6px rgba(0,0,0,0.25) !important;
}

/* Topbar home button */
.topbar-home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 0.375rem;
    color: inherit;
    opacity: 0.55;
    transition: opacity 0.15s, background 0.15s;
    text-decoration: none;
    margin-left: 0.4rem;
    flex-shrink: 0;
}
.topbar-home-btn:hover { opacity: 1; background: rgba(0,0,0,0.07); }
.dark .topbar-home-btn:hover { background: rgba(255,255,255,0.09); }

/* Mobile: hide topbar quick-action button labels */
@media (max-width: 640px) { .db-btn-label { display: none; } }


/* ── 3. Sidebar Shell ──────────────────────────────────────── */
.fi-sidebar {
    border-right: 1px solid #e5e7eb !important;
}
.dark .fi-sidebar {
    border-right-color: rgba(255,255,255,0.08) !important;
}

/* ── Main content tinted background ── */
.fi-main { background: #f1f5f9 !important; }
.dark .fi-main { background: #0f172a !important; }


/* ── 4. [C] Sidebar Nav Items — Compact ───────────────────── */
.fi-sidebar-item-button,
.fi-sidebar-item-btn,
.fi-sidebar nav a,
.fi-sidebar nav li > a,
.fi-sidebar-item > a {
    padding-top: 0.18rem !important;
    padding-bottom: 0.18rem !important;
    font-size: var(--nfms-text-xs) !important;
    color: #1e293b !important;
    gap: 0.275rem !important;
    text-decoration: none !important;
}
.dark .fi-sidebar-item-button,
.dark .fi-sidebar-item-btn,
.dark .fi-sidebar nav a,
.dark .fi-sidebar nav li > a,
.dark .fi-sidebar-item > a {
    color: #e2e8f0 !important;
}
.fi-sidebar-item-button svg,
.fi-sidebar-item-btn svg,
.fi-sidebar nav a svg {
    width: 0.8rem !important;
    height: 0.8rem !important;
    flex-shrink: 0 !important;
    opacity: 0.85;
}

/* Sidebar group labels */
.fi-sidebar-group-label {
    padding-top: 0.15rem !important;
    padding-bottom: 0.1rem !important;
    font-size: var(--nfms-text-3xs) !important;
    letter-spacing: var(--nfms-tracking-wide) !important;
    font-weight: 700 !important;
}
.fi-sidebar-group-items { margin-top: 0 !important; }
.fi-sidebar-group {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
.fi-sidebar-nav,
.fi-sidebar nav ul,
.fi-sidebar nav > ul {
    gap: 0 !important;
}


/* ── 5. Color-Coded Nav Groups ─────────────────────────────── */
.fi-sidebar-group[data-group="Quick Access"] .fi-sidebar-group-label { color: #059669 !important; }
.fi-sidebar-group[data-group="Quick Access"] > button svg,
.fi-sidebar-group[data-group="Quick Access"] .fi-sidebar-group-btn svg { color: #059669 !important; }

.fi-sidebar-group[data-group="Dashboard"] .fi-sidebar-group-label { color: #6366f1 !important; }
.fi-sidebar-group[data-group="Dashboard"] > button svg,
.fi-sidebar-group[data-group="Dashboard"] .fi-sidebar-group-btn svg { color: #6366f1 !important; }

.fi-sidebar-group[data-group="Transactions"] .fi-sidebar-group-label { color: #2563eb !important; }
.fi-sidebar-group[data-group="Transactions"] > button svg,
.fi-sidebar-group[data-group="Transactions"] .fi-sidebar-group-btn svg { color: #2563eb !important; }

.fi-sidebar-group[data-group="Inventory"] .fi-sidebar-group-label { color: #d97706 !important; }
.fi-sidebar-group[data-group="Inventory"] > button svg,
.fi-sidebar-group[data-group="Inventory"] .fi-sidebar-group-btn svg { color: #d97706 !important; }

.fi-sidebar-group[data-group="Reports"] .fi-sidebar-group-label { color: #7c3aed !important; }
.fi-sidebar-group[data-group="Reports"] > button svg,
.fi-sidebar-group[data-group="Reports"] .fi-sidebar-group-btn svg { color: #7c3aed !important; }

.fi-sidebar-group[data-group="Ledgers"] .fi-sidebar-group-label { color: #0284c7 !important; }
.fi-sidebar-group[data-group="Ledgers"] > button svg,
.fi-sidebar-group[data-group="Ledgers"] .fi-sidebar-group-btn svg { color: #0284c7 !important; }

.fi-sidebar-group[data-group="Financials"] .fi-sidebar-group-label { color: #0891b2 !important; }
.fi-sidebar-group[data-group="Financials"] > button svg,
.fi-sidebar-group[data-group="Financials"] .fi-sidebar-group-btn svg { color: #0891b2 !important; }

.fi-sidebar-group[data-group="HR & Payroll"] .fi-sidebar-group-label { color: #ea580c !important; }
.fi-sidebar-group[data-group="HR & Payroll"] > button svg,
.fi-sidebar-group[data-group="HR & Payroll"] .fi-sidebar-group-btn svg { color: #ea580c !important; }

.fi-sidebar-group[data-group="Settings"] .fi-sidebar-group-label,
.fi-sidebar-group[data-group="Configuration"] .fi-sidebar-group-label { color: #64748b !important; }
.fi-sidebar-group[data-group="Settings"] > button svg,
.fi-sidebar-group[data-group="Settings"] .fi-sidebar-group-btn svg,
.fi-sidebar-group[data-group="Configuration"] > button svg,
.fi-sidebar-group[data-group="Configuration"] .fi-sidebar-group-btn svg { color: #64748b !important; }


/* ── 6. Sidebar Collapsed (Icon Rail) ──────────────────────── */
.fi-sidebar-collapsed .fi-sidebar-item-button,
.fi-sidebar-collapsed .fi-sidebar-item-btn,
.fi-sidebar-collapsed .fi-sidebar nav a {
    justify-content: center !important;
    padding-left: 0.6rem !important;
    padding-right: 0.6rem !important;
}
.fi-sidebar-collapsed .fi-sidebar-item-button svg,
.fi-sidebar-collapsed .fi-sidebar-item-btn svg,
.fi-sidebar-collapsed .fi-sidebar nav a svg {
    width: 1.1rem !important;
    height: 1.1rem !important;
    opacity: 1;
}
.fi-sidebar-collapsed .fi-sidebar-item-button:hover,
.fi-sidebar-collapsed .fi-sidebar-item-btn:hover,
.fi-sidebar-collapsed .fi-sidebar nav a:hover {
    background: rgba(16, 185, 129, 0.1) !important;
    border-radius: 0.375rem !important;
}


/* ── 7. Active Nav Item — Left Accent Pill ─────────────────── */
.fi-sidebar-item-button[aria-current="page"],
.fi-sidebar-item-btn[aria-current="page"],
.fi-sidebar nav a[aria-current="page"] {
    background: rgba(5, 150, 105, 0.1) !important;
    border-left: 3px solid #059669 !important;
    border-radius: 0 0.4rem 0.4rem 0 !important;
    padding-left: calc(0.75rem - 3px) !important;
    font-weight: 700 !important;
    color: #059669 !important;
}
.fi-sidebar-item-button[aria-current="page"] svg,
.fi-sidebar-item-btn[aria-current="page"] svg,
.fi-sidebar nav a[aria-current="page"] svg {
    color: #059669 !important;
    opacity: 1 !important;
}
.dark .fi-sidebar-item-button[aria-current="page"],
.dark .fi-sidebar-item-btn[aria-current="page"],
.dark .fi-sidebar nav a[aria-current="page"] {
    background: rgba(5, 150, 105, 0.15) !important;
    color: #34d399 !important;
}
.dark .fi-sidebar-item-button[aria-current="page"] svg,
.dark .fi-sidebar nav a[aria-current="page"] svg { color: #34d399 !important; }


/* ── 8. [A] Table Density ───────────────────────────────────── */
.fi-ta-header-cell {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    font-size: var(--nfms-text-3xs) !important;
    letter-spacing: var(--nfms-tracking-wide) !important;
    text-transform: uppercase !important;
    font-weight: 700 !important;
    background: #f8fafc !important;
    border-bottom: 2px solid #e5e7eb !important;
}
.dark .fi-ta-header-cell {
    background: rgba(255,255,255,0.04) !important;
    border-bottom-color: rgba(255,255,255,0.1) !important;
}
/* [A+B] Cell: tight padding + tabular numeric alignment */
.fi-ta-cell {
    padding-top: 0.2rem !important;
    padding-bottom: 0.2rem !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    font-size: var(--nfms-text-xs) !important;
    font-variant-numeric: tabular-nums !important;
    font-feature-settings: "tnum" !important;
}

/* [A] Row hover */
.fi-ta-row { transition: background-color 0.12s ease; }
.fi-ta-row:hover { background-color: var(--fi-surface-05) !important; }


/* ── 9. [D] Page Headers & Chrome ──────────────────────────── */
.fi-page-header {
    padding-top: 0.25rem !important;
    padding-bottom: 0.35rem !important;
}
.fi-page-heading {
    font-size: var(--nfms-text-lg) !important;
    font-weight: 700 !important;
    line-height: var(--nfms-leading-tight) !important;
}
.fi-page-sub-heading {
    font-size: var(--nfms-text-2xs) !important;
    margin-top: 0.1rem !important;
}
.fi-breadcrumbs {
    font-size: var(--nfms-text-2xs) !important;
    padding-top: 0.1rem !important;
    padding-bottom: 0.1rem !important;
    margin-top: 0 !important;
}
.fi-page-content {
    padding-top: 0.5rem !important;
    padding-bottom: 1rem !important;
}
/* Table toolbar (search + filters bar) */
.fi-ta-header-toolbar {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}
/* Pagination row */
.fi-pagination {
    padding-top: 0.4rem !important;
    padding-bottom: 0.4rem !important;
}
.fi-pagination-item,
.fi-pagination-previous-btn,
.fi-pagination-next-btn {
    font-size: var(--nfms-text-2xs) !important;
    min-width: 1.75rem !important;
    height: 1.75rem !important;
    padding: 0 0.35rem !important;
}
/* Reduce visual gap between stacked sections */
.fi-page .fi-section + .fi-section { margin-top: 0.625rem !important; }

/* Custom HTML report tables: zebra + hover */
.fi-main-ctn table tbody tr { transition: background-color 0.12s ease; }
.fi-main-ctn table tbody tr:nth-child(even) { background-color: var(--fi-surface-04); }
.fi-main-ctn table tbody tr:hover { background-color: var(--fi-surface-08) !important; }


/* ── 10. [E] Badges ─────────────────────────────────────────── */
.fi-badge {
    padding-top: 0.1rem !important;
    padding-bottom: 0.1rem !important;
    padding-left: 0.45rem !important;
    padding-right: 0.45rem !important;
    font-size: var(--nfms-text-3xs) !important;
    line-height: var(--nfms-leading-snug) !important;
    border-radius: 0.25rem !important;
    font-weight: 700 !important;
}


/* ── 11. [G] Form Fields — Compact Inputs ───────────────────── */
/* Inputs, selects, textareas */
.fi-input,
.fi-fo-text-input input,
.fi-fo-textarea textarea,
.fi-fo-select-input select,
.fi-input-wrp > input,
.fi-input-wrp > select,
.fi-input-wrp > textarea,
.fi-select-input,
.fi-fo-date-picker input {
    padding-top: 0.3rem !important;
    padding-bottom: 0.3rem !important;
    font-size: var(--nfms-text-xs) !important;
    line-height: var(--nfms-leading-snug) !important;
    min-height: unset !important;
}
/* Field labels */
.fi-fo-field-wrp-label,
.fi-fo-field-wrp label,
.fi-label-wrp label,
.fi-label-wrp .fi-label,
.fi-fo-field-wrp > .fi-fo-field-wrp-label {
    font-size: var(--nfms-text-2xs) !important;
    font-weight: 600 !important;
    margin-bottom: 0.15rem !important;
    line-height: var(--nfms-leading-snug) !important;
}
/* Hint / helper text */
.fi-fo-field-hint,
.fi-fo-field-wrp-hint,
.fi-field-hint {
    font-size: var(--nfms-text-3xs) !important;
    margin-top: 0.1rem !important;
}
/* Gap between fields in a form */
.fi-fo-component-ctn { gap: 0.75rem !important; }
.fi-fo-grid-component-ctn { gap: 0.625rem !important; }

/* Section card header */
.fi-section-header-ctn {
    padding-top: 0.45rem !important;
    padding-bottom: 0.45rem !important;
    padding-left: 0.875rem !important;
    padding-right: 0.875rem !important;
}
/* Section card content */
.fi-section-content-ctn {
    padding-top: 0.625rem !important;
    padding-bottom: 0.625rem !important;
    padding-left: 0.875rem !important;
    padding-right: 0.875rem !important;
}
.fi-section-header-heading {
    font-size: var(--nfms-text-sm) !important;
    font-weight: 700 !important;
}
.fi-section-header-description {
    font-size: var(--nfms-text-2xs) !important;
    margin-top: 0.05rem !important;
}
/* Repeater item content */
.fi-fo-repeater-item-content { padding: 0.625rem 0.875rem !important; }

/* ── Toggle fix: prevent general input padding rules from squishing the toggle pill ── */
/* (Our compact input rules target .fi-input-wrp > input which can match the checkbox) */
input[type="checkbox"],
input[type="radio"] {
    padding: unset !important;
    padding-top: unset !important;
    padding-bottom: unset !important;
    font-size: unset !important;
    line-height: unset !important;
    min-height: unset !important;
}


/* ── 12. Buttons ─────────────────────────────────────────────── */
.fi-btn-color-primary {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    box-shadow: 0 2px 8px rgba(5,150,105,0.35) !important;
    border: none !important;
    color: #ffffff !important;
    transition: background 0.18s, box-shadow 0.18s, transform 0.12s !important;
}
.fi-btn-color-primary:hover {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%) !important;
    box-shadow: 0 4px 14px rgba(5,150,105,0.50) !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
}
.fi-btn-color-primary:active {
    transform: translateY(0) !important;
    box-shadow: 0 1px 4px rgba(5,150,105,0.30) !important;
}
.fi-btn-color-primary span,
.fi-btn-color-primary svg { color: #ffffff !important; }


/* ── 13. Print / PDF ─────────────────────────────────────────── */
@media print {
    .fi-sidebar,
    .fi-topbar,
    .fi-breadcrumbs,
    .fi-page-sub-navigation,
    .fi-wi-stats-overview,
    .fi-pagination,
    .fi-ta-header-toolbar,
    .print-hide,
    [data-filament-form],
    .fi-page-header-actions { display: none !important; }

    body, html { background: #fff !important; }
    .fi-main, .fi-main-ctn, .fi-page { background: #fff !important; }
    .fi-page-content { padding: 0 !important; }
    .print-header { display: block !important; }
    * { box-shadow: none !important; }
    table { border-collapse: collapse !important; width: 100% !important; }
    th, td { border: 1px solid #ccc !important; padding: 5px 8px !important; font-size: 9pt !important; }
    thead { display: table-header-group; }
    tr { page-break-inside: avoid; }
    .fi-ta-row:hover { background: transparent !important; }
}

/* ── Branded login header (AUTH_LOGIN_FORM_BEFORE render hook) ───────── */
.nfms-login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}
.nfms-login-wordmark {
    font-size: var(--nfms-text-2xl);
    font-weight: 800;
    letter-spacing: var(--nfms-tracking-tight);
    color: #0f172a;
    line-height: 1.1; /* intentionally tighter than --nfms-leading-tight -- a hero-scale wordmark reads better tighter than a regular heading */
}
.nfms-login-wordmark span { color: #059669; }
.nfms-login-tagline {
    margin-top: 0.15rem;
    font-size: var(--nfms-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--nfms-tracking-wider);
    color: #64748b;
}
/* Franchise's own uploaded logo, shown in place of the wordmark on a
   single-franchise deployment -- capped so an arbitrary upload can't blow
   out the login card's layout. */
.nfms-login-logo {
    max-height: 64px;
    max-width: 240px;
    width: auto;
    height: auto;
    margin: 0 auto;
    display: block;
}
.nfms-login-powered {
    margin-top: 0.5rem;
    font-size: var(--nfms-text-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--nfms-tracking-wider);
    color: #94a3b8;
}
/* Dark-mode readability */
.dark .nfms-login-wordmark { color: #f1f5f9; }
.dark .nfms-login-tagline { color: #94a3b8; }
.dark .nfms-login-powered { color: #64748b; }
