/* ============================================================
   iApprove — "Data-Dense Pro" theme
   Design system + app shell. Replaces the external Noble theme.
   Load order: bootstrap4 -> theme.css -> site.css
   ============================================================ */

:root {
    --accent: #0a6ed1;
    --accent-hover: #0a5cb0;
    --accent-weak: #e7f1fb;
    --accent-text: #0a5cb0;

    --bg: #eef0f4;
    --surface: #ffffff;
    --surface-2: #f6f7fa;
    --border: #dfe3ea;
    --border-2: #eceff4;

    --text: #1c2433;
    --muted: #5b6577;
    --muted-2: #8a93a3;

    --green: #1a7d4f;   --green-bg: #e3f3ea;
    --amber: #9a5a00;   --amber-bg: #fbf0db;
    --slate: #465064;   --slate-bg: #e9edf3;
    --red:   #a8261c;   --red-bg:   #fae6e4;

    --sidebar-bg: #1c2433;
    --sidebar-hover: #2a3447;
    --sidebar-text: #aab3c3;
    --sidebar-muted: #6b7689;

    --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.05);
    --shadow-md: 0 8px 24px rgba(16,24,40,.12);
}

/* ---------- base ---------- */
body {
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}
.body-no-footer { margin: 0 !important; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ============================================================
   APP SHELL  (re-created since Noble provided these)
   ============================================================ */
.main-wrapper {
    display: flex;
    align-items: stretch;
    height: 100vh;
    overflow: hidden;
    width: 100%;
}
.page-wrapper { min-height: 0; }

/* ---------- sidebar ---------- */
.sidebar {
    flex: 0 0 232px;
    width: 232px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    transition: flex-basis .18s ease, width .18s ease;
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    flex: 0 0 auto;
}
.sidebar-brand {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.3px;
    text-decoration: none;
}
.sidebar-brand:hover { color: #fff; text-decoration: none; }
.sidebar-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 10px 24px;
    border-right: none !important;
    background: none !important;
}
.sidebar .nav { flex-direction: column; flex-wrap: nowrap; }
.nav-category {
    font-size: 10px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
    font-weight: 600;
    padding: 14px 10px 4px;
    list-style: none;
}
.sidebar .nav-link { color: var(--sidebar-text); padding: 0; display: flex; align-items: center; }
.sidebar .nav-link:hover { color: #fff; text-decoration: none; }
.sidebar .link-icon { width: 16px; height: 16px; flex: 0 0 16px; color: var(--sidebar-text) !important; }
.ia-menu-item:hover .link-icon { color: #fff !important; }
.sidebar .link-title { font-size: 12.5px; font-weight: 500; margin-left: 12px !important; }

.ia-menu-item {
    display: block;
    padding: 7px 10px;
    margin-bottom: 1px;
    border-radius: 7px;
    cursor: pointer;
}
.ia-menu-item:hover { background: var(--sidebar-hover); }
.ia-menu-item-active,
.ia-menu-item.ia-menu-item-active { background: var(--accent); }
.ia-menu-item-active .nav-link,
.ia-menu-item-active .link-title,
.ia-menu-item-active .link-icon { color: #fff !important; }

.ia-h-container { display: flex; align-items: center; }
.ia-menu-row-rowcount { margin-left: auto; }
.sidebar .ia-badge-rowcount {
    background: var(--sidebar-hover) !important;
    color: #c2cad8 !important;
    font-size: 10.5px;
    padding: 1px 7px;
    border-radius: 10px;
    opacity: 1;
}

/* sidebar company panel */
.ia-sidepanel-company-wrapper { padding: 0 2px; cursor: pointer; }
.ia-sidepanel-company-container {
    background: var(--sidebar-hover);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    margin: 2px 0 6px;
    padding: 9px 11px;
    overflow: hidden;
}
.ia-sidepanel-company { color: #fff; font-weight: 600; font-size: 12.5px; display: inline-block; }
.ia-sidepanel-username { color: #8a93a3; font-size: 11px; }

/* sidebar collapse */
.sidebar-toggler { background: none; border: none; cursor: pointer; }
.main-wrapper.sidebar-folded .sidebar { flex-basis: 0; width: 0; }

/* ---------- page wrapper / topbar ---------- */
.page-wrapper {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.navbar {
    min-height: 50px;
    background: var(--surface);
    border-bottom: 1px solid var(--border) !important;
    padding: 0 16px;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
}
.navbar-content { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0; }
.navbar .sidebar-toggler { color: var(--muted); display: inline-flex; padding: 4px; }
.search-form { flex: 1 1 auto; min-width: 0; }
.search-form .input-group-text { background: transparent; border: none; color: var(--muted-2); padding: 0 6px 0 0; }
.search-form .input-group-text svg { width: 18px; height: 18px; }
.search-form .input-group-text .spinner-border { display: none; width: 18px; height: 18px; border-width: 2px; color: var(--muted-2); }
.search-form.searching .input-group-text svg { display: none; }
.search-form.searching .input-group-text .spinner-border { display: inline-block; }
.search-form .form-control { border: none; box-shadow: none; height: 100%; padding-top: 0; padding-bottom: 0; }
.navbar-nav { flex-direction: row; align-items: center; margin-left: auto; gap: 4px; }
.navbar .dropdown-toggle,
.navbar .nav-profile > .nav-link {
    height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 12px;
    line-height: 1;
    background: var(--surface);
}
.navbar .dropdown-toggle:hover,
.navbar .nav-profile > .nav-link:hover { background: var(--surface-2); }

/* ---------- profile dropdown menu internals ---------- */
.nav-profile .dropdown-menu { min-width: 220px; }
.nav-profile .dropdown-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 10px 10px;
    text-transform: none;
    letter-spacing: normal;
}
.nav-profile .dropdown-header .name {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}
.nav-profile .dropdown-header .email {
    color: var(--muted) !important;
    font-size: 11.5px;
    margin-bottom: 0 !important;
}
.nav-profile .dropdown-body { border-top: 1px solid var(--border-2); padding-top: 4px; }
.nav-profile .profile-nav {
    list-style: none;
    margin: 0;
    padding: 0 !important;
}
.nav-profile .profile-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    height: auto;
    padding: 7px 10px;
    margin: 1px 0;
    border: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    background: transparent;
}
.nav-profile .profile-nav .nav-link:hover {
    background: var(--accent-weak);
    color: var(--accent-text);
    text-decoration: none;
}
.nav-profile .profile-nav .nav-link svg { width: 16px; height: 16px; flex: 0 0 16px; }
/* Plain (non-expand) navbar keeps dropdowns in static flow; anchor them under their toggle */
.navbar .navbar-nav .nav-item.dropdown { position: relative; }
.navbar .navbar-nav .dropdown-menu { position: absolute; right: 0; left: auto; top: 100%; float: none; margin-top: 4px; }

.page-content {
    flex: 1 1 auto;
    min-height: 0;
    background: var(--bg) !important;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* The active content host (or the overlay, for invoice detail) fills the area
   and scrolls internally, so the page itself never scrolls. */
#maincontent,
#overlay { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }

/* Invoice list / archive: table fills the parent; only the table scrolls. */
#maincontent:has(.ia-invoices-card) { display: flex; flex-direction: column; overflow: hidden; }
.ia-invoices-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.ia-invoices-card .ia-invoices-card-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.ia-invoices-card .ia-invoice-table-container { flex: 1 1 auto; min-height: 0; max-height: none; }

/* ============================================================
   BOOTSTRAP COMPONENT RESTYLE
   ============================================================ */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}
/* Noble used to provide card grid spacing */
.grid-margin { margin-bottom: 16px; }
/* Noble used to provide stretch-card / flex-grow — restore equal-height cards.
   The Bootstrap .row already lays columns out as equal-height flex items;
   these make the .card inside each column fill that full height. */
.flex-grow { flex-grow: 1; }
.stretch-card { display: flex; align-items: stretch; }
.stretch-card > .card { width: 100%; min-width: 0; }
.card-header {
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-2);
    padding: 9px 14px;
}
.card-body { padding: 14px; }
.card-footer, .card-footer.ia-text-dim {
    background: var(--surface-2);
    border-top: 1px solid var(--border-2);
    color: var(--muted-2);
    font-size: 11px;
    padding: 8px 14px;
}

/* generic tables (dashboard, history, users, etc.) */
.table { font-size: 12.5px; color: var(--text); margin-bottom: 0; }
.table thead th {
    border-top: none;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 10.5px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted-2);
    font-weight: 600;
    padding: 7px 12px;
    white-space: nowrap;
}
.table td { padding: 6px 12px; border-top: 1px solid var(--border-2); vertical-align: middle; }
.table.table-sm td, .table.table-sm th { padding: 4px 10px; }
.table tbody tr:hover { background: var(--accent-weak); color: var(--text); }
/* keep table-hover from forcing Bootstrap's hardcoded dark text on hover */
.table-hover tbody tr:hover { color: var(--text); }
/* monospaced, right-aligned numeric cells */
.table td[style*="right"], .table th[style*="right"] { font-family: var(--mono); }
.table td[style*="right"] { font-weight: 600; }

/* buttons */
.btn { font-size: 13px; border-radius: 6px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus { background: var(--accent-hover); border-color: var(--accent-hover); }

/* forms */
.form-control { background: var(--surface); border-color: var(--border); border-radius: 6px; font-size: 13px; color: var(--text); }
.form-control::placeholder { color: var(--muted-2); }
.form-control:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); color: var(--text); }
.form-control[readonly] { background: var(--surface-2); color: var(--muted); }
.input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.btn-outline-secondary { color: var(--muted); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.form-control-sm { font-size: 12px; }
/* denser form rows */
.form-group { margin-bottom: .5rem; }
.form-group.row { margin-bottom: .4rem; }
.col-form-label { padding-top: calc(.25rem + 1px); padding-bottom: calc(.25rem + 1px); }

/* ============================================================
   CHECKBOXES & RADIOS  (modern accent-filled, app-wide)
   Styles the native input directly via appearance:none, so it
   applies regardless of wrapper class (.form-check-input,
   .form-checks, plain inputs) and survives inline display toggles.
   ============================================================ */
input[type="checkbox"]:not(.custom-control-input),
input[type="radio"]:not(.custom-control-input) {
    -webkit-appearance: none;
    appearance: none;
    -moz-appearance: none;
    width: 16px;
    height: 16px;
    margin: 0;
    flex: 0 0 16px;
    vertical-align: middle;
    border: 1.5px solid var(--border);
    background: var(--surface);
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
input[type="checkbox"]:not(.custom-control-input) { border-radius: 4px; }
input[type="radio"]:not(.custom-control-input) { border-radius: 50%; }

input[type="checkbox"]:not(.custom-control-input):hover,
input[type="radio"]:not(.custom-control-input):hover { border-color: var(--accent); }

input[type="checkbox"]:not(.custom-control-input):checked,
input[type="radio"]:not(.custom-control-input):checked {
    background-color: var(--accent);
    border-color: var(--accent);
}
input[type="checkbox"]:not(.custom-control-input):checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-6.5'/%3E%3C/svg%3E");
}
input[type="checkbox"]:not(.custom-control-input):indeterminate {
    background-color: var(--accent);
    border-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M4 8h8'/%3E%3C/svg%3E");
}
input[type="radio"]:not(.custom-control-input):checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='3' fill='%23fff'/%3E%3C/svg%3E");
}

input[type="checkbox"]:not(.custom-control-input):focus-visible,
input[type="radio"]:not(.custom-control-input):focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-weak);
}

