/* NS3 ERP – application styles (Bootstrap 5.3 overrides + layout) */
:root {
    --ns3-navy: #1b2b6d;
    --ns3-navy-dark: #14215a;
    --ns3-red: #c8102e;
    --ns3-bg: #f4f6fa;
    --ns3-sidebar-width: 250px;
    --bs-primary: #1b2b6d;
    --bs-primary-rgb: 27, 43, 109;
    --bs-link-color: #1b2b6d;
    --bs-link-color-rgb: 27, 43, 109;
    --bs-link-hover-color: #c8102e;
    --bs-link-hover-color-rgb: 200, 16, 46;
    --bs-body-bg: #f4f6fa;
    --bs-body-font-size: 0.925rem;
}

.btn-primary {
    --bs-btn-bg: var(--ns3-navy);
    --bs-btn-border-color: var(--ns3-navy);
    --bs-btn-hover-bg: var(--ns3-navy-dark);
    --bs-btn-hover-border-color: var(--ns3-navy-dark);
    --bs-btn-active-bg: var(--ns3-navy-dark);
    --bs-btn-active-border-color: var(--ns3-navy-dark);
    --bs-btn-disabled-bg: var(--ns3-navy);
    --bs-btn-disabled-border-color: var(--ns3-navy);
}
.btn-outline-primary {
    --bs-btn-color: var(--ns3-navy);
    --bs-btn-border-color: var(--ns3-navy);
    --bs-btn-hover-bg: var(--ns3-navy);
    --bs-btn-hover-border-color: var(--ns3-navy);
    --bs-btn-active-bg: var(--ns3-navy);
    --bs-btn-active-border-color: var(--ns3-navy);
}
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: #6f7fc2;
    box-shadow: 0 0 0 0.2rem rgba(27, 43, 109, 0.15);
}
.form-check-input:checked { background-color: var(--ns3-navy); border-color: var(--ns3-navy); }
.page-link { color: var(--ns3-navy); }
.page-item.active .page-link { background-color: var(--ns3-navy); border-color: var(--ns3-navy); }
.text-navy { color: var(--ns3-navy) !important; }
.bg-navy { background: linear-gradient(135deg, var(--ns3-navy) 0%, #2a3f94 100%) !important; }

/* ---- Layout -------------------------------------------------------------- */
html, body { height: 100%; }
.app-body { background: var(--ns3-bg); }
.app-wrapper { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--ns3-sidebar-width);
    flex: 0 0 var(--ns3-sidebar-width);
    background: var(--ns3-navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1040;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 0.9rem 1rem;
    background: #fff;
    border-bottom: 3px solid var(--ns3-red);
}
.sidebar-logo { height: 38px; width: auto; }
.sidebar-title { color: var(--ns3-navy); font-weight: 700; margin-left: 0.6rem; letter-spacing: 0.02em; }
.sidebar-close { margin-left: auto; color: var(--ns3-navy); }
.sidebar-nav { padding: 0.75rem 0.6rem 1.5rem; }
.sidebar-heading {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    padding: 1rem 0.75rem 0.35rem;
}
.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.85);
    border-radius: 0.4rem;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.9rem;
}
.sidebar-nav .nav-link .bi { font-size: 1.05rem; width: 1.25rem; text-align: center; opacity: 0.9; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar-nav .nav-link.active { background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 500; box-shadow: inset 3px 0 0 var(--ns3-red); }
.sidebar-nav .nav-link.disabled { color: rgba(255, 255, 255, 0.4); cursor: default; }
.badge-soon { margin-left: auto; font-size: 0.6rem; background: rgba(255, 255, 255, 0.12); padding: 0.1rem 0.4rem; border-radius: 0.3rem; }

.app-sidebar-backdrop { display: none; }

.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    display: flex;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #e3e6ee;
    padding: 0.65rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: 60px;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; margin: 0; color: var(--ns3-navy); }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--ns3-navy); color: #fff; font-size: 0.8rem; font-weight: 600;
}
.app-content { padding: 1.25rem; flex: 1 1 auto; }
.app-footer { display: flex; padding: 0.75rem 1.25rem; border-top: 1px solid #e3e6ee; background: #fff; }

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.25);
    }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .app-sidebar-backdrop {
        display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 1035;
    }
    .app-content { padding: 1rem; }
}

