/* Reports page/table helpers.
   Scoped by .reports-sticky-first-col to avoid affecting other tables globally. */

.reports-page .table {
    font-size: 0.82rem;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto !important;
    width: 100%;
    min-width: max-content;
    margin-bottom: 0;
    background-color: transparent;
}

/* Стили заголовков отчета с поддержкой sticky */
.reports-page thead th {
    position: sticky;
    top: 0;
    z-index: 15;
    background-color: #1a1d20 !important;
    color: var(--accent-amber) !important;
    font-family: var(--header);
    font-weight: 600;
    padding: 12px 10px;
    border-bottom: 2px solid var(--accent-amber-border) !important;
    white-space: nowrap;
    box-shadow: 0 2px 2px rgba(0,0,0,0.2);
}

.reports-page tbody td {
    padding: 8px 10px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Базово не даем первой колонке схлопываться во всех отчетных таблицах. */
.reports-page .table th:first-child,
.reports-page .table td:first-child {
    min-width: 220px !important;
    width: 24% !important;
    max-width: none !important;
    white-space: normal;
    overflow-wrap: anywhere;
}

.reports-page tr:hover td {
    background-color: rgba(251, 191, 36, 0.03) !important;
}

/* Bootstrap status rows are light by default; keep report tables dark. */
.reports-page .table tbody tr.table-danger td,
.reports-page .table tbody tr.table-danger th {
    background-color: rgba(220, 53, 69, 0.16) !important;
    color: var(--foreground) !important;
}

.reports-page .table tbody tr.table-warning td,
.reports-page .table tbody tr.table-warning th {
    background-color: rgba(251, 191, 36, 0.16) !important;
    color: var(--foreground) !important;
}

.reports-page .table tbody tr.table-success td,
.reports-page .table tbody tr.table-success th {
    background-color: rgba(25, 135, 84, 0.16) !important;
    color: var(--foreground) !important;
}

.reports-sticky-first-col {
    table-layout: auto;
}

/* закрепляем первую колонку */
.reports-sticky-first-col th:first-child,
.reports-sticky-first-col td:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: #1a1d20 !important;
    box-shadow: 4px 0 8px rgba(0, 0, 0, 0.4);
    vertical-align: middle;

    min-width: clamp(220px, 24vw, 420px) !important;
    max-width: none !important;
    width: auto !important;
    white-space: normal;
    overflow-wrap: anywhere;
}

.reports-sticky-first-col th:first-child {
    white-space: nowrap;
}

table.reports-cashboxes-table {
    table-layout: auto !important;
}

table.reports-cashboxes-table th:first-child,
table.reports-cashboxes-table td:first-child {
    width: 220px !important;
    min-width: 220px !important;
    max-width: 220px !important;
    white-space: nowrap !important;
}

table.reports-cashboxes-table th:not(:first-child),
table.reports-cashboxes-table td:not(:first-child) {
    width: 1% !important;
    white-space: nowrap !important;
}

@media (min-width: 992px) {
    .reports-page .table th:first-child,
    .reports-page .table td:first-child {
        min-width: 240px;
    }

    .reports-sticky-first-col th:first-child,
    .reports-sticky-first-col td:first-child {
        min-width: 360px !important;
    }
}

/* Улучшение скролла только для страницы reports */
.reports-page .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    background: var(--card);
    max-height: 80vh; /* Ограничение высоты для работы sticky header */
}

