/*
    Summary stylesheet for Auto Tracker.
    Contains summary board layout, summary result panel, and ageing summary table.
*/

/* ======================================================
   SUMMARY PAGE LAYOUT
   ====================================================== */
body.content-page.summary-page,
body.summary-page,
body.content-page.set-supplier-page,
body.set-supplier-page {
    background: #f4f7fb;
}

body.content-page.summary-page,
body.content-page.set-supplier-page {
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
    padding: 14px 18px !important;
}

.summary-board {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: calc(100vh - 28px);
    margin: 0;
}

/* ======================================================
   SUMMARY RESULT PANEL
   ====================================================== */
.summary-result-panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: flex;
    flex: none;
    flex-direction: column;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.summary-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-expand-all-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-left: 6px;
    padding: 0;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    background: #eff6ff;
    color: #2563eb;
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
}

.summary-expand-all-button:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

/* ======================================================
   SUMMARY TABLE & STICKY HORIZONTAL/VERTICAL SCROLLING
   ====================================================== */

.summary-page .process-table-scroll {
    overflow-x: auto !important;
    overflow-y: auto !important;
    max-height: calc(100vh - 125px) !important;
    position: relative;
    width: 100%;
    border-radius: 0 0 12px 12px;
}

.summary-table {
    width: 100%;
    min-width: 1650px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
    color: #1e293b;
}

/* General Header Sticky Top */
.summary-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid #cbd5e1;
    white-space: nowrap;
}

/* Sticky left key columns for summary table (main supplier rows ONLY) */
.summary-table:not(.set-supplier-table) > thead > tr > th:nth-child(1),
.summary-table:not(.set-supplier-table) > tbody > tr.summary-main-row > td:nth-child(1) {
    width: 42px;
    min-width: 42px;
    max-width: 42px;
    position: sticky;
    left: 0;
    z-index: 11;
    text-align: center;
}

.summary-table:not(.set-supplier-table) > thead > tr > th:nth-child(2),
.summary-table:not(.set-supplier-table) > tbody > tr.summary-main-row > td:nth-child(2) {
    width: 58px;
    min-width: 58px;
    max-width: 58px;
    position: sticky;
    left: 42px;
    z-index: 11;
    text-align: center;
}

.summary-table:not(.set-supplier-table) > thead > tr > th:nth-child(3),
.summary-table:not(.set-supplier-table) > tbody > tr.summary-main-row > td:nth-child(3) {
    width: 130px;
    min-width: 130px;
    max-width: 130px;
    position: sticky;
    left: 100px;
    z-index: 11;
}

.summary-table:not(.set-supplier-table) > thead > tr > th:nth-child(4),
.summary-table:not(.set-supplier-table) > tbody > tr.summary-main-row > td:nth-child(4) {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    position: sticky;
    left: 230px;
    z-index: 11;
    box-shadow: 3px 0 6px -2px rgba(0, 0, 0, 0.12);
}

.summary-table:not(.set-supplier-table) > thead > tr > th:nth-child(1),
.summary-table:not(.set-supplier-table) > thead > tr > th:nth-child(2),
.summary-table:not(.set-supplier-table) > thead > tr > th:nth-child(3),
.summary-table:not(.set-supplier-table) > thead > tr > th:nth-child(4) {
    background: #f8fafc !important;
    z-index: 12;
}

.summary-main-row > td:nth-child(1),
.summary-main-row > td:nth-child(2),
.summary-main-row > td:nth-child(3),
.summary-main-row > td:nth-child(4) {
    background: #ffffff !important;
}

/* Ensure nested sub-table cells never inherit main table sticky positioning */
.summary-subtable th,
.summary-subtable td,
.summary-detail-wrapper-row th,
.summary-detail-wrapper-row td {
    position: static !important;
    box-shadow: none !important;
}

/* Scrollable Data Columns */
.summary-table:not(.set-supplier-table) > thead > tr > th:nth-child(5),
.summary-table:not(.set-supplier-table) > tbody > tr.summary-main-row > td:nth-child(5) {
    width: 155px;
    text-align: right;
}

