/* =====================================================================
   iGEAR360 - Integrated Governance, Excellence, Analytics & Reporting
   J.H. Cerilles State College.
   ===================================================================== */
:root {
    --gas-green: #0b6e3a;
    --gas-green-600: #095c31;
    --gas-green-700: #074a27;
    --gas-green-800: #05391e;
    --gas-green-50: #e8f4ed;
    --gas-green-100: #cfe8da;
    --gas-red: #c8102e;
    --gas-red-600: #a50d26;
    --gas-red-50: #fdecef;
    --gas-white: #ffffff;
    --gas-bg: #f3f6f4;
    --gas-border: #dfe7e2;
    --gas-text: #1d2b24;
    --gas-muted: #66756d;
    --sidebar-w: 264px;

    /* Bootstrap overrides */
    --bs-primary: var(--gas-green);
    --bs-primary-rgb: 11, 110, 58;
    --bs-success: var(--gas-green);
    --bs-success-rgb: 11, 110, 58;
    --bs-danger: var(--gas-red);
    --bs-danger-rgb: 200, 16, 46;
    --bs-link-color: var(--gas-green);
    --bs-link-color-rgb: 11, 110, 58;
    --bs-link-hover-color: var(--gas-green-700);
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--gas-text);
    --bs-border-color: var(--gas-border);
    --bs-body-bg: var(--gas-bg);
    --bs-focus-ring-color: rgba(var(--bs-primary-rgb), .25);
}

body { background: var(--gas-bg); font-size: .925rem; }

/* ---------- buttons ---------- */
.btn-primary, .btn-success {
    --bs-btn-bg: var(--gas-green); --bs-btn-border-color: var(--gas-green);
    --bs-btn-hover-bg: var(--gas-green-600); --bs-btn-hover-border-color: var(--gas-green-600);
    --bs-btn-active-bg: var(--gas-green-700); --bs-btn-active-border-color: var(--gas-green-700);
    --bs-btn-disabled-bg: var(--gas-green); --bs-btn-disabled-border-color: var(--gas-green);
}
.btn-danger {
    --bs-btn-bg: var(--gas-red); --bs-btn-border-color: var(--gas-red);
    --bs-btn-hover-bg: var(--gas-red-600); --bs-btn-hover-border-color: var(--gas-red-600);
    --bs-btn-active-bg: var(--gas-red-600); --bs-btn-active-border-color: var(--gas-red-600);
}
.btn-outline-primary, .btn-outline-success {
    --bs-btn-color: var(--gas-green); --bs-btn-border-color: var(--gas-green);
    --bs-btn-hover-bg: var(--gas-green); --bs-btn-hover-border-color: var(--gas-green); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--gas-green-700); --bs-btn-active-border-color: var(--gas-green-700);
}
.btn-outline-danger {
    --bs-btn-color: var(--gas-red); --bs-btn-border-color: var(--gas-red);
    --bs-btn-hover-bg: var(--gas-red); --bs-btn-hover-border-color: var(--gas-red); --bs-btn-hover-color: #fff;
}
.btn-icon { width: 1.875rem; height: 1.875rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.text-success { color: var(--gas-green) !important; }
.text-danger { color: var(--gas-red) !important; }
.bg-success { background-color: var(--gas-green) !important; }
.bg-danger { background-color: var(--gas-red) !important; }
.form-control:focus, .form-select:focus { border-color: var(--gas-green-100); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .18); }
.form-check-input:checked { background-color: var(--gas-green); border-color: var(--gas-green); }
.form-label { font-weight: 500; font-size: .85rem; color: #34453c; margin-bottom: .3rem; }
.form-text { font-size: .78rem; }
.required::after { content: " *"; color: var(--gas-red); }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-w); flex-shrink: 0; position: fixed; inset: 0 auto 0 0; z-index: 1030;
    background: linear-gradient(180deg, var(--gas-green-700) 0%, var(--gas-green-800) 100%);
    color: #e6f2eb; display: flex; flex-direction: column; overflow-y: auto;
    border-right: 4px solid var(--gas-red);
}
.app-sidebar .brand {
    display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.1rem 1rem; text-decoration: none; color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .1); background: rgba(0, 0, 0, .08);
}
.brand-logo { width: 42px; height: 42px; border-radius: 50%; background: #fff; padding: 2px; object-fit: contain; }
.brand-title { font-weight: 700; font-size: 1.05rem; letter-spacing: .3px; }
.brand-sub { font-size: .7rem; opacity: .75; }
.sidebar-nav { padding: .5rem .6rem 1rem; flex: 1; }
.sidebar-heading {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255, 255, 255, .55);
    padding: 1rem .75rem .35rem; font-weight: 600;
}
.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, .86); border-radius: .5rem; padding: .5rem .75rem; display: flex; align-items: center; gap: .65rem;
    font-size: .875rem; transition: background .15s ease;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .9; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.sidebar-nav .nav-link.active {
    background: #fff; color: var(--gas-green-700); font-weight: 600; box-shadow: inset 4px 0 0 var(--gas-red);
}
.sidebar-nav .nav-link.active i { color: var(--gas-red); }
.sidebar-footer { padding: .8rem 1.1rem; color: rgba(255, 255, 255, .55); border-top: 1px solid rgba(255, 255, 255, .1); }

