/* C:\xampp_8.2_TICL\htdocs\ticl_web\public\assets\css\pages\tenders-nest.css */

/* =====================================================
   TABLE SCROLL WRAPPER
   overflow-x + overflow-y = scroll ya table peke yake.
   Sticky thead inafanya kazi ndani ya container hii.
   Hakuna scrollbar ya ziada kwenye page nzima.
===================================================== */
.table-scroll {
    overflow-x: auto;
    overflow-y: clip;
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-sizing: border-box;
}

/* =====================================================
   TABLE LAYOUT
   table-layout: fixed + colgroup = msingi wa resize.
   JS inabadilisha col width → column yote (th+td)
   inabadilika mara moja. width:max-content inazuia
   table kubonyezwa chini ya jumla ya col widths.
===================================================== */
#tenderTable {
    table-layout: fixed;
    width: 1190px;
    /* jumla ya default widths: 60+140+280+200+110+110+80+90+120 */
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* =====================================================
   STICKY THEAD
   top:0 = ndani ya .table-scroll container.
   Thead inabaki juu wakati wowote unaposcroll chini.
   Sehemu zingine (dashboard, search, pagination)
   hazibaki juu — zinafuata scroll ya page nzima.
===================================================== */
#tenderTable thead th {
    background: #2b2b2b !important;
    color: #fff !important;
    border-right: 1px solid #fff !important;
    border-bottom: 2px solid #555 !important;
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    overflow: visible;
    /* ← BADILISHA HAPA */
    vertical-align: middle;
    text-align: left;
    padding: 10px 6px !important;
    font-size: 14px;
    line-height: 1.15;
}

/* =====================================================
   STICKY THEAD CLONE — JS-driven (sio CSS sticky).
   Clone ina position:fixed kwa hivyo haifuatii CSS table
   paint-order rules. JS inasync widths, horizontal scroll,
   na resize handlers kati ya clone na original.
===================================================== */
#sticky-thead-clone {
    /* JS inaweka position/top/left/width/display inline */
    box-sizing: border-box;
}

#tenderTable-stickyClone {
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    background: #2b2b2b;
    box-sizing: border-box;
}

#tenderTable-stickyClone thead th {
    background: #2b2b2b;
    color: #fff;
    border-right: 1px solid #fff;
    border-bottom: 2px solid #555;
    padding: 10px 6px;
    font-size: 14px;
    line-height: 1.15;
    vertical-align: middle;
    text-align: left;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    overflow: visible;
    position: relative;
    box-sizing: border-box;
}

#tenderTable-stickyClone thead th:last-child {
    border-right: none;
    padding-right: 12px;
}

#tenderTable-stickyClone .resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 100%;
    cursor: col-resize !important;
    z-index: 9999;
    user-select: none;
    touch-action: none;
    pointer-events: auto;
    background: transparent;
    box-sizing: border-box;
}

#tenderTable-stickyClone .resizer::after {
    content: '';
    position: absolute;
    right: 2px;
    top: 18%;
    bottom: 18%;
    width: 3px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 2px;
    pointer-events: none;
    transition: all 0.15s ease;
}

#tenderTable-stickyClone .resizer:hover::after,
#tenderTable-stickyClone .resizer.resizing::after {
    background: #4dabf7;
    top: 0;
    bottom: 0;
    width: 4px;
    right: 1px;
    box-shadow: 0 0 6px rgba(77, 171, 247, 0.8);
}

#tenderTable thead th:last-child {
    border-right: none !important;
}

/* =====================================================
   LAST COLUMN — zuia isizame kwenye border ya kulia
===================================================== */
#tenderTable thead th:last-child,
#tenderTable tbody td:last-child {
    padding-right: 12px !important;
}

/* =====================================================
   RESIZER HANDLE — Excel-style
   z-index:9999 inahakikisha resizer iko juu ya kila kitu.
   width:12px inaipa mtumiaji target kubwa ya drag.
   ::after ni kiashirio cha mstari kinachoonekana.
===================================================== */
#tenderTable th {
    position: relative;
}

#tenderTable .resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 100%;
    cursor: col-resize !important;
    z-index: 9999;
    user-select: none;
    touch-action: none;
    pointer-events: auto;
    background: transparent;
    box-sizing: border-box;
}

#tenderTable .resizer::after {
    content: '';
    position: absolute;
    right: 2px;
    top: 18%;
    bottom: 18%;
    width: 3px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 2px;
    pointer-events: none;
    transition: all 0.15s ease;
}

#tenderTable .resizer:hover::after,
#tenderTable .resizer.resizing::after {
    background: #4dabf7;
    top: 0;
    bottom: 0;
    width: 4px;
    right: 1px;
    box-shadow: 0 0 6px rgba(77, 171, 247, 0.8);
}