/* Expanded Detail Sub-table Column 5 (Narration) must be centered */
.summary-detail-wrapper-row table th:nth-child(5),
.summary-detail-wrapper-row table td:nth-child(5),
.summary-subtable th:nth-child(5),
.summary-subtable td:nth-child(5) {
    text-align: center !important;
}

.summary-table:not(.set-supplier-table) > thead > tr > th:nth-child(6),
.summary-table:not(.set-supplier-table) > tbody > tr.summary-main-row > td:nth-child(6) {
    width: 110px;
    text-align: center;
}

.summary-table:not(.set-supplier-table) th:nth-child(7),
.summary-table:not(.set-supplier-table) td:nth-child(7),
.summary-table:not(.set-supplier-table) th:nth-child(8),
.summary-table:not(.set-supplier-table) td:nth-child(8),
.summary-table:not(.set-supplier-table) th:nth-child(9),
.summary-table:not(.set-supplier-table) td:nth-child(9),
.summary-table:not(.set-supplier-table) th:nth-child(10),
.summary-table:not(.set-supplier-table) td:nth-child(10),
.summary-table:not(.set-supplier-table) th:nth-child(11),
.summary-table:not(.set-supplier-table) td:nth-child(11) {
    width: 120px;
    min-width: 120px;
    text-align: right;
}

.summary-table:not(.set-supplier-table) th:nth-child(12),
.summary-table:not(.set-supplier-table) td:nth-child(12),
.summary-table:not(.set-supplier-table) th:nth-child(13),
.summary-table:not(.set-supplier-table) td:nth-child(13) {
    width: 135px;
    min-width: 135px;
    text-align: right;
}

.summary-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
    vertical-align: middle;
}

.summary-table td.empty-state {
    text-align: center !important;
    padding: 36px 20px !important;
    color: #64748b !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    background: #ffffff !important;
    position: static !important;
    box-shadow: none !important;
}

.set-supplier-page .summary-board {
    width: 100%;
    max-width: none;
    height: auto;
    min-height: calc(100vh - 28px);
    margin: 0;
}

.set-supplier-page .summary-result-panel {
    display: flex;
    flex: none;
    flex-direction: column;
}

.set-supplier-page .process-table-scroll {
    flex: none;
    max-height: none !important;
    height: auto !important;
    width: 100%;
}

.set-supplier-table {
    width: 100%;
    min-width: 900px;
    table-layout: fixed;
}

.set-supplier-actions {
    white-space: nowrap;
}

.set-supplier-actions button + button {
    margin-left: 6px;
}

.set-supplier-table th:nth-child(1),
.set-supplier-table td:nth-child(1) {
    width: 90px;
    text-align: center;
}

.set-supplier-table th:nth-child(2),
.set-supplier-table td:nth-child(2),
.set-supplier-table th:nth-child(3),
.set-supplier-table td:nth-child(3) {
    width: 40%;
}

.set-supplier-table th:nth-child(4),
.set-supplier-table td:nth-child(4) {
    width: 90px;
    text-align: center;
}

.set-supplier-table .set-supplier-code-input,
.set-supplier-table .set-supplier-type-input {
    width: 100%;
    min-width: 0;
}

.summary-row-checkbox,
#summary-select-all {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #2563eb;
}

.summary-header-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #334155;
}

.summary-header-label > i {
    color: #2563eb;
    font-size: 12px;
}

.summary-icon-only-action {
    width: 38px;
    min-width: 38px;
    padding-inline: 0;
    justify-content: center;
}

.summary-type-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
}

.summary-type-filter i {
    color: #2563eb;
}

.summary-type-filter select {
    min-width: 145px;
    border: 0;
    outline: 0;
    background: transparent;
    color: #1e293b;
    font-size: 13px;
}