/* ---- Cards & tables ------------------------------------------------------ */
.card { border: 1px solid #e3e6ee; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); }
.card-header { background: #fff; font-weight: 600; color: #2d3348; }
.card-footer { background: #fafbfd; }
.table-list th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: #6b7280; white-space: nowrap; background: #fafbfd; }
.table-list td { vertical-align: middle; }
.table > :not(caption) > * > * { padding: 0.6rem 0.75rem; }
.row-inactive td { color: #9aa0ad; }
.sort-link.active { color: var(--ns3-navy) !important; }
.list-filters .form-select, .list-filters .form-control { min-width: 0; }
.w-40 { width: 40%; }

.stat-card { color: inherit; transition: box-shadow 0.15s ease, transform 0.15s ease; }
.stat-card:hover { box-shadow: 0 4px 14px rgba(16, 24, 40, 0.08); transform: translateY(-1px); }
.stat-icon { width: 40px; height: 40px; border-radius: 0.6rem; display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--ns3-navy); line-height: 1.1; }
.stat-label { color: #6b7280; font-size: 0.85rem; }

.badge-action { font-weight: 500; text-transform: capitalize; background: #e9ecf4; color: #2d3348; }
.badge-action.action-create, .badge-action.action-activate, .badge-action.action-login { background: #d9f2e3; color: #146c43; }
.badge-action.action-update, .badge-action.action-migrate { background: #dde7fb; color: #1b2b6d; }
.badge-action.action-deactivate, .badge-action.action-cancel, .badge-action.action-login_failed, .badge-action.action-login_locked { background: #fde2e4; color: #a11a2b; }
.badge-action.action-logout, .badge-action.action-password_change, .badge-action.action-password_reset, .badge-action.action-password_reset_request { background: #fff3cd; color: #7a5a00; }
.audit-json { font-size: 0.78rem; background: #fff; border: 1px solid #e3e6ee; border-radius: 0.35rem; padding: 0.5rem 0.75rem; max-height: 320px; overflow: auto; white-space: pre-wrap; }

/* ---- Forms --------------------------------------------------------------- */
.form-label { font-weight: 500; font-size: 0.85rem; color: #3b4256; margin-bottom: 0.3rem; }
.form-text { font-size: 0.78rem; }
.permission-grid .form-check { margin-bottom: 0.3rem; }
.numbering-preview { background: #f4f6fa; border: 1px dashed #c9cfe0; border-radius: 0.5rem; padding: 0.75rem 1rem; text-align: center; }
.numbering-preview .display-6 { color: var(--ns3-navy); font-weight: 600; letter-spacing: 0.03em; }
.logo-preview img { max-width: 100%; max-height: 140px; object-fit: contain; border: 1px solid #e3e6ee; border-radius: 0.4rem; padding: 0.5rem; background: #fff; }
.letterhead-preview { background: #fff; }
.letterhead-logo { height: 54px; width: auto; }
.letterhead-rule { height: 3px; background: linear-gradient(90deg, var(--ns3-navy) 0 85%, var(--ns3-red) 85% 100%); }

/* ---- Auth ---------------------------------------------------------------- */
.auth-body { background: radial-gradient(circle at 20% 0%, #27399a 0%, var(--ns3-navy) 45%, #0f1a4a 100%); min-height: 100vh; }
.auth-wrapper { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-wrapper > .text-muted { color: rgba(255, 255, 255, 0.65) !important; }
.auth-card { width: 100%; max-width: 420px; border: 0; border-top: 4px solid var(--ns3-red); border-radius: 0.75rem; }
.auth-logo { height: 70px; }
.auth-brand { font-weight: 700; color: var(--ns3-navy); font-size: 1.15rem; }

/* ---- Errors -------------------------------------------------------------- */
.error-page .display-1 { letter-spacing: -0.03em; }

/* ---- Tom Select ---------------------------------------------------------- */
.ts-wrapper.form-select { padding: 0; }
.ts-control { font-size: 0.925rem; }
