/* ===================================================================
   HeJacksonWeb - Site Stylesheet
   Clean, light design with consistent button and table styling.
   =================================================================== */

/* --- Base --- */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin-bottom: 60px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f8f9fa;
}

/* --- Links --- */
a {
    color: #0077cc;
}

a:hover {
    color: #005a99;
}

/* --- Focus Styles --- */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* --- Brand Colors --- */
/* Primary brand blue used for navbar and primary buttons */

/* --- Buttons --- */
/* Primary button - use for the main action on the page (1 Primary, rest Secondary) */
.btn-primary {
    color: #fff;
    background-color: #2E3A8C;
    border-color: #2E3A8C;
}

.btn-primary:hover {
    color: #fff;
    background-color: #25307A;
    border-color: #25307A;
}

.btn-primary:active, .btn-primary:focus {
    color: #fff;
    background-color: #1F2966;
    border-color: #1F2966;
}

/* Secondary button - use for all other actions */
.btn-secondary {
    color: #333;
    background-color: #f0f0f0;
    border-color: #ccc;
}

.btn-secondary:hover {
    color: #333;
    background-color: #e0e0e0;
    border-color: #adadad;
}

.btn-secondary:active, .btn-secondary:focus {
    background-color: #d4d4d4;
    border-color: #8c8c8c;
}

/* Danger button */
.btn-danger {
    color: #fff;
    background-color: #d9534f;
    border-color: #d43f3a;
}

.btn-danger:hover {
    color: #fff;
    background-color: #c9302c;
    border-color: #ac2925;
}

/* Button transition for smooth hover effect */
.btn {
    transition: all 0.2s ease-in-out;
}

/* --- Layout --- */
.border-top {
    border-top: 1px solid #e5e5e5;
}

.border-bottom {
    border-bottom: 1px solid #e5e5e5;
}

.box-shadow {
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}

.footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    white-space: nowrap;
    line-height: 60px;
    font-size: 0.85rem;
}

/* --- Navbar --- */
.navbar-portal {
    background-color: #2E3A8C !important;
}

.navbar-portal .navbar-brand,
.navbar-portal .nav-link,
.navbar-portal .navbar-nav .nav-link,
.navbar-portal .dropdown-toggle {
    color: #ffffff !important;
}

.navbar-portal .nav-link:hover,
.navbar-portal .nav-link:focus,
.navbar-portal .dropdown-toggle:hover {
    color: #d6dcf5 !important;
}

.navbar-portal .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.5);
}

/* --- Org Selector (top nav) --- */
.org-selector {
    margin-right: 50px;
}

.org-selector label.form-label {
    display: inline;
    white-space: nowrap;
}

.org-selector .org-selector-input {
    min-width: 200px;
    max-width: 260px;
}

@media (max-width: 575.98px) {
    .org-selector {
        margin-right: 0;
        margin-top: 8px;
        margin-bottom: 8px;
        width: 100%;
    }
    .org-selector .org-selector-input {
        flex: 1;
        max-width: none;
    }
}

/* --- Dashboard widgets / cards --- */
.widget-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 .25rem .75rem rgba(0,0,0,.04);
    margin-bottom: 1rem;
}

.widget-card .widget-header {
    padding: 8px 12px;
    border-bottom: 1px solid #e9ecef;
    background: #f6f8fa;
    font-weight: 600;
    font-size: 0.9rem;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.widget-card .widget-body {
    padding: 10px 12px;
}

.widget-card table.table {
    margin-bottom: 0;
    font-size: 0.78rem;
}

.widget-card table.table thead th {
    padding: 4px 8px;
    font-size: 0.75rem;
}

.widget-card table.table td {
    padding: 4px 8px;
}

.show-all-link {
    font-size: 0.8rem;
    margin-top: 4px;
    display: inline-block;
}

.info-card-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.85rem;
    border-bottom: 1px dashed #eee;
}

.info-card-row:last-child {
    border-bottom: none;
}

