/* ===================================================================
   WISDOM HILL ACADEMY — SCHOOL FEES, RECEIPTS & ARREARS LEDGER ERP
   Standalone modular addon (zero edits to app.js, style.css, api.php)
   =================================================================== */

.wha-fees-icon-bg {
    background: linear-gradient(135deg, #059669, #0d9488) !important;
    color: #ffffff !important;
}

.wha-fees-badge-free {
    background: rgba(16, 185, 129, 0.18) !important;
    color: #10b981 !important;
    border: 1px solid rgba(16, 185, 129, 0.35);
    font-size: 10px !important;
}

/* Analytics Card Injection */
.wha-an-fees-wrap {
    margin-top: 16px;
}

.wha-an-fees-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 12px 0;
}

.wha-an-fee-stat {
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
    padding: 10px 12px;
}

html[data-theme="dark"] .wha-an-fee-stat {
    background: rgba(15, 23, 42, 0.45);
    border-color: rgba(148, 163, 184, 0.16);
}

.wha-an-fee-lbl {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

html[data-theme="dark"] .wha-an-fee-lbl {
    color: #94a3b8;
}

.wha-an-fee-val {
    font-size: 18px;
    font-weight: 900;
    margin-top: 3px;
}

.wha-an-fee-progress-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.22);
    overflow: hidden;
    margin: 8px 0 6px;
}

.wha-an-fee-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #059669, #10b981);
    transition: width 0.3s ease;
}

/* Main Fees ERP Modal */
.wha-fees-overlay {
    position: fixed;
    inset: 0;
    z-index: 10650;
    background: rgba(15, 23, 42, 0.74);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
}

.wha-fees-overlay.hidden {
    display: none !important;
}

.wha-fees-dialog {
    width: 100%;
    max-width: 1160px;
    max-height: 93vh;
    background: #ffffff;
    color: #0f172a;
    border-radius: 18px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 24px 60px rgba(2, 6, 23, 0.38);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif;
}

html[data-theme="dark"] .wha-fees-dialog {
    background: #0f172a;
    color: #f8fafc;
    border-color: #1e293b;
}

.wha-fees-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #064e3b 0%, #0f766e 100%);
    color: #ffffff;
    flex-shrink: 0;
}