/* Wakati wa drag — body cursor na text-select */
body.col-resizing,
body.col-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* =====================================================
   TD
===================================================== */
td {
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    overflow: hidden;
    vertical-align: top;
}

/* =====================================================
   STATUS CELL
===================================================== */
tbody tr td.status-cell {
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

.status-cell .badge {
    display: inline-block;
    white-space: normal !important;
    word-break: break-word;
    max-width: 100%;
}

/* =====================================================
   ROW COLORS
===================================================== */
.table-warning {
    background-color: #fff3cd !important;
}

.table-danger {
    background-color: #f8d7da !important;
}

/* =====================================================
   SORT CURSOR — lazima iwe chini ya resizer cursor
===================================================== */
th[data-sort] {
    cursor: pointer;
    user-select: none;
}

/* =====================================================
   TABLE ROW HOVER
===================================================== */
tbody tr {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

tbody tr:hover {
    transform: translateX(3px);
    box-shadow: -3px 0 0 0 var(--primary, #0b2545);
}

/* =====================================================
   PAGINATION
===================================================== */
.pagination {
    gap: 4px;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    /* ← ongeza hii */
}

/* =====================================================
   BUTTONS — HOVER
===================================================== */
button,
.btn {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover,
.btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0.95;
}

.btn-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.btn-primary:hover {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}

/* =====================================================
   BODY BACKGROUND
===================================================== */
body {
    background-color: #def1f9;
}

/* =====================================================
   DASHBOARD CARD SPACING
===================================================== */
#dashboard-container .card {
    padding: 2px;
    border-radius: 7px;
    min-width: 112px;
    white-space: nowrap;
}

#dashboard-container .card-body {
    padding: 4px 8px;
}

#dashboard-container h6 {
    font-size: 12px;
    margin-top: 1px;
    margin-bottom: 1px;
    line-height: 1.1;
}

#dashboard-container .card strong {
    font-size: 14px;
    font-weight: 700;
}

#dashboard-container .card:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

/* =====================================================
   DASHBOARD LAYOUT
===================================================== */
#dashboard-container {
    line-height: 1.05;
    contain: layout;
}

#dashboard-container .dash-title {
    font-size: 1.5rem;
    line-height: 1.5;
    margin: 0 0 8px 0 !important;
    padding-bottom: 4px !important;
}

#dashboard-container .dash-section {
    font-size: 1.2rem;
    line-height: 1.05;
    margin: 0 !important;
}

#dashboard-container .mb-1:has(.dash-section) {
    margin-top: 10px !important;
    margin-bottom: 1px !important;
}

#dashboard-container .card strong {
    font-size: 15px;
    line-height: 1.1;
}

#dashboard-container .badge {
    font-size: 10px;
    line-height: 2;
}

#dashboard-container .d-flex {
    gap: 10px !important;
}

#dashboard-container h5 {
    margin-top: 6px;
    margin-bottom: 7px;
}

/* =====================================================
   BLINK ALERT
===================================================== */
@keyframes blinkSoft {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.blink-alert {
    animation: blinkSoft 1s infinite;
}

/* =====================================================
   CLOSING SOON BADGE
===================================================== */
.closing-soon-badge {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 92px;
    min-height: 52px;
    border-radius: 8px;
    padding: 4px 8px !important;
    line-height: 1.05 !important;
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

.closing-soon-badge strong {
    font-size: 18px !important;
    display: inline;
    margin-left: 4px;
}

/* =====================================================
   COMPACT LAYOUT
===================================================== */
body.tender-search {
    padding-top: 140px;
}

/* 1. Punguza padding chini ya main content */
body.tender-search main.content {
    margin-top: 37px;
    margin-left: 32px;
    padding-right: 32px;
    padding-bottom: 10px;
    /* ← ilikuwa 40px */
    box-sizing: border-box;
}

/* 2. Punguza padding ya kila kitufe cha pagination */
.page-link {
    padding: 2px 8px !important;
    /* ← Bootstrap default ni 6px 12px */
    font-size: 13px !important;
    line-height: 1.4 !important;
}

main.content h2.page-title {
    margin: 20px 0 10px 0;
    font-size: 1.7rem;
    line-height: 1.5;
    text-align: center;
}

#tender-wrapper h5 {
    font-size: 1.2rem;
    margin: 0;
    line-height: 1.2;
}

/* =====================================================
   TENDER WRAPPER RIGHT MARGIN
===================================================== */
#tender-wrapper {
    padding-right: 8px;
    /* nafasi ndogo upande wa kulia */
    box-sizing: border-box;
}

.table-scroll {
    margin-right: 0;
    /* zuia table-scroll isikate kwenye ukingo wa kulia */
    max-width: 100%;
}

#tender-wrapper>.d-flex {
    margin-bottom: 4px !important;
}

