/*
 * report-table.css
 * ─────────────────────────────────────────────────────────────────────────────
 * Shared styles for all report pages using #reportTable.
 * Supports light/dark theming driven by html.light-mode / html.dark-mode
 * classes set by the parent window theme manager (ThemeManager in index.asp).
 *
 * Usage:
 *   <link rel="stylesheet" href="/include/styles/report-table.css">
 *
 * Table markup expected:
 *   <table id="reportTable">
 *     <thead> ... </thead>
 *     <tbody>
 *       <tr class="group-header"> ... </tr>  <!-- optional section label -->
 *       <tr> ... </tr>                        <!-- data rows             -->
 *       <tr class="totals-row"> ... </tr>     <!-- totals / summary      -->
 *     </tbody>
 *   </table>
 *
 * Topbar markup expected:
 *   <div class="rpt-topbar">
 *     <div class="rpt-title">Report <span>Title</span></div>
 *     <div class="rpt-badge">Type</div>          <!-- optional -->
 *     <div class="rpt-actions">                  <!-- buttons  -->
 *       <button class="btn-rpt" onclick="window.print()">Print</button>
 *       <button class="btn-rpt excel" onclick="exportToExcel()">Export Excel</button>
 *     </div>
 *   </div>
 *
 * Meta bar markup expected:
 *   <div class="rpt-meta">
 *     <div>Label: <strong>Value</strong></div>
 *   </div>
 * ─────────────────────────────────────────────────────────────────────────────
 */

/* ═══════════════════════════════════════════════════════════════════
   CSS VARIABLES — dark default, overridden by html.light-mode
   ═══════════════════════════════════════════════════════════════════ */
html {
    --rpt-bg: #0f1117;
    --rpt-surface: #181c27;
    --rpt-border: #272d3d;
    --rpt-accent: #4f8ef7;
    --rpt-accent2: #a78bfa;
    --rpt-text: #e2e8f0;
    --rpt-muted: #64748b;
    --rpt-neg: #f87171;
    --rpt-pos: #34d399;
    --rpt-header-bg: #1e243a;
    --rpt-row-alt: #141824;
    --rpt-hover-row: #1a2035;
    --rpt-group-bg: #161c2e;
}

    html.light-mode {
        --rpt-bg: #f4f6fb;
        --rpt-surface: #ffffff;
        --rpt-border: #dde2ee;
        --rpt-accent: #2563eb;
        --rpt-accent2: #7c3aed;
        --rpt-text: #1e2535;
        --rpt-muted: #64748b;
        --rpt-neg: #dc2626;
        --rpt-pos: #059669;
        --rpt-header-bg: #eef1f8;
        --rpt-row-alt: #f9fafc;
        --rpt-hover-row: #edf2ff;
        --rpt-group-bg: #f0f3fc;
    }

/* ═══════════════════════════════════════════════════════════════════
   SMOOTH THEME TRANSITIONS
   ═══════════════════════════════════════════════════════════════════ */
.rpt-topbar,
.rpt-meta,
#reportTable thead tr,
#reportTable tr.group-header td,
#reportTable tr.totals-row td,
.rpt-table-wrap {
    transition: background .25s, color .25s, border-color .25s;
}

/* ═══════════════════════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════════════════════ */
.rpt-topbar {
    background: var(--rpt-surface);
    border-bottom: 1px solid var(--rpt-border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rpt-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--rpt-text);
    flex: 1;
}

    .rpt-title span {
        color: var(--rpt-accent);
        font-style: italic;
    }