.info-card-row .label {
    color: #666;
}

.info-card-row .value {
    font-weight: 600;
}

.navbar-brand {
    white-space: normal;
    display: flex;
    align-items: center;
    padding: 4px 0;
}

.navbar-brand img {
    max-height: 36px;
    width: auto;
}

.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
    color: #fff;
    background-color: #337ab7;
    border-color: #2e6da4;
}

/* --- Tables --- */
/* All tables should use table-sm for compact display */
.table {
    font-size: 0.875rem;
}

/* Table header styling - clean, professional blue-grey */
.table thead th {
    background-color: #4a6785;
    color: #fff;
    font-weight: 600;
    border-color: #3d566e;
    padding: 8px 10px;
    vertical-align: middle;
}

.table thead th a {
    color: #fff;
    text-decoration: none;
}

.table thead th a:hover {
    color: #d0e0f0;
    text-decoration: underline;
}

/* Sortable table styles */
.sortable th {
    cursor: pointer;
    position: relative;
    user-select: none;
}

.sortable th:hover {
    background-color: #3d566e;
}

.sortable th::after {
    content: '\2195';
    position: absolute;
    right: 8px;
    opacity: 0.4;
    font-size: 0.75rem;
}

.sortable th.sort-asc::after {
    content: '\2191';
    opacity: 1;
}

.sortable th.sort-desc::after {
    content: '\2193';
    opacity: 1;
}

