/* design-system.css
   Shared visual language across the platform.
*/

:root {
    --ds-space-1: 0.25rem;
    --ds-space-2: 0.5rem;
    --ds-space-3: 0.75rem;
    --ds-space-4: 1rem;
    --ds-space-5: 1.5rem;
    --ds-space-6: 2rem;
    --ds-content-max: 1660px;
    --ds-page-gutter: clamp(0.65rem, 2vw, 1.25rem);

    /* Bootstrap token bridge */
    --bs-primary: var(--primary-color);
    --bs-success: var(--success-color);
    --bs-danger: var(--danger-color);
    --bs-warning: var(--warning-color);
    --bs-info: var(--info-color);
    --bs-body-font-family: var(--font-family);
    --bs-body-bg: var(--background-color);
    --bs-body-color: var(--text-color);
    --bs-border-radius: var(--border-radius);
    --bs-border-color: var(--border-color);
}

.main-container {
    background: var(--background-color);
}

/* Ensure consistent content width across all pages extending base.html */
.main-container > .container-fluid {
    width: 100%;
    max-width: var(--ds-content-max);
    margin-inline: auto;
    padding-inline: var(--ds-page-gutter);
}

.ds-page {
    width: 100%;
    max-width: var(--ds-content-max);
    margin-inline: auto;
    padding-inline: var(--ds-page-gutter);
}

.ds-card,
.card.ds-card {
    border: 1px solid rgba(var(--primary-color-rgb), 0.08);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-soft);
}

.ds-subcard .card-header,
.card-header.ds-subcard-header {
    background-color: var(--light-color);
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

.ds-subcard .card-header h6,
.card-header.ds-subcard-header h6 {
    color: var(--text-color);
}

.ds-filter-select {
    min-width: 9rem;
}

.ds-filter-select-sm {
    min-width: 6.5rem;
}

.ds-select-auto {
    width: auto;
    min-width: 6rem;
}

.ds-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background-color: #fff;
}

.ds-table th {
    white-space: nowrap;
}

.ds-action-btn {
    white-space: nowrap !important;
    hyphens: none !important;
    flex-shrink: 0;
}

/* Reusable page header layout */
.ds-header {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-3);
}

.ds-header-title h1,
.ds-header-title h2,
.ds-header-title h3 {
    margin: 0;
    line-height: 1.2;
}

.ds-header-subtitle {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.ds-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
    margin-top: var(--ds-space-2);
}

.ds-header-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid rgba(var(--primary-color-rgb), 0.2);
    border-radius: 999px;
    background: #fff;
    color: var(--text-color);
    font-size: 0.88rem;
    line-height: 1;
}

.ds-header-stat strong {
    font-weight: 700;
}

.ds-header-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--ds-space-3);
    align-items: start;
}

.ds-header-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ds-space-2);
    min-width: 0;
}

.ds-filter-search {
    flex: 1 1 320px;
    min-width: 220px;
}

.ds-filter-year {
    width: 120px;
}

.ds-checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.ds-checkbox-inline .form-check-input {
    margin: 0;
}

.ds-checkbox-inline .form-check-label {
    margin: 0;
}

.ds-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
    justify-content: flex-end;
    align-items: center;
}

.ds-table-static-cursor tbody tr,
.ds-table-static-cursor tbody tr:hover {
    cursor: default !important;
}

.dataTables_wrapper .dataTables_scrollBody .ds-table-static-cursor tbody tr:hover {
    cursor: default !important;
    background-color: transparent !important;
}

.ds-table-static-cursor tbody tr a {
    cursor: pointer !important;
}

.ds-dropdown-icon-btn::after {
    margin-left: 0;
}

.ds-dropdown-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ds-dropdown-icon-btn i {
    margin-right: 0;
}

.ds-empty-state {
    padding: 1rem 1.25rem;
    color: var(--text-muted);
}

/* Matrix table */
.ds-matrix-wrap {
    max-height: 72vh;
    background-color: #fff;
}

.ds-matrix-table {
    font-size: 0.85rem;
}

.ds-matrix-table th,
.ds-matrix-table td {
    white-space: nowrap;
    vertical-align: middle;
    text-align: center;
}

.ds-matrix-table .ds-matrix-sticky {
    position: sticky;
    z-index: 2;
    background: #fff;
}

.ds-matrix-table thead .ds-matrix-sticky {
    z-index: 4;
    background: var(--table-header-color);
    color: #fff;
}

.ds-matrix-table .ds-matrix-col-1 {
    left: 0;
    min-width: 120px;
}

.ds-matrix-table .ds-matrix-col-2 {
    left: 120px;
    min-width: 260px;
    text-align: left;
}

.ds-matrix-table .ds-matrix-col-3 {
    left: 380px;
    min-width: 180px;
    text-align: left;
}

.ds-matrix-table .ds-matrix-col-4 {
    left: 560px;
    min-width: 95px;
}

.ds-matrix-table .ds-matrix-activity-col {
    min-width: 150px;
}

.ds-matrix-table tbody tr:hover .ds-matrix-sticky {
    background: var(--table-row-hover);
}

@media (max-width: 576px) {
    .ds-filter-select,
    .ds-filter-select-sm,
    .ds-select-auto {
        min-width: 100%;
        width: 100%;
    }

    .ds-header-actions .ds-action-btn {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .ds-header-filters {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .ds-filter-search {
        min-width: 0;
        width: 100%;
        flex: 1 1 auto;
    }

    .ds-filter-year {
        width: 100%;
    }

    .ds-header-filters > .d-flex {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .ds-header-filters > .d-flex .form-select,
    .ds-header-filters > .d-flex .ds-filter-select,
    .ds-header-filters > .d-flex .ds-filter-select-sm {
        flex: 1 1 220px;
        min-width: 0;
    }
}

@media (max-width: 992px) {
    .ds-header-toolbar {
        grid-template-columns: 1fr;
    }

    .ds-header-meta {
        width: 100%;
    }

    .ds-header-actions {
        justify-content: flex-start;
    }
}
