/* =========================================================================
   Payment & Analytics — dashboard theme (pa- prefix)
   Aligned to the app's dashboard standard (CommissionSetup / ModuleGroup /
   GlobalMenuBuilder): full-width #0F1412 page, neutral #2E2E2E / #252927
   borders, underline tabs, icon-box stat cards, gradient primary buttons,
   and the shared table style. Accent #2DD4BF (teal).
   ========================================================================= */

/* ── Page container ─────────────────────────────────────────────── */
.pa-page {
    background: #0F1412;
    min-height: 100vh;
    padding-bottom: 2rem;
}

/* ── Page head (title bar) ──────────────────────────────────────── */
.pa-head {
    padding: 1.25rem;
    border-bottom: 2px solid #2E2E2E;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.pa-head h1 {
    color: #FFFFFF;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}
.pa-head h1 i { color: #2DD4BF; font-size: 1.25rem; }
.pa-sub { color: #6B7280; font-size: 0.813rem; margin-top: 4px; }

/* ── Tab bar (underline tabs) ───────────────────────────────────── */
.pa-tabs {
    display: flex;
    gap: 0;
    padding: 0 1.25rem;
    border-bottom: 2px solid #2E2E2E;
    background: #0F1412;
    overflow-x: auto;
}
.pa-tab {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: #6B7280;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
}
.pa-tab:hover { color: #D1D5DB; }
.pa-tab.active { color: #2DD4BF; border-bottom-color: #2DD4BF; }
.pa-tab i { font-size: 0.813rem; }

/* ── Body / sections ──────────────────────────────────────────── */
.pa-body { padding: 1.25rem; }
.pa-section { margin-top: 1.5rem; }
.pa-section-title {
    color: #FFFFFF; font-size: 1rem; font-weight: 700; margin: 0 0 0.875rem;
    display: flex; align-items: center; gap: 0.5rem;
}
.pa-section-title i { color: #2DD4BF; font-size: 1.125rem; }

/* ── KPI / stat cards (matches .cs-stat-card) ───────────────────── */
.pa-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 1.25rem;
}
.pa-kpi {
    background: #1A1D1C;
    border: 1px solid #2E2E2E;
    border-radius: 14px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.pa-kpi-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; flex-shrink: 0;
    background: rgba(45, 212, 191, 0.12); color: #2DD4BF;
}
.pa-kpi.accent .pa-kpi-icon { background: rgba(139, 92, 246, 0.12); color: #8B5CF6; }
.pa-kpi.warn .pa-kpi-icon { background: rgba(245, 158, 11, 0.12); color: #F59E0B; }
.pa-kpi.danger .pa-kpi-icon { background: rgba(239, 68, 68, 0.12); color: #EF4444; }
.pa-kpi.good .pa-kpi-icon { background: rgba(34, 197, 94, 0.12); color: #22C55E; }
.pa-kpi-body { min-width: 0; }
.pa-kpi-value { color: #FFFFFF; font-size: 1.5rem; font-weight: 700; line-height: 1; }
.pa-kpi-label {
    color: #6B7280; font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em; margin-top: 6px;
}
.pa-kpi-sub { color: #6B7280; font-size: 0.75rem; margin-top: 2px; }

/* ── Toolbar / filter bar (matches .cs-filter-bar) ──────────────── */
.pa-toolbar {
    display: flex; align-items: flex-end; gap: 0.75rem;
    flex-wrap: wrap; margin-bottom: 1rem;
}
.pa-field { display: flex; flex-direction: column; gap: 4px; }
.pa-field label {
    color: #6B7280; font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.pa-input, .pa-select {
    padding: 0.5rem 0.75rem;
    background: #1A1D1C;
    border: 1px solid #2E2E2E;
    border-radius: 0.5rem;
    color: #FFFFFF;
    font-size: 0.875rem;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
    min-width: 130px;
    transition: border-color 0.2s;
}
.pa-input:focus, .pa-select:focus { border-color: #2DD4BF; box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.08); }
.pa-select { cursor: pointer; }
.pa-select option { background: #1A1D1C; }

/* ── Buttons (matches .cs-btn family) ──────────────────────────── */
.pa-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
    cursor: pointer; font-weight: 700; font-size: 0.813rem;
    border-radius: 0.5rem; transition: all 0.15s; font-family: inherit;
    padding: 0.5rem 1rem; border: none;
    background: linear-gradient(135deg, #2DD4BF, #22C55E);
    color: #0F1412; box-shadow: 0 2px 8px rgba(45, 212, 191, 0.2);
}
.pa-btn:hover { box-shadow: 0 4px 16px rgba(45, 212, 191, 0.3); transform: translateY(-1px); }
.pa-btn.sm { padding: 0.4rem 0.75rem; font-size: 0.75rem; font-weight: 600; box-shadow: none; }
.pa-btn.sm:hover { transform: none; box-shadow: 0 2px 8px rgba(45, 212, 191, 0.2); }
.pa-btn.ghost {
    background: #252927; color: #D1D5DB; border: none; box-shadow: none; font-weight: 600;
}
.pa-btn.ghost:hover { background: #2E2E2E; transform: none; box-shadow: none; }
.pa-btn.danger { background: #EF4444; color: #fff; box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2); }
.pa-btn.danger:hover { background: #DC2626; box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3); }
.pa-btn.success { background: #22C55E; color: #0F1412; }
.pa-btn.success:hover { background: #16A34A; }
.pa-btn.amber { background: #F59E0B; color: #0F1412; }
.pa-btn.amber:hover { background: #D97706; }

/* ── Tables (matches .cs-table) ────────────────────────────────── */
.pa-table-wrap { overflow-x: auto; }
.pa-table {
    width: 100%; border-collapse: collapse;
    background: #1A1D1C; border-radius: 14px; overflow: hidden;
    min-width: 720px;
}
.pa-table thead th {
    background: #252927; color: #9CA3AF;
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    padding: 14px 16px; text-align: left; white-space: nowrap;
}
.pa-table tbody td {
    padding: 14px 16px; color: #D1D5DB; font-size: 0.875rem;
    border-top: 1px solid #252927; vertical-align: middle;
}
.pa-table tbody tr { transition: background 0.15s; cursor: default; }
.pa-table tbody tr:hover { background: rgba(45, 212, 191, 0.04); }
.pa-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pa-table .clickable { cursor: pointer; }
.pa-table .clickable:hover { color: #2DD4BF; }
.pa-restaurant { color: #FFFFFF; font-weight: 600; }
.pa-muted { color: #6B7280; }
.pa-amount.pos { color: #22C55E; font-weight: 700; }
.pa-amount.neg { color: #EF4444; font-weight: 700; }

/* ── Status badges (matches .cs-table-status / .cs-card-badge) ──── */
.pa-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 10px;
    font-size: 0.75rem; font-weight: 600; text-transform: capitalize;
}
.pa-badge i { font-size: 0.625rem; }
.pa-badge.completed, .pa-badge.paid { background: rgba(34, 197, 94, 0.12); color: #22C55E; }
.pa-badge.pending, .pa-badge.processing { background: rgba(245, 158, 11, 0.12); color: #F59E0B; }
.pa-badge.failed, .pa-badge.cancelled, .pa-badge.reversed, .pa-badge.rejected { background: rgba(239, 68, 68, 0.12); color: #EF4444; }
.pa-badge.refunded { background: rgba(139, 92, 246, 0.12); color: #8B5CF6; }
.pa-badge.default { background: rgba(107, 114, 128, 0.12); color: #9CA3AF; }

/* ── Rank pill ──────────────────────────────────────────────────── */
.pa-rank {
    width: 26px; height: 26px; border-radius: 50%;
    background: rgba(45, 212, 191, 0.12); color: #2DD4BF;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
}
.pa-rank.top { background: #2DD4BF; color: #0F1412; }

/* ── Bars (revenue trend / peak hours) ─────────────────────────── */
.pa-bars { display: flex; flex-direction: column; gap: 10px; }
.pa-bar-row { display: flex; align-items: center; gap: 10px; }
.pa-bar-label { width: 70px; color: #9CA3AF; font-size: 0.75rem; flex-shrink: 0; }
.pa-bar-track { flex: 1; height: 18px; background: #252927; border-radius: 6px; overflow: hidden; }
.pa-bar-fill { height: 100%; background: linear-gradient(90deg, rgba(45, 212, 191, 0.5), #2DD4BF); border-radius: 6px; transition: width 0.4s; }
.pa-bar-value { width: 90px; color: #D1D5DB; font-size: 0.75rem; font-weight: 600; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* ── Best-selling list ─────────────────────────────────────────── */
.pa-dish {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; background: #252927; border-radius: 12px; margin-bottom: 8px;
}
.pa-dish:last-child { margin-bottom: 0; }
.pa-dish-rank {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(45, 212, 191, 0.12); color: #2DD4BF;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.813rem; flex-shrink: 0;
}
.pa-dish-body { flex: 1; min-width: 0; }
.pa-dish-name { color: #FFFFFF; font-size: 0.875rem; font-weight: 600; }
.pa-dish-meta { color: #6B7280; font-size: 0.75rem; margin-top: 2px; }
.pa-dish-rev { color: #2DD4BF; font-weight: 700; font-size: 0.938rem; text-align: right; }

/* ── Panels (matches .cs-calc-form / .cs-calc-result) ──────────── */
.pa-panel {
    background: #1A1D1C; border: 1px solid #2E2E2E;
    border-radius: 16px; padding: 24px;
}
.pa-panel h3 {
    color: #FFFFFF; font-size: 1rem; font-weight: 700; margin: 0 0 1rem;
    display: flex; align-items: center; gap: 0.5rem;
}
.pa-panel h3 i { color: #2DD4BF; font-size: 1.125rem; }

/* ── Wallet quick panels ───────────────────────────────────────── */
.pa-wallet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.pa-kv {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0; border-bottom: 1px solid #252927;
}
.pa-kv:last-child { border-bottom: none; }
.pa-kv .k { color: #9CA3AF; font-size: 0.875rem; }
.pa-kv .v { color: #FFFFFF; font-size: 0.875rem; font-weight: 600; }
.pa-kv .v.pos { color: #22C55E; }
.pa-kv .v.neg { color: #EF4444; }
.pa-actions { display: flex; flex-direction: column; gap: 10px; }
.pa-actions .pa-btn { justify-content: center; width: 100%; }

/* ── Breakdown grid ────────────────────────────────────────────── */
.pa-breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 1.25rem; }
.pa-breakdown:last-child { margin-bottom: 0; }

/* ── Row action buttons (withdrawals) ──────────────────────────── */
.pa-actions-cell { display: flex; gap: 6px; justify-content: flex-end; }
.pa-icon-btn {
    width: 32px; height: 32px; border-radius: 8px; border: none;
    background: rgba(255, 255, 255, 0.04); color: #9CA3AF; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.pa-icon-btn:hover { background: rgba(45, 212, 191, 0.15); color: #2DD4BF; }
.pa-icon-btn.danger:hover { background: rgba(239, 68, 68, 0.15); color: #EF4444; }
.pa-icon-btn.success:hover { background: rgba(34, 197, 94, 0.15); color: #22C55E; }

/* ── Footer / pagination ───────────────────────────────────────── */
.pa-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 1rem; padding: 0 4px;
}
.pa-pages { color: #6B7280; font-size: 0.75rem; }

/* ── Empty / loading (matches .cs-empty) ────────────────────────── */
.pa-empty { text-align: center; padding: 4rem 1rem; color: #6B7280; }
.pa-empty i { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; color: #4B5563; }
.pa-empty p { color: #fff; font-size: 1.063rem; font-weight: 600; margin: 0 0 0.5rem; }
.pa-empty .pa-empty-desc { color: #6B7280; font-size: 0.875rem; font-weight: 400; }
.pa-loading { text-align: center; padding: 3rem 1rem; color: #6B7280; }
.pa-loading i { color: #2DD4BF; font-size: 2rem; margin-bottom: 0.75rem; display: block; }
.pa-loading p { color: #fff; font-size: 1rem; font-weight: 600; margin: 0; }
.pa-muted-inline { color: #6B7280; padding: 12px 0; }

/* ── Header action buttons ──────────────────────────────────────── */
.pa-head-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .pa-wallet-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .pa-head { padding: 1rem; }
    .pa-head-actions { width: 100%; justify-content: flex-end; }
    .pa-tabs { padding: 0 1rem; }
    .pa-body { padding: 1rem; }
    .pa-kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
    .pa-kpis { grid-template-columns: 1fr; }
    .pa-toolbar { flex-direction: column; align-items: stretch; }
    .pa-input, .pa-select { min-width: 0; width: 100%; }
    .pa-breakdown { grid-template-columns: 1fr; }
}

/* ── Print styles ───────────────────────────────────────────────── */
@media print {
    /* Hide interactive chrome */
    .pa-head-actions,
    .pa-tabs,
    .pa-toolbar,
    .pa-load-more,
    .pa-actions,
    .pa-actions-cell,
    .pa-icon-btn,
    .pa-btn,
    .pa-footer { display: none !important; }

    /* White background, black text throughout */
    .pa-page { background: #fff !important; min-height: auto; color: #000; }
    .pa-head { border-bottom: 2px solid #000; padding: 0.5rem 0; background: #fff; }
    .pa-head h1 { color: #000; font-size: 1.25rem; }
    .pa-head h1 i { color: #333; }
    .pa-sub { color: #666; }
    .pa-body { padding: 0; background: #fff; }

    /* KPI cards */
    .pa-kpis { grid-template-columns: repeat(5, 1fr); gap: 8px; }
    .pa-kpi { border: 1px solid #ccc; background: #fff; border-radius: 4px; }
    .pa-kpi-icon { display: none; }
    .pa-kpi-value { color: #000; }
    .pa-kpi-label, .pa-kpi-sub { color: #666; }

    /* Panels */
    .pa-panel { border: 1px solid #ccc; background: #fff; page-break-inside: avoid; border-radius: 4px; }
    .pa-panel h3 { color: #000; }
    .pa-panel h3 i { color: #333; }

    /* Grids */
    .pa-breakdown { grid-template-columns: 1fr 1fr; }
    .pa-wallet-grid { grid-template-columns: 1fr 1fr; }

    /* Tables */
    .pa-table-wrap { overflow: visible; }
    .pa-table { border-collapse: collapse; background: #fff; min-width: 0; }
    .pa-table th { background: #f5f5f5; color: #333; border: 1px solid #ccc; }
    .pa-table td { color: #000; border: 1px solid #ccc; }
    .pa-table .num { color: #000; }
    .pa-table tbody tr:hover { background: transparent; }
    .pa-restaurant { color: #000; }
    .pa-muted { color: #666; }

    /* Key-value pairs */
    .pa-kv { border-bottom: 1px solid #eee; }
    .pa-kv .k { color: #333; }
    .pa-kv .v { color: #000; }
    .pa-kv .pos { color: #16A34A; }
    .pa-kv .neg { color: #DC2626; }

    /* Best-selling dishes */
    .pa-dish { border: 1px solid #ddd; background: #fff; border-radius: 4px; }
    .pa-dish-rank { background: #f5f5f5; color: #333; }
    .pa-dish-name { color: #000; }
    .pa-dish-meta { color: #666; }
    .pa-dish-rev { color: #000; }

    /* Bar charts */
    .pa-bar-row { border-bottom: 1px solid #eee; }
    .pa-bar-label, .pa-bar-value { color: #000; }
    .pa-bar-track { background: #eee; }
    .pa-bar-fill { background: #2DD4BF; }

    /* Badges — make them print-friendly */
    .pa-badge { border: 1px solid #ccc; background: #f9f9f9; color: #333; }
    .pa-badge.completed, .pa-badge.paid { background: #dcfce7; color: #166534; border-color: #86efac; }
    .pa-badge.pending, .pa-badge.processing { background: #fef3c7; color: #92400e; border-color: #fde68a; }
    .pa-badge.failed, .pa-badge.cancelled, .pa-badge.reversed, .pa-badge.rejected { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
    .pa-badge.refunded { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }

    /* Amount colors */
    .pa-amount.pos { color: #16A34A; }
    .pa-amount.neg { color: #DC2626; }

    /* Rank pills */
    .pa-rank { background: #f5f5f5; color: #333; border: 1px solid #ccc; }
    .pa-rank.top { background: #2DD4BF; color: #000; }

    /* Empty/loading states */
    .pa-empty, .pa-loading { display: none; }

    /* Inputs/selects */
    .pa-input, .pa-select { background: #fff; color: #000; border: 1px solid #ccc; }

    /* Reports tab — low stock alert */
    .pa-report-low-stock {
        border: 1px solid rgba(245, 158, 11, 0.3) !important;
        background: rgba(245, 158, 11, 0.05) !important;
    }
    .pa-report-low-stock-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 0;
        font-size: 13px;
        color: #D1D5DB;
    }
    .pa-report-low-stock-item + .pa-report-low-stock-item {
        border-top: 1px solid #2E2E2E;
    }
}