/* --- Action Icons in Tables --- */
.action-icon {
    width: 18px;
    height: 18px;
    margin: 0 4px;
    opacity: 0.7;
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.action-icon:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* --- Cards --- */
.card {
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

/* --- Forms --- */
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* --- Alerts --- */
.alert {
    font-size: 0.9rem;
}

/* --- Procurement status colours ---
   These mirror the colour coding used in the legacy Power BI Procurement
   Summary report. Adjust here to tune the dashboard's status palette. */
.proc-stat-card {
    border-radius: 6px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #dee2e6;
    text-align: center;
    margin-bottom: 8px;
    height: 100%;
}
.proc-stat-card .proc-stat-label {
    font-size: 0.7rem;
    color: #555;
    text-transform: none;
    line-height: 1.15;
    margin-bottom: 4px;
}
.proc-stat-card .proc-stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #2E3A8C;
}
.proc-stat-card.proc-stat-warn   { border-top: 3px solid #f0ad4e; }
.proc-stat-card.proc-stat-ok     { border-top: 3px solid #5cb85c; }
.proc-stat-card.proc-stat-info   { border-top: 3px solid #5bc0de; }
.proc-stat-card.proc-stat-bad    { border-top: 3px solid #d9534f; }
.proc-stat-card.proc-stat-neutral{ border-top: 3px solid #6c757d; }

.proc-status-pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    background: #adb5bd;
    line-height: 1.4;
    white-space: nowrap;
}
/* Requisition statuses (CodeType = SRQ) */
.proc-status-Open                   { background: #5bc0de; }
.proc-status-AwaitingApproval       { background: #f0ad4e; color: #000; }
.proc-status-PendingApproval        { background: #f0ad4e; color: #000; }
.proc-status-POCreated              { background: #2E3A8C; }
.proc-status-POReady                { background: #5cb85c; }
.proc-status-PORead                 { background: #5cb85c; }
.proc-status-Completed              { background: #198754; }
.proc-status-Rejected               { background: #d9534f; }
.proc-status-Cancelled              { background: #6c757d; }
.proc-status-ChangeOrderPending     { background: #fd7e14; color: #000; }
.proc-status-ChangeOrderPendingApproval { background: #fd7e14; color: #000; }
.proc-status-ChangeOrderCompleted   { background: #20c997; }
.proc-status-ChangeOrderDone        { background: #20c997; }
.proc-status-OnAccount              { background: #6610f2; }
.proc-status-DepositPaid            { background: #0d6efd; }
/* Order statuses (CodeType = SPO) */
.proc-status-POCreated              { background: #2E3A8C; }
.proc-status-POReady                { background: #5cb85c; }
.proc-status-ReadytoService         { background: #5cb85c; }
.proc-status-ReadyToService         { background: #5cb85c; }
.proc-status-Complete               { background: #198754; }
.proc-status-Completed              { background: #198754; }
.proc-status-OrderCancelled         { background: #6c757d; }
.proc-status-OrderCompleted         { background: #198754; }
.proc-status-CancelledbyBuyer       { background: #6c757d; }
.proc-status-CancelledByBuyer       { background: #6c757d; }
.proc-status-CompletedbyBuyer       { background: #198754; }
.proc-status-CompletedByBuyer       { background: #198754; }
.proc-status-ChangeOrderProcess     { background: #fd7e14; color: #000; }
/* Fallback for anything unmapped — base .proc-status-pill background handles this */
.proc-status-Unknown                { background: #adb5bd; color: #212529; }

/* --- Procurement Detail Modal table --- */
.proc-detail-table {
    font-size: 0.72rem;
}
.proc-detail-table thead th {
    font-size: 0.72rem;
    white-space: nowrap;
    vertical-align: middle;
}
.proc-detail-filter-row th {
    padding: 2px 4px;
    background: #f8f9fa;
}
.proc-detail-filter {
    font-size: 0.68rem;
    padding: 1px 4px;
    height: auto;
    min-width: 60px;
}

/* --- Procurement multi-select filters --- */
.proc-multi {
    height: calc(1.5em + 0.5rem + 2px);
    overflow-y: auto;
}
.proc-multi[size="1"] {
    /* Browsers ignore size on multi-select; force a compact visible height */
    min-height: calc(1.5em + 0.5rem + 2px);
    max-height: calc(1.5em + 0.5rem + 2px);
}
.proc-multi:focus {
    min-height: 160px;
    max-height: 160px;
}

/* --- Procurement picker (compact label + Change link) --- */
.proc-picker {
    background-color: #fff;
    cursor: default;
}
.proc-picker a {
    text-decoration: none;
}
.proc-picker a:hover {
    text-decoration: underline;
}

/* --- Procurement custom overlay (no Bootstrap Modal API) --- */
.proc-overlay { position: fixed; inset: 0; z-index: 1080; }
.proc-overlay-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.proc-overlay-dialog {
    position: relative;
    background: #fff;
    max-width: 70vw;
    width: 70vw;
    margin: 5vh auto;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,.3);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.proc-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem .75rem;
    border-bottom: 1px solid #dee2e6;
}
.proc-overlay-body { padding: .5rem .75rem; overflow: auto; }
.proc-overlay-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .5rem .75rem;
    border-top: 1px solid #dee2e6;
}
/* Picker overlay — larger checkboxes (~50% bigger than browser default ~13px) */
.proc-overlay input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
    vertical-align: middle;
    flex-shrink: 0;
}

/* --- Login Page --- */
.login-container {
    max-width: 400px;
    margin: 0 auto;
}
/* Procurement table pager */
.proc-page-btn { min-width: 32px; padding: 2px 6px; font-size: 12px; }
#reqsPager, #itemsPager { gap: 3px; flex-wrap: wrap; }
.proc-detail-table thead.sticky-top th { background-color: #4a6785; z-index: 2; }

/* --- Data tables: keep the columns inside the card ---------------------------
   These grids carry a lot of columns, and hard-coded pixel widths pushed the
   table past its container so the last columns fell off the right-hand edge.
   Columns now size to their content up to a cap, and anything longer is clipped
   with an ellipsis - the full value is already on the cell's title attribute,
   and the 20-character rule keeps most cells well inside the cap anyway.
   .table-responsive still wraps every table, so narrow screens scroll rather
   than squash.                                                               */
.hj-fit {
    width: 100%;
    table-layout: auto;
}
.hj-fit th,
.hj-fit td {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Numeric and short-code columns never need the full cap. */
.hj-fit td.text-end,
.hj-fit th.text-end {
    max-width: 120px;
}
/* The widest grids (14+ columns) get a slightly tighter type size so the whole
   row fits on a normal laptop screen without horizontal scrolling. */
.hj-fit-dense th,
.hj-fit-dense td {
    font-size: .8rem;
    padding-top: .3rem;
    padding-bottom: .3rem;
    max-width: 120px;
}

/* ===================================================================
   Fleet Hub
   -------------------------------------------------------------------
   Status colours are taken from the legacy Power BI "Hub - Fleet"
   report so the two look the same to users mid-migration. Adjust the
   values here to tune the Fleet palette.

   The status list is driven by the data, not hard-coded: the report
   defines a "To Be Sold" chip that has no rows behind it. Its class is
   defined so it renders correctly if the value ever appears, but the
   page will not show an empty card for it.
   =================================================================== */

.fleet-status-pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    color: #333;
    background: #e9ecef;
}
.fleet-status-pill.status-running        { background: #8BD98B; }
.fleet-status-pill.status-off-hired      { background: #B8C4CE; }
.fleet-status-pill.status-breakdown      { background: #FF9191; }
.fleet-status-pill.status-sold           { background: #7A73FF; color: #fff; }
.fleet-status-pill.status-standing       { background: #FFF64F; }
.fleet-status-pill.status-being-repaired { background: #FFB650; }
.fleet-status-pill.status-to-be-sold     { background: #FF6DFD; }
.fleet-status-pill.status-unspecified    { background: #e9ecef; color: #6c757d; }

/* Status stat cards on the register and summary. The left border carries the
   same colour as the pill so a card and a row read as the same status. */
.fleet-stat-card {
    border-radius: 6px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-left: 4px solid #adb5bd;
    text-align: center;
    margin-bottom: 8px;
    height: 100%;
    cursor: pointer;
    transition: box-shadow .15s ease-in-out, transform .15s ease-in-out;
}
.fleet-stat-card:hover      { box-shadow: 0 2px 6px rgba(0,0,0,.12); transform: translateY(-1px); }
.fleet-stat-card.is-active  { box-shadow: 0 0 0 2px #2E3A8C inset; }
.fleet-stat-card .fleet-stat-label {
    font-size: 0.7rem;
    color: #555;
    line-height: 1.15;
    margin-bottom: 4px;
}
.fleet-stat-card .fleet-stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #2E3A8C;
}
.fleet-stat-card.status-running        { border-left-color: #8BD98B; }
.fleet-stat-card.status-off-hired      { border-left-color: #B8C4CE; }
.fleet-stat-card.status-breakdown      { border-left-color: #FF9191; }
.fleet-stat-card.status-sold           { border-left-color: #7A73FF; }
.fleet-stat-card.status-standing       { border-left-color: #FFF64F; }
.fleet-stat-card.status-being-repaired { border-left-color: #FFB650; }
.fleet-stat-card.status-to-be-sold     { border-left-color: #FF6DFD; }
.fleet-stat-card.status-unspecified    { border-left-color: #ced4da; }

/* Expiry state colouring for licence / insurance cells. This is the thing the
   Power BI register cannot do and is the main reason to look at this page. */
.fleet-expiry-expired      { color: #b02a37; font-weight: 600; }
.fleet-expiry-due          { color: #b8860b; font-weight: 600; }
.fleet-expiry-ok           { color: inherit; }
.fleet-expiry-notrecorded  { color: #adb5bd; }

/* Compact info panels used on Plant DNA - label left, value right. */
.fleet-info-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.78rem;
}
.fleet-info-row:last-child { border-bottom: 0; }
.fleet-info-row .label { color: #6c757d; flex: 0 0 45%; }
.fleet-info-row .value { font-weight: 600; text-align: right; word-break: break-word; }

.fleet-page-btn { min-width: 34px; }