/* Вспомогательные классы для колонок с числами */
.reports-page .text-numeric {
    text-align: right;
    font-family: var(--money);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Итоговые строки */
.reports-page .report-summary-row td {
    background-color: rgba(255, 255, 255, 0.04) !important;
    font-weight: 700;
    color: var(--foreground);
    border-top: 1px solid var(--accent-amber-border);
    border-bottom: 2px solid var(--accent-amber-border);
}

/* Global pagination theme */
body.dark-theme :is(.pagination, .navigator, .money-pagination__controls, .money-pagination__pages, .news-pagination, .course-pagination, .bank-stock-pagination) {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

body.dark-theme :is(.pagination .page-link, .navigator .btn, .navigator a, .navigator button, .money-pagination__page, .money-pagination__nav, .news-pagination__btn, .course-pagination .page-link, .bank-stock-pagination__button) {
    min-width: 44px !important;
    height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 14px !important;
    border: 1px solid rgba(251, 191, 36, .36) !important;
    border-radius: 10px !important;
    background: rgba(251, 191, 36, .08) !important;
    color: #fbbf24 !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 10px 24px rgba(0, 0, 0, .22) !important;
}

body.dark-theme :is(.pagination .page-link, .navigator .btn, .navigator a, .navigator button, .money-pagination__page, .money-pagination__nav, .news-pagination__btn, .course-pagination .page-link, .bank-stock-pagination__button):is(:hover, :focus) {
    border-color: rgba(251, 191, 36, .78) !important;
    background: rgba(251, 191, 36, .18) !important;
    color: #ffd166 !important;
    outline: none !important;
}

body.dark-theme :is(.pagination .page-item.active .page-link, .navigator .active, .money-pagination__page.is-active) {
    border-color: #fbbf24 !important;
    background: #fbbf24 !important;
    color: #111827 !important;
}

body.dark-theme :is(.pagination .page-item.disabled .page-link, .navigator .disabled, .money-pagination__page.is-disabled, .money-pagination__nav.is-disabled, .news-pagination__btn.is-disabled, .bank-stock-pagination__button.is-disabled) {
    border-color: rgba(148, 163, 184, .24) !important;
    background: rgba(15, 23, 42, .48) !important;
    color: rgba(203, 213, 225, .42) !important;
    box-shadow: none !important;
    cursor: not-allowed !important;
    opacity: 1 !important;
}

body.dark-theme :is(.money-pagination__meta, .news-pagination__meta, .bank-stock-pagination__meta, .navigator > span:not(.btn)) {
    color: #fbbf24 !important;
    font-weight: 700 !important;
}

body:not(.dark-theme) :is(.pagination, .navigator, .money-pagination__controls, .money-pagination__pages, .news-pagination, .course-pagination, .bank-stock-pagination),
html[data-bs-theme="light"] :is(.pagination, .navigator, .money-pagination__controls, .money-pagination__pages, .news-pagination, .course-pagination, .bank-stock-pagination) {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

body:not(.dark-theme) :is(.pagination .page-link, .navigator .btn, .navigator a, .navigator button, .money-pagination__page, .money-pagination__nav, .news-pagination__btn, .course-pagination .page-link, .bank-stock-pagination__button),
html[data-bs-theme="light"] :is(.pagination .page-link, .navigator .btn, .navigator a, .navigator button, .money-pagination__page, .money-pagination__nav, .news-pagination__btn, .course-pagination .page-link, .bank-stock-pagination__button) {
    min-width: 44px !important;
    height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 14px !important;
    border: 1px solid rgba(51, 51, 51, .22) !important;
    border-radius: 10px !important;
    background: transparent !important;
    color: #333333 !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    box-shadow: none !important;
}

body:not(.dark-theme) :is(.pagination .page-link, .navigator .btn, .navigator a, .navigator button, .money-pagination__page, .money-pagination__nav, .news-pagination__btn, .course-pagination .page-link, .bank-stock-pagination__button):is(:hover, :focus),
html[data-bs-theme="light"] :is(.pagination .page-link, .navigator .btn, .navigator a, .navigator button, .money-pagination__page, .money-pagination__nav, .news-pagination__btn, .course-pagination .page-link, .bank-stock-pagination__button):is(:hover, :focus) {
    border-color: rgba(51, 51, 51, .42) !important;
    background: rgba(51, 51, 51, .06) !important;
    color: #333333 !important;
    outline: none !important;
}

body:not(.dark-theme) :is(.pagination .page-item.active .page-link, .navigator .active, .money-pagination__page.is-active),
html[data-bs-theme="light"] :is(.pagination .page-item.active .page-link, .navigator .active, .money-pagination__page.is-active) {
    border-color: rgba(51, 51, 51, .5) !important;
    background: rgba(51, 51, 51, .1) !important;
    color: #333333 !important;
}

body:not(.dark-theme) :is(.pagination .page-item.disabled .page-link, .navigator .disabled, .money-pagination__page.is-disabled, .money-pagination__nav.is-disabled, .news-pagination__btn.is-disabled, .bank-stock-pagination__button.is-disabled),
html[data-bs-theme="light"] :is(.pagination .page-item.disabled .page-link, .navigator .disabled, .money-pagination__page.is-disabled, .money-pagination__nav.is-disabled, .news-pagination__btn.is-disabled, .bank-stock-pagination__button.is-disabled) {
    border-color: rgba(51, 51, 51, .12) !important;
    background: transparent !important;
    color: rgba(51, 51, 51, .45) !important;
    box-shadow: none !important;
    cursor: not-allowed !important;
    opacity: 1 !important;
}

body:not(.dark-theme) :is(.money-pagination__meta, .news-pagination__meta, .bank-stock-pagination__meta, .navigator > span:not(.btn)),
html[data-bs-theme="light"] :is(.money-pagination__meta, .news-pagination__meta, .bank-stock-pagination__meta, .navigator > span:not(.btn)) {
    color: #333333 !important;
    font-weight: 700 !important;
}