.app-main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    position: sticky; top: 0; z-index: 1020; background: #fff; height: 64px; display: flex; align-items: center;
    padding: 0 1.5rem; border-bottom: 3px solid var(--gas-red); box-shadow: 0 2px 6px rgba(0, 0, 0, .04);
}
.topbar-title .agency { font-size: .72rem; color: var(--gas-muted); text-transform: uppercase; letter-spacing: .06em; }
.topbar-title .page { font-weight: 700; font-size: 1.1rem; color: var(--gas-green-700); line-height: 1.2; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--gas-green); color: #fff; display: inline-flex;
    align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; border: 2px solid var(--gas-red);
}
.app-content { padding: 1.5rem; flex: 1; }
.app-footer {
    display: flex; justify-content: space-between; padding: .8rem 1.5rem; font-size: .78rem; color: var(--gas-muted);
    border-top: 1px solid var(--gas-border); background: #fff;
}

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .app-sidebar.show { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    .app-main { margin-left: 0; }
    .app-content { padding: 1rem; }
}

/* ---------- cards & page header ---------- */
.page-header { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; margin: 0; color: var(--gas-green-700); }
.page-header .subtitle { color: var(--gas-muted); font-size: .85rem; margin-top: .15rem; }
.card { border: 1px solid var(--gas-border); border-radius: .75rem; box-shadow: 0 1px 2px rgba(16, 40, 28, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--gas-border); font-weight: 600; padding: .8rem 1rem; border-radius: .75rem .75rem 0 0 !important; }
.card-header.accent { border-top: 3px solid var(--gas-green); }
.card-header.accent-red { border-top: 3px solid var(--gas-red); }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gas-green); font-weight: 700; margin: 1rem 0 .5rem; }

.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-icon {
    width: 46px; height: 46px; border-radius: .7rem; display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
}
.stat-card .stat-icon.green { background: var(--gas-green-50); color: var(--gas-green); }
.stat-card .stat-icon.red { background: var(--gas-red-50); color: var(--gas-red); }
.stat-card .stat-value { font-size: 1.45rem; font-weight: 700; color: var(--gas-text); }
.stat-card .stat-label { font-size: .78rem; color: var(--gas-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--gas-green); }
.stat-card.red::after { background: var(--gas-red); }

