/* ============================================================
   ConstructMS — Metronic v8 overrides
   Custom widgets + behaviors Metronic doesn't provide, ported
   from the retired theme-base.css. Loaded AFTER the Metronic
   bundles so these win.
   ============================================================ */

/* ---- Font-size system ----
   Metronic's bundle hard-forces `html, body { font-size: 13px !important }`,
   which overrode our scale and made the Settings control inert. We override
   BOTH html (rem-based component sizes) and body (inherited text) with
   !important + higher specificity so the setting works again.

   Default = medium = 13px: a compact admin base that reads right at 100% browser
   zoom (no zoom-out needed). Bump to large/xlarge from Settings for readability. */
html:has(body.font-size-small),  body.font-size-small  { font-size: 12px !important; }
html:has(body.font-size-medium), body.font-size-medium { font-size: 13px !important; }
html:has(body.font-size-large),  body.font-size-large  { font-size: 15px !important; }
html:has(body.font-size-xlarge), body.font-size-xlarge { font-size: 17px !important; }

/* ---- Table-row action buttons ---- */
.action-btns {
    display: inline-flex;
    gap: 0.375rem;
    align-items: center;
    flex-wrap: wrap;
}
.action-btns form { display: inline-flex; }

/* ---- Dashboard stat cards ---- */
.card-body:has(.stat-num) { container-type: inline-size; }
.stat-num {
    font-size: clamp(1.25rem, 10cqi, 2.25rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Notifications dropdown (content injected by app.js) ---- */
.notif-dropdown { width: 340px; max-width: 90vw; }
.notif-header,
.notif-footer { padding: 0.75rem 1rem; }
.notif-header { border-bottom: 1px solid var(--bs-border-color); }
.notif-footer { border-top: 1px solid var(--bs-border-color); text-align: center; }
.notif-body { max-height: 360px; overflow-y: auto; }
.notif-item {
    display: flex;
    align-items: flex-start;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}
.notif-item:hover { background-color: var(--bs-gray-100); }
.min-width-0 { min-width: 0; }

/* ---- RTL accent-border helper ---- */
[dir="rtl"] .border-start {
    border-left: none !important;
    border-right: 4px solid !important;
}

/* ---- Settings theme cards ---- */
.theme-card { cursor: pointer; transition: all 0.15s ease; }
.theme-card:hover { transform: translateY(-2px); }
.theme-card.active { outline: 2px solid var(--bs-primary); }

/* ============================================================
   DENSITY LAYER
   Metronic ships very airy defaults (chunky buttons, tall card
   headers, ~2rem card bodies). These rules tighten the whole app
   to a compact look that reads right at 100% browser zoom.
   Adjust the numbers here to taste — it's the single dial.
   ============================================================ */

/* Narrower sidebar than Metronic's 300px default, sized to our menu. */
@media (min-width: 992px) {
    :root {
        --bs-app-sidebar-width: 245px;
        --bs-app-sidebar-width-actual: 245px;
    }
}

/* Cap content width on ultra-wide screens so tables don't stretch into emptiness. */
.app-content .app-container,
#kt_app_toolbar .app-container,
#kt_app_header .app-container {
    max-width: 1440px;
    margin-inline: auto;
}

/* Compact buttons (Metronic .btn padding is large by default). */
.btn:not(.btn-icon):not(.btn-sm):not(.btn-lg) {
    padding: 0.5rem 0.95rem;
}
.btn-sm:not(.btn-icon) {
    padding: 0.35rem 0.65rem;
}
.btn.btn-icon { width: 2.2rem; height: 2.2rem; }
.btn.btn-icon.btn-sm { width: 1.85rem; height: 1.85rem; }

/* Table-row action icons stay compact regardless of the above. */
td .action-btns .btn,
td .btn.btn-icon,
td .btn.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
    padding: 0;
}

/* Tighter cards — trim the tall header min-height and fat bodies. */
.card-header {
    min-height: unset;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}
.card-body { padding: 1.1rem 1.25rem; }
.card-body.p-0 { padding: 0 !important; }

/* Tighter shell padding. */
.app-content { padding-top: 1rem; padding-bottom: 1rem; }

/* Denser tables + form controls. */
.table > :not(caption) > * > * { padding: 0.5rem 0.65rem; }
.form-control, .form-select { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.form-control-sm, .form-select-sm { padding-top: 0.35rem; padding-bottom: 0.35rem; }

/* Synced top horizontal scrollbar for wide tables (wired up in app.js). */
.table-top-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    display: none;          /* shown by JS only when the table overflows */
}
.table-top-scroll-inner { height: 1px; }

/* ---- Fixed-header offset (must-have fix) ----
   The app-header is position:fixed and 90px tall on desktop. Metronic offsets
   the content via margin-top:var(--bs-app-header-height) on the wrapper, but
   that var is scoped to the header subtree and resolves inconsistently — content
   then slides up under the header and the toolbar/page-heading vanish. We hard-
   pin the wrapper's top offset to the real 90px header height and zero
   #kt_app_main's padding so the offset is never double-counted. */
@media (min-width: 992px) {
    body[data-kt-app-header-fixed="true"] #kt_app_wrapper {
        margin-top: 90px !important;
        padding-top: 0 !important;
    }
    body[data-kt-app-header-fixed="true"] #kt_app_main { padding-top: 0 !important; }
}

/* Metronic gives .app-content a large negative margin-top (a toolbar-overlap
   pattern that assumes a FIXED toolbar). Our toolbar is static, so that negative
   margin drags content up under the fixed header. Neutralize it. */
#kt_app_content.app-content { margin-top: 0 !important; }

/* The starterkit ships a solid-blue gradient toolbar banner with low-contrast
   dark text, AND reserves a large fixed --bs-app-toolbar-height (≈224px) as the
   toolbar's min-height. Ours is a static page-title bar, so that reservation
   becomes dead empty space above the content. Make it a slim, transparent
   page-title bar. */
#kt_app_toolbar.app-toolbar {
    background: transparent !important;
    box-shadow: none !important;
    min-height: auto !important;
    height: auto !important;
    padding-top: 0.85rem !important;
    padding-bottom: 0.25rem !important;
}