/* =====================================================
   DASHBOARD — sogeza "Closing Soon" badge kulia
   ioanishe na "Go Back" button
===================================================== */
#dashboard-container .d-flex.justify-content-between {
    padding-right: 8px;
}

/* =========================================================
   ADVANCED TENDER FILTER BAR
   Ilibadilisha ile search field moja (title/tender_no/entity
   yote kwa pamoja) na filters nne huru: Keyword, Category,
   Procuring Entity, Tender No. — zinazofanya kazi pamoja.
========================================================= */
.tender-filter-bar {
    display: grid;
    grid-template-columns:
        minmax(190px, 1.15fr) minmax(160px, 0.85fr) minmax(230px, 1.35fr) minmax(190px, 1fr);
    gap: 12px;
    align-items: end;
    margin-bottom: 14px;
    padding: 14px;
    background: #ffffff;
    border: 1px solid #d9e1e7;
    border-radius: 8px;
}

.tender-filter-field {
    min-width: 0;
}

.tender-filter-field label {
    display: block;
    margin-bottom: 5px;
    color: #168fd1;
    font-size: 13px;
    font-weight: 700;
}

.tender-filter-field .form-control,
.tender-filter-field .form-select {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid #aeb8c2;
    border-radius: 5px;
    background-color: #ffffff;
}

.tender-filter-field .form-control:focus,
.tender-filter-field .form-select:focus {
    border-color: #1d8fcb;
    box-shadow: 0 0 0 0.15rem rgba(29, 143, 203, 0.18);
}

.tender-filter-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.tender-filter-actions .btn {
    min-height: 40px;
    min-width: 110px;
}

/* Tablet */
@media (max-width: 992px) {
    .tender-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Mobile */
@media (max-width: 600px) {
    .tender-filter-bar {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .tender-filter-actions {
        grid-column: auto;
        display: grid;
        grid-template-columns: 1fr;
    }

    .tender-filter-actions .btn {
        width: 100%;
    }
}

/* =====================================================
   TENDERNEST SECTION LABEL
===================================================== */
#tenderNest-section {
    text-align: center;
    margin-bottom: 8px;
}

#tenderNest-section .tenderNest-section-label {
    display: inline-block;
    background: #000000;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    padding: 5px 14px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    margin-bottom: 4px;
}

/* =====================================================
   REVEAL ANIMATION
===================================================== */
body.tender-search .reveal-up {
    opacity: 0;
    transform: translateY(55px);
    transition: opacity 0.9s ease, transform 0.9s ease;
    will-change: transform, opacity;
}

body.tender-search .reveal-up.active {
    opacity: 1;
    transform: translateY(0);
}

body.tender-search .delay-1 {
    transition-delay: 0.1s;
}

body.tender-search .delay-2 {
    transition-delay: 0.25s;
}

body.tender-search .delay-3 {
    transition-delay: 0.4s;
}

body.tender-search .delay-4 {
    transition-delay: 0.55s;
}

body.tender-search .delay-5 {
    transition-delay: 0.7s;
}

/* =====================================================
   PAGE TITLE ANIMATION
===================================================== */
body.tender-search main.content h2.page-title {
    animation: tenderTitleSlide 1s ease both;
}

@keyframes tenderTitleSlide {
    from {
        opacity: 0;
        transform: translateY(-25px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
   MOBILE
===================================================== */
@media (max-width: 600px) {
    body.tender-search {
        padding-top: 145px;
    }

    body.tender-search main.content {
        margin-left: 10px;
        padding-right: 10px;
        /* ← ilikuwa 10px, sawa kwa mobile */
        box-sizing: border-box;
    }
}


/* =========================================================
   UNGM DASHBOARD — COMPACT HORIZONTAL CARDS
   Based on NeST CSS, but UNGM has more statistic cards.
========================================================= */

#dashboard-container .d-flex {
    gap: 4px !important;
}

#dashboard-container .card {
    flex: 0 0 auto !important;
    min-width: max-content !important;
    white-space: nowrap !important;
    padding: 1px !important;
    border-radius: 7px;
}

#dashboard-container .card-body {
    padding: 3px 6px !important;
}

#dashboard-container h6 {
    margin: 0 !important;
    font-size: 11px !important;
    line-height: 1.05 !important;
    white-space: nowrap !important;
}

#dashboard-container .card strong {
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1.05 !important;
    white-space: nowrap !important;
}

#dashboard-container .d-flex.flex-nowrap {
    margin-bottom: 2px !important;
}

#dashboard-container .card h6 [data-translate="dashLastSync"] {
    white-space: nowrap !important;
}

#dashboard-container .dash-title {
    margin-bottom: 4px !important;
}

#dashboard-container .dash-section {
    margin-bottom: 2px !important;
}

#dashboard-container .overflow-auto {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-bottom: 2px;
}