.rpt-badge {
    background: var(--rpt-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.rpt-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════════
   TOOLBAR BUTTONS  (.btn-rpt)
   ═══════════════════════════════════════════════════════════════════ */
.btn-rpt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--rpt-border);
    color: var(--rpt-muted);
    padding: 5px 13px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: border-color .2s, color .2s;
    white-space: nowrap;
    text-decoration: none;
}

    .btn-rpt:hover {
        border-color: var(--rpt-accent2);
        color: var(--rpt-accent2);
    }

    .btn-rpt.excel:hover {
        border-color: #16a34a;
        color: #16a34a;
    }

    .btn-rpt svg {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

/* ═══════════════════════════════════════════════════════════════════
   META BAR
   ═══════════════════════════════════════════════════════════════════ */
.rpt-meta {
    padding: 10px 20px;
    display: flex;
    gap: 20px;
    color: var(--rpt-muted);
    font-size: 11px;
    letter-spacing: 0.4px;
    background: var(--rpt-surface);
    border-bottom: 1px solid var(--rpt-border);
    flex-wrap: wrap;
}

    .rpt-meta strong {
        color: var(--rpt-accent2);
    }

/* ═══════════════════════════════════════════════════════════════════
   TABLE WRAPPER
   ═══════════════════════════════════════════════════════════════════ */
.rpt-table-wrap {
    margin: 14px 20px 0;
    border: 1px solid var(--rpt-border);
    border-radius: 10px;
    overflow-x: auto;
}

/* ═══════════════════════════════════════════════════════════════════
   TABLE — #reportTable
   ═══════════════════════════════════════════════════════════════════ */
#reportTable {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

    /* ── Head ── */
    #reportTable thead tr {
        background: var(--rpt-header-bg);
    }

    #reportTable thead th {
        padding: 10px 12px;
        text-align: right;
        font-size: 11px;
        font-weight: 500;
        color: var(--rpt-muted);
        letter-spacing: 0.7px;
        text-transform: uppercase;
        border-bottom: 1px solid var(--rpt-border);
        white-space: nowrap;
    }

        #reportTable thead th.left {
            text-align: left;
        }

        #reportTable thead th.center {
            text-align: center;
        }

        #reportTable thead th.period-col {
            color: var(--rpt-accent);
        }

    /* ── Body rows ── */
    #reportTable tbody tr {
        border-bottom: 1px solid var(--rpt-border);
        transition: background .15s;
    }

        #reportTable tbody tr:last-child {
            border-bottom: none;
        }

        #reportTable tbody tr:nth-child(even) {
            background: var(--rpt-row-alt);
        }

        #reportTable tbody tr:hover {
            background: var(--rpt-hover-row);
        }

    /* ── Group header rows ── */
    #reportTable tr.group-header td {
        background: var(--rpt-group-bg);
        color: var(--rpt-accent2);
        font-size: 11px;
        letter-spacing: 1px;
        text-transform: uppercase;
        padding: 7px 12px;
        border-top: 1px solid var(--rpt-border);
        font-weight: 600;
    }

    /* ── Data cells ── */
    #reportTable td {
        padding: 9px 12px;
        text-align: right;
        white-space: nowrap;
        vertical-align: middle;
        font-size: 12px;
        color: var(--rpt-text);
    }

        #reportTable td.left {
            text-align: left;
        }

        #reportTable td.center {
            text-align: center;
        }

        #reportTable td.code {
            color: var(--rpt-muted);
            font-size: 11px;
        }

        #reportTable td.name {
            color: var(--rpt-text);
        }

    /* ── Amount spans ── */
    #reportTable .amt {
        color: var(--rpt-pos);
    }

        #reportTable .amt.neg {
            color: var(--rpt-neg);
        }

    #reportTable .nil {
        color: var(--rpt-border);
    }

    /* ── Totals row ── */
    #reportTable tr.totals-row td {
        background: var(--rpt-header-bg);
        border-top: 2px solid var(--rpt-accent);
        color: var(--rpt-text);
        font-weight: 600;
        padding: 10px 12px;
        font-size: 12px;
    }

    #reportTable tr.totals-row .amt {
        color: var(--rpt-accent);
    }

        #reportTable tr.totals-row .amt.neg {
            color: var(--rpt-neg);
        }

/* ═══════════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════════ */
.rpt-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--rpt-muted);
}

.rpt-empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════════════════════
   PRINT OVERRIDES
   ═══════════════════════════════════════════════════════════════════ */
@media print {
    .rpt-topbar,
    .rpt-meta {
        display: none !important;
    }

    .rpt-table-wrap {
        border: 1px solid #ccc !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    #reportTable thead th {
        background: #f0f0f0 !important;
        color: #333 !important;
    }

    #reportTable tbody tr:nth-child(even) {
        background: #fafafa !important;
    }

    #reportTable tr.group-header td {
        background: #e8e8e8 !important;
        color: #444 !important;
    }

    #reportTable tr.totals-row td {
        background: #f0f0f0 !important;
    }

    #reportTable .amt {
        color: #000 !important;
    }

        #reportTable .amt.neg {
            color: #c00 !important;
        }

    #reportTable .nil {
        color: #999 !important;
    }
}