input[type="checkbox"]:not(.custom-control-input):disabled,
input[type="radio"]:not(.custom-control-input):disabled {
    background-color: var(--surface-2);
    border-color: var(--border-2);
    cursor: not-allowed;
    opacity: .6;
}

/* Bootstrap 4 custom switch / custom checkbox — recolor to accent */
.custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--accent);
    border-color: var(--accent);
}
.custom-control-input:focus ~ .custom-control-label::before {
    box-shadow: 0 0 0 2px var(--accent-weak);
}
.custom-control-input:focus:not(:checked) ~ .custom-control-label::before {
    border-color: var(--accent);
}

/* dropdowns */
.dropdown-menu {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    padding: 6px;
}
.dropdown-item { color: var(--text); }
.dropdown-item { border-radius: 6px; padding: 7px 10px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--accent-weak); color: var(--accent-text); }
.dropdown-divider { border-color: var(--border-2); }

/* modals */
.modal-content { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); }
.modal-header { border-bottom: 1px solid var(--border-2); padding: 14px 18px; }
.modal-header .close { color: var(--text); text-shadow: none; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px; }

/* pagination */
.pagination .page-link { color: var(--accent); border-color: var(--border); border-radius: 6px; margin: 0 2px; font-size: 12px; }
.pagination .page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: #fff; }

/* nav-tabs (invoice detail, settings) */
.nav-tabs { border-bottom: 1px solid var(--border); }
.nav-tabs .nav-link { color: var(--muted); border: none; border-bottom: 2px solid transparent; padding: 8px 14px; font-weight: 500; }
.nav-tabs .nav-link:hover { color: var(--text); border-color: transparent; }
.nav-tabs .nav-link.active { color: var(--accent-text); background: none; border-bottom-color: var(--accent); }

/* alerts */
.alert-info { background: var(--accent-weak); border-color: #cfe2f5; color: var(--accent-text); }

/* ============================================================
   LOGIN / ANON
   ============================================================ */
.main-wrapper-anon { display: block; height: auto; min-height: 100vh; overflow: visible; background: var(--bg); }
.page-wrapper.full-page { min-height: 100vh; }
.noble-ui-logo, .ia-brand-logo {
    color: var(--text);
    font-weight: 700;
    font-size: 26px;
    letter-spacing: -.5px;
    text-decoration: none;
}
.noble-ui-logo span, .ia-brand-logo span { color: var(--accent); }