/* ---------- tables / DataTables ---------- */
.table { --bs-table-hover-bg: var(--gas-green-50); }
.table > thead th {
    background: var(--gas-green-50); color: var(--gas-green-800); font-weight: 600; font-size: .78rem;
    text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--gas-green-100); white-space: nowrap;
}
table.dataTable { width: 100% !important; }
/* DataTables pagination: neutral (no theme color) */
div.dt-container .pagination {
    --bs-pagination-color: #212529; --bs-pagination-hover-color: #212529; --bs-pagination-focus-color: #212529;
    --bs-pagination-hover-bg: #e9ecef; --bs-pagination-focus-bg: #e9ecef; --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(0, 0, 0, .08);
    --bs-pagination-active-color: #212529; --bs-pagination-active-bg: #dee2e6; --bs-pagination-active-border-color: #ced4da;
}
div.dt-container .page-item.active .page-link { font-weight: 600; }
div.dt-container .dt-search input { border-radius: 2rem; padding-left: .9rem; min-width: 220px; }
.dt-buttons .btn { font-size: .8rem; }
/* DataTables export buttons: neutral (no theme color) */
.dt-buttons .btn.dt-plain-btn { background: #fff; color: #212529; border: 1px solid #ced4da; }
.dt-buttons .btn.dt-plain-btn:hover, .dt-buttons .btn.dt-plain-btn:focus, .dt-buttons .btn.dt-plain-btn:active { background: #f1f3f5; color: #212529; border-color: #adb5bd; box-shadow: none; }
.amount, td.amount, th.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85rem; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- status badges ---------- */
.status { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 2rem; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-Draft { background: #eef1f0; color: #59665f; }
.status-Submitted, .status-Certified { background: #fff4e0; color: #9a5b00; }
.status-Approved { background: #e3f0fb; color: #1b5d9a; }
.status-Obligated, .status-Posted, .status-Paid, .status-Implemented, .status-Open { background: var(--gas-green-50); color: var(--gas-green-700); }
.status-Reversed, .status-InProgress { background: #f3ecfb; color: #6b3fa0; }
.status-Cancelled, .status-Closed, .status-Planned, .status-Inactive { background: var(--gas-red-50); color: var(--gas-red); }
.status-Active { background: var(--gas-green-50); color: var(--gas-green-700); }

/* ---------- line-item editors ---------- */
.lines-table td { vertical-align: middle; padding: .35rem; }
.lines-table .form-control, .lines-table .form-select { font-size: .85rem; }
.lines-table input.amount-input { text-align: right; min-width: 120px; }
.lines-table tfoot td { font-weight: 700; background: #fafcfb; }
.balance-ok { color: var(--gas-green); }
.balance-bad { color: var(--gas-red); }

/* ---------- document detail ---------- */
.doc-meta dt { font-size: .75rem; color: var(--gas-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.doc-meta dd { font-weight: 500; margin-bottom: .75rem; }
.doc-no { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--gas-red); }
.workflow { display: flex; gap: 0; flex-wrap: wrap; }
.workflow .step { flex: 1; min-width: 110px; text-align: center; position: relative; padding: .5rem .25rem; font-size: .78rem; color: var(--gas-muted); }
.workflow .step .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--gas-border); background: #fff; margin: 0 auto .3rem; display: flex; align-items: center; justify-content: center; font-size: .75rem; position: relative; z-index: 1; }
.workflow .step::before { content: ""; position: absolute; top: 20px; left: -50%; right: 50%; height: 2px; background: var(--gas-border); }
.workflow .step:first-child::before { display: none; }
.workflow .step.done { color: var(--gas-green-700); font-weight: 600; }
.workflow .step.done .dot { background: var(--gas-green); border-color: var(--gas-green); color: #fff; }
.workflow .step.done::before { background: var(--gas-green); }
.workflow .step.current .dot { border-color: var(--gas-red); color: var(--gas-red); }

/* ---------- permission matrix ---------- */
.perm-table td, .perm-table th { text-align: center; vertical-align: middle; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-table .group-row td { background: var(--gas-green-50); color: var(--gas-green-800); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.perm-table .form-check-input { width: 1.15rem; height: 1.15rem; cursor: pointer; }
.perm-inherited { font-size: .68rem; color: var(--gas-green); display: block; }

/* ---------- modal ---------- */
.modal-header { border-bottom: 3px solid var(--gas-green); }
.modal-header .modal-title { font-weight: 700; color: var(--gas-green-700); }

/* ---------- toasts ---------- */
.toast { border: 0; box-shadow: 0 6px 24px rgba(0, 0, 0, .12); }
.toast.toast-success { border-left: 5px solid var(--gas-green); }
.toast.toast-danger { border-left: 5px solid var(--gas-red); }
.toast.toast-warning { border-left: 5px solid #e6a100; }
.toast.toast-info { border-left: 5px solid #1b5d9a; }

/* ---------- login ---------- */
.login-body { background: linear-gradient(135deg, var(--gas-green-800) 0%, var(--gas-green) 60%, var(--gas-green-600) 100%); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 3rem; padding: 2rem; flex-wrap: wrap; }
.login-brand { color: #fff; max-width: 420px; }
.login-brand img { width: 92px; height: 92px; object-fit: contain; background: #fff; border-radius: 50%; padding: 4px; border: 4px solid var(--gas-red); }
.login-brand h1 { font-weight: 700; font-size: 2rem; margin: 1.2rem 0 .3rem; }
.login-brand p { opacity: .85; font-size: 1.05rem; }
.login-points { list-style: none; padding: 0; margin-top: 1.5rem; }
.login-points li { margin-bottom: .5rem; opacity: .92; }
.login-points i { color: #ffd6dc; margin-right: .4rem; }
.login-card { background: #fff; border-radius: 1rem; padding: 2.2rem; width: 100%; max-width: 410px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); border-top: 6px solid var(--gas-red); }
.login-card h2 { font-weight: 700; color: var(--gas-green-700); font-size: 1.4rem; }

/* ---------- print (GAM forms) ---------- */
.print-page { background: #fff; max-width: 8.5in; margin: 0 auto; padding: .4in; color: #000; font-family: Arial, Helvetica, sans-serif; font-size: 10.5pt; }
.print-page table.form { width: 100%; border-collapse: collapse; }
.print-page table.form td, .print-page table.form th { border: 1px solid #000; padding: 3px 5px; vertical-align: top; }
.print-page .appendix { text-align: right; font-style: italic; font-size: 9pt; }
.print-page .form-title { text-align: center; font-weight: bold; font-size: 13pt; text-transform: uppercase; }
.print-page .sig { border-top: 1px solid #000; text-align: center; font-weight: bold; padding-top: 2px; margin-top: 28px; }
.print-page .box-label { font-weight: bold; }
.print-page .num { text-align: right; white-space: nowrap; }
.print-toolbar { max-width: 8.5in; margin: 1rem auto; display: flex; gap: .5rem; justify-content: flex-end; }

@media print {
    @page { size: letter portrait; margin: .35in; }
    body { background: #fff !important; font-size: 10pt; }
    .app-sidebar, .app-topbar, .app-footer, .no-print, .print-toolbar, .dt-buttons, .dt-search, .dt-length, .dt-paging, .dt-info, form.filters { display: none !important; }
    .app-main { margin: 0 !important; }
    .app-content { padding: 0 !important; }
    .card { border: 0; box-shadow: none; }
    .print-page { padding: 0; max-width: none; }
    a { text-decoration: none; color: #000; }
    .table > thead th { background: #eee !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- validation ---------- */
.validation-summary-valid { display: none; }
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }
.field-validation-error { color: var(--gas-red); font-size: .78rem; }
.input-validation-error { border-color: var(--gas-red) !important; }
.modal-content > form { display: contents; }

/* ---------- collapsible sidebar groups ---------- */
.sidebar-toggle { display: flex; justify-content: space-between; align-items: center; text-decoration: none; cursor: pointer; border-radius: .4rem; margin-top: .25rem; }
.sidebar-toggle:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.sidebar-toggle .chev { transition: transform .2s ease; font-size: .7rem; }
.sidebar-toggle.collapsed .chev { transform: rotate(-90deg); }
.sidebar-nav .collapse .nav-link, .sidebar-nav .collapsing .nav-link { padding-left: 1.1rem; }

/* ---------- statuses used by area modules ---------- */
.status-Prepared, .status-Inspected, .status-Granted, .status-PartiallyDelivered, .status-PartiallyLiquidated, .status-Low { background: #fff4e0; color: #9a5b00; }
.status-Received, .status-Issued, .status-DvGenerated { background: #e3f0fb; color: #1b5d9a; }
.status-Accepted, .status-Delivered, .status-Released, .status-Liquidated, .status-Replenished, .status-Verified, .status-Completed { background: var(--gas-green-50); color: var(--gas-green-700); }
.status-Returned, .status-Transferred { background: #f3ecfb; color: #6b3fa0; }
.status-Disposed, .status-Invalidated, .status-Stale, .status-Spoiled, .status-Overdue, .status-Lost { background: var(--gas-red-50); color: var(--gas-red); }

/* ---------- advances & liquidation monitor / alert bell ---------- */
.monitor-tabs .nav-link { padding: .4rem .35rem; color: var(--gas-muted); white-space: nowrap; }
.monitor-tabs .nav-link.active { color: var(--gas-green-700); font-weight: 600; }
.monitor-list { max-height: 430px; overflow-y: auto; }
.monitor-item.level-Lapsed { background: var(--gas-red-50); box-shadow: inset 4px 0 0 var(--gas-red); }
.monitor-item.level-DueSoon { box-shadow: inset 4px 0 0 #f0ad00; }
.monitor-item.level-Ok { opacity: .8; }
.topbar-bell { color: var(--gas-green-700); padding: .25rem; }
.topbar-bell.has-alerts { color: var(--gas-red); animation: gas-ring 2.4s ease-in-out 1; }
.alert-menu { width: 340px; max-width: calc(100vw - 2rem); }
.alert-menu-list { max-height: 360px; overflow-y: auto; }
.alert-menu-item { white-space: normal; border-left: 3px solid var(--gas-red); }
@keyframes gas-ring { 0%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-14deg); } 20%, 40% { transform: rotate(14deg); } 50% { transform: rotate(0); } }
@media (prefers-reduced-motion: reduce) { .topbar-bell.has-alerts { animation: none; } }

/* ---------- Release 10: searchable comboboxes (Tom Select, bootstrap5 theme) ---------- */
.lines-table .ts-wrapper.form-select-sm { font-size: .875rem; min-width: 160px; }
.ts-dropdown { z-index: 1080; font-size: .9rem; }
.ts-dropdown .active { background-color: var(--gas-green-50); color: inherit; }
.ts-dropdown .option { white-space: normal; }
.ts-wrapper.focus { border-color: var(--gas-green-600); box-shadow: 0 0 0 .2rem rgba(11, 110, 58, .15); }
.input-group > .ts-wrapper { position: relative; flex: 1 1 auto; width: 1%; min-width: 0; }
.input-group > .ts-wrapper:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .ts-wrapper:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.login-or { display: flex; align-items: center; gap: .75rem; color: #8a958f; font-size: .85rem; margin: 1rem 0; }
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid #dfe5e1; }