.summary-selected-count {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    margin-top: 5px;
    padding: 0 8px;
    border: 1px solid #dbeafe;
    border-radius: 7px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.summary-main-row td {
    font-weight: 600;
    background: #ffffff;
}

.summary-main-row:not(:first-child) td {
    border-top: 10px solid #f4f7fb;
}

.summary-main-row {
    cursor: pointer;
}

.summary-balance-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.summary-row-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #2563eb;
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.summary-row-icon-button:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.summary-reference-numbers-row td {
    background: #f8fafc;
    padding: 10px 14px;
}

.summary-reference-numbers-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.summary-reference-number-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    background: #ffffff;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.summary-detail-header td {
    background: #eff6ff !important;
    color: #1e3a8a;
    font-weight: 700;
    font-size: 11.5px;
    border-top: 1px solid #bfdbfe;
    border-bottom: 1px solid #bfdbfe;
    padding: 6px 12px;
}

.summary-detail-row td {
    background: #f8fafc !important;
    color: #334155;
    font-size: 12px;
    border-bottom: 1px dashed #e2e8f0;
}

.summary-detail-row:hover td {
    background: #f1f5f9 !important;
}

/* Subtable Clean Isolation Rules */
.summary-detail-wrapper-row > td {
    padding: 0 !important;
}

.summary-copyable-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
}

.summary-copy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #ffffff;
    color: #64748b;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s ease-in-out;
}

.summary-copy-button:hover {
    background: #eff6ff;
    color: #2563eb;
    border-color: #93c5fd;
}

/* AR Summary Sticky Left Columns */
.r-summary-sticky-col {
    position: sticky !important;
    background-clip: padding-box !important;
    opacity: 1 !important;
}

#r-summary-main-table thead th.r-summary-sticky-col {
    z-index: 30 !important;
    background-color: #f1f5f9 !important; /* solid slate-100 header */
}

#r-summary-main-table tbody tr td.r-summary-sticky-col {
    z-index: 20 !important;
    background-color: #ffffff !important; /* 100% solid opaque white */
}

#r-summary-main-table tbody tr:hover td.r-summary-sticky-col {
    background-color: #f8fafc !important; /* solid slate-50 on hover */
}

.r-sticky-col-1 { left: 0px !important; width: 38px !important; min-width: 38px !important; }
.r-sticky-col-2 { left: 38px !important; width: 38px !important; min-width: 38px !important; }
.r-sticky-col-3 { left: 76px !important; width: 50px !important; min-width: 50px !important; }
.r-sticky-col-4 { left: 126px !important; width: 120px !important; min-width: 120px !important; }
.r-sticky-col-5 { left: 246px !important; min-width: 180px !important; border-right: 2px solid #cbd5e1 !important; box-shadow: 3px 0 6px -2px rgba(0,0,0,0.12) !important; }

/* Month Selection Modal & Badges */
.r-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.r-modal-box {
    animation: modalFadeIn 0.2s ease-out forwards;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.r-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.r-btn-dark {
    background: #0f172a;
    color: #ffffff;
    border: 1px solid #0f172a;
}

.r-btn-dark:hover {
    background: #1e293b;
}

.r-btn-outline {
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.r-btn-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

/* Month Group Row Banner Styling */
.summary-month-group-row td {
    background: #ecfdf5 !important;
    border-top: 2px solid #a7f3d0;
    border-bottom: 1px solid #6ee7b7;
    padding: 6px 12px !important;
}

.summary-month-group-row > td:first-child {
    width: 510px !important;
    min-width: 510px !important;
    max-width: 510px !important;
    position: sticky !important;
    left: 0 !important;
    z-index: 11 !important;
    background: #ecfdf5 !important;
    box-shadow: 3px 0 6px -2px rgba(0, 0, 0, 0.08);
}

.summary-month-group-title {
    font-weight: 800;
    color: #064e3b;
}

.summary-month-group-total {
    text-align: right;
    font-weight: 800;
    color: #064e3b;
}

.summary-month-bar-row td {
    padding: 6px 12px !important;
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0;
}

.summary-month-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 2px 0;
}

.summary-month-bar-label {
    font-size: 11px;
    font-weight: 700;
    color: #334155;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.summary-month-pills-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.summary-month-pill {
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.summary-month-pill:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

.summary-month-pill.active {
    background: #047857 !important;
    color: #ffffff !important;
    border-color: #047857 !important;
    box-shadow: 0 1px 2px rgba(4, 120, 87, 0.3);
}