.wha-fees-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wha-fees-icon-box {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.wha-fees-title {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
}

.wha-fees-sub {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: #a7f3d0;
}

.wha-fees-close {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wha-fees-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    flex-wrap: wrap;
}

html[data-theme="dark"] .wha-fees-tabs {
    background: #111827;
    border-bottom-color: #1f2937;
}

.wha-fees-tab {
    flex: 1;
    min-width: 170px;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: inherit;
}

html[data-theme="dark"] .wha-fees-tab {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

.wha-fees-tab.active {
    background: linear-gradient(135deg, #059669, #0d9488);
    border-color: #059669;
    color: #ffffff;
}

.wha-fees-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.wha-fees-panel.hidden {
    display: none !important;
}

/* KPI Strip */
.wha-fees-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.wha-fees-kpi {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
}

html[data-theme="dark"] .wha-fees-kpi {
    background: #1e293b;
    border-color: #334155;
}

.wha-fees-kpi-lbl {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
}

html[data-theme="dark"] .wha-fees-kpi-lbl {
    color: #94a3b8;
}

.wha-fees-kpi-val {
    font-size: 18px;
    font-weight: 900;
    margin-top: 2px;
}

/* Controls & Table */
.wha-fees-filters {
    display: grid;
    grid-template-columns: 130px 120px 150px 160px 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.wha-fees-input,
.wha-fees-select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-size: 12.5px;
    font-family: inherit;
    box-sizing: border-box;
}

html[data-theme="dark"] .wha-fees-input,
html[data-theme="dark"] .wha-fees-select {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}

.wha-fees-table-wrap {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: auto;
    max-height: 370px;
}

html[data-theme="dark"] .wha-fees-table-wrap {
    border-color: #334155;
}

.wha-fees-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.wha-fees-table th,
.wha-fees-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    white-space: nowrap;
}

html[data-theme="dark"] .wha-fees-table th,
html[data-theme="dark"] .wha-fees-table td {
    border-bottom-color: #1e293b;
}

.wha-fees-table th {
    background: #f1f5f9;
    font-weight: 800;
    font-size: 11px;
    text-transform: uppercase;
    color: #475569;
    position: sticky;
    top: 0;
    z-index: 2;
}

html[data-theme="dark"] .wha-fees-table th {
    background: #1e293b;
    color: #cbd5e1;
}

.wha-fee-pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 800;
}

.wha-fee-pill.cleared { background: #dcfce7; color: #166534; }
.wha-fee-pill.partial { background: #fef3c7; color: #92400e; }
.wha-fee-pill.owing   { background: #fee2e2; color: #991b1b; }
.wha-fee-pill.exempt  { background: #e0e7ff; color: #1e40af; }
.wha-fee-pill.free    { background: #f1f5f9; color: #475569; }

.wha-fees-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 7px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

html[data-theme="dark"] .wha-fees-btn {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}

.wha-fees-btn-primary {
    background: linear-gradient(135deg, #059669, #0d9488);
    border-color: #059669;
    color: #ffffff !important;
}

.wha-fees-btn-blue {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    border-color: #1d4ed8;
    color: #ffffff !important;
}

/* Payment Sub-Drawer Box */
.wha-pay-drawer {
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

html[data-theme="dark"] .wha-pay-drawer {
    background: rgba(6, 78, 59, 0.35);
    border-color: #059669;
}

.wha-pay-drawer.hidden {
    display: none !important;
}

.wha-pay-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 8px;
}

/* Printable Official School Fee Receipt */
@media screen {
    #whaFeeReceiptPrintContainer {
        display: none !important;
    }
}

.wha-receipt-sheet {
    max-width: 190mm;
    margin: 0 auto;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif;
    color: #0f172a;
    background: #ffffff;
}

.wha-receipt-box {
    border: 2px solid #0f2b59;
    border-radius: 8px;
    padding: 12px 16px;
    position: relative;
    overflow: hidden;
    background: #ffffff;
    box-sizing: border-box;
    page-break-inside: avoid;
    break-inside: avoid;
}

.wha-receipt-cut-line {
    border-top: 1.5px dashed #64748b;
    margin: 10px 0;
    text-align: center;
    font-size: 9px;
    color: #64748b;
    letter-spacing: 1px;
}

.wha-receipt-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #0f2b59;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.wha-receipt-school {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wha-receipt-school img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.wha-receipt-school-name {
    font-size: 15px;
    font-weight: 900;
    color: #0f2b59;
}

.wha-receipt-school-sub {
    font-size: 10px;
    color: #475569;
    font-weight: 600;
}

.wha-receipt-badge {
    text-align: right;
}

.wha-receipt-title-pill {
    display: inline-block;
    background: #0f2b59 !important;
    color: #ffffff !important;
    font-size: 10.5px;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 999px;
    letter-spacing: 0.06em;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.wha-receipt-no {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 800;
    color: #b91c1c;
    margin-top: 3px;
}

.wha-receipt-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px 12px;
    background: #f8fafc !important;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 11px;
    margin-bottom: 8px;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.wha-receipt-amounts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.wha-receipt-amt-card {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 8px;
    text-align: center;
}

.wha-receipt-amt-lbl {
    font-size: 9px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
}

.wha-receipt-amt-val {
    font-size: 13.5px;
    font-weight: 900;
    color: #0f172a;
    margin-top: 2px;
}

.wha-receipt-foot {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 12px;
    padding-top: 6px;
    border-top: 1px dotted #cbd5e1;
    font-size: 10px;
}

@media print {
    html.has-active-session body.wha-printing-fee-receipt > :not(#whaFeeReceiptPrintContainer),
    html body.wha-printing-fee-receipt > :not(#whaFeeReceiptPrintContainer),
    body.wha-printing-fee-receipt > :not(#whaFeeReceiptPrintContainer),
    html.has-active-session body.wha-printing-fee-receipt > #printReportContainer,
    body.wha-printing-fee-receipt > #printReportContainer {
        display: none !important;
    }

    html.has-active-session body.wha-printing-fee-receipt > #whaFeeReceiptPrintContainer,
    html body.wha-printing-fee-receipt > #whaFeeReceiptPrintContainer,
    body.wha-printing-fee-receipt > #whaFeeReceiptPrintContainer {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: static !important;
        width: 100% !important;
        background: #ffffff !important;
        color: #0f172a !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

@media (max-width: 768px) {
    .wha-an-fees-grid,
    .wha-fees-kpi-row {
        grid-template-columns: 1fr 1fr;
    }
    .wha-fees-filters,
    .wha-pay-grid {
        grid-template-columns: 1fr;
    }
    .wha-fees-overlay {
        padding: 6px;
    }
}
