/* Shared styling for the statistics modal (statisticsModal.js) and the
   full-page overview (statisticsOverviewPage.js). */

/* layout.css declares `.center-btn { display: flex; }` after `.hidden { display: none; }`,
   so on an element carrying both classes the later same-specificity rule wins and it stays
   visible — `.hidden` alone does nothing there. Force it with a more specific selector so the
   database table's per-platform statistics-preview button actually hides/shows correctly. */
#sample-statistics-preview-wrap.hidden {
    display: none;
}

.control-input.region-tab-btn {
    width: auto !important;
    flex: 0 0 auto !important;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}

.control-input.active-plot-btn {
    background-color: #6366f1 !important;
    color: white !important;
    border-color: #4f46e5 !important;
}

.stats-overview-page {
    width: 1400px;
    max-width: 95vw;
    margin: 90px auto 40px auto;
    padding: 24px 32px 40px 32px;
    background: #f3f4f6;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.stats-overview-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.stats-overview-title {
    font-size: 1.5em;
    font-weight: 600;
    color: #0b0b0b;
}

.stats-overview-summary {
    font-size: 14px;
    color: #52514e;
    margin-bottom: 18px;
}

.stats-overview-empty {
    color: #898781;
    font-size: 14px;
    padding: 40px 0;
    text-align: center;
}

.stats-overview-species {
    margin-bottom: 14px;
}

.stats-overview-filters {
    display: flex;
    gap: 14px;
    margin-bottom: 14px;
}

.stats-overview-filters label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #52514e;
    margin: 0;
}

.stats-overview-filters select {
    min-width: 200px;
}

.stats-overview-tabs {
    margin-bottom: 18px;
}

.stats-overview-tab-group {
    margin-bottom: 10px;
}

.stats-overview-tab-group-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #898781;
    margin-bottom: 6px;
}

.stats-overview-tab-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.stats-overview-tab-count {
    font-weight: 400;
    opacity: 0.75;
}

.stats-overview-compare {
    margin-bottom: 18px;
}

.stats-overview-compare-form {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 10px;
    padding: 12px;
    background: #fff;
    border: 1px solid #e1e0d9;
    border-radius: 8px;
}

.stats-overview-compare-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #52514e;
    margin: 0;
}

/* ===== Statistics modal (also used as the base .custom-modal style if no
   other modal has been opened yet on this page) ===== */
.custom-modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 11, 11, 0.35);
    z-index: 9999;
    display: none;
}

.custom-modal .modal-content {
    background: #fcfcfb;
    border-radius: 10px;
    margin: 40px auto;
    padding: 20px 24px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #0b0b0b;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    line-height: 1;
    cursor: pointer;
    color: #52514e;
}

.modal-close:hover {
    color: #0b0b0b;
}

.custom-modal .stats-modal-content {
    width: 98vw;
    max-width: none;
    max-height: 96vh;
    overflow-y: auto;
    margin: 2vh auto;
    padding: 16px 20px;
}

.stats-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stats-compare-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #52514e;
    cursor: pointer;
    user-select: none;
}

.stats-compare-columns {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.stats-compare-col {
    flex: 1 1 0;
    min-width: 0;
    border-right: 1px solid #e1e0d9;
    padding-right: 24px;
}

.stats-compare-col:last-child {
    border-right: none;
    padding-right: 0;
}

.stats-compare-col-title {
    font-size: 15px;
    font-weight: 600;
    color: #0b0b0b;
    font-family: monospace;
    margin-bottom: 6px;
}

.stats-modal-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    padding: 10px 2px 14px 2px;
    border-bottom: 1px solid #e1e0d9;
    margin-bottom: 14px;
    font-size: 14px;
    color: #52514e;
}

.stats-header-id {
    font-weight: 600;
    font-size: 16px;
    color: #0b0b0b;
    font-family: monospace;
}

.stats-header-sep {
    color: #898781;
}

.stats-header-key {
    color: #898781;
    margin-right: 4px;
}

.stats-tile-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-tile {
    background: #fff;
    border: 1px solid #e1e0d9;
    border-radius: 8px;
    padding: 12px 14px;
}

.stat-tile-label {
    font-size: 12px;
    color: #898781;
    margin-bottom: 4px;
}

.stat-tile-value {
    font-size: 24px;
    font-weight: 600;
    color: #0b0b0b;
    line-height: 1.1;
}

.stat-tile-delta {
    font-size: 12px;
    color: #52514e;
    margin-top: 4px;
}

.stats-section {
    margin-bottom: 24px;
}

.stats-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #0b0b0b;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e1e0d9;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
}

/* Same space-between issue as .stat-plot-tile-header: title text + buttons are all flex
   siblings, so space-between would spread the buttons apart from each other too. Push just the
   first button (and everything after it, via the 5px gap) to the right instead. */
.stats-section-title .stat-download-btn:first-of-type {
    margin-left: auto;
}

.stats-flex-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    /* Each slot below carries its own explicit width/height (matching the
       size the same plot type uses elsewhere in the app) rather than being
       stretched to fill a uniform grid cell — that mismatch (a legend or a
       large heatmap squeezed into a small fixed-height cell) was what made
       plots overlap/clip. */
    overflow-x: auto;
}

.stat-plot-slot {
    background: #fff;
    border: 1px solid #e1e0d9;
    border-radius: 8px;
    padding: 10px 12px 12px 12px;
}

.stats-composition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
}

.stat-plot-slot-heatmap {
    background: #fff;
    border: 1px solid #e1e0d9;
    border-radius: 8px;
    padding: 10px 12px 12px 12px;
    overflow: auto;
}

.stat-plot-tile-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 6px;
    gap: 5px;
}

.stat-plot-tile-title {
    font-size: 13px;
    font-weight: 600;
    color: #0b0b0b;
    white-space: nowrap;
}

/* space-between used to spread the title AND every download button apart evenly (since they're
   all flex siblings) — a huge gap between buttons that should sit right next to each other.
   Instead: flex-start + push only the first element after the title to the right with auto
   margin: title stays left, everything after it (the buttons) clusters together at the
   container's 5px gap, pushed as a group to the right edge. */
.stat-plot-tile-title + * {
    margin-left: auto;
}

.stats-toggle-group {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.stat-download-btn {
    border: 1px solid #e1e0d9;
    background: #fcfcfb;
    color: #52514e;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
}

.stat-download-btn:hover {
    background: #f0efec;
    color: #0b0b0b;
}

.stat-plot-error {
    color: #898781;
    font-size: 12px;
    padding: 20px 0;
    text-align: center;
}

.stats-preview-card {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
    background: #fff;
    border: 1px solid #e1e0d9;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}

.stats-preview-image-wrap {
    flex: 0 1 420px;
    min-width: 160px;
    max-width: 420px;
    background: #f4f3ef;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.stats-preview-image {
    width: 100%;
    height: auto;
    display: block;
}

.stats-preview-table-cols {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* Same field styling as #info-table on the sample page (layout.css), minus the borders. */
.stats-preview-table {
    flex: 1 1 260px;
    min-width: 0;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: small;
}

.stats-preview-table td {
    border: none;
    padding: 8px;
    vertical-align: top;
    word-break: break-word;
}

.stats-preview-table td:first-child {
    width: 40%;
    white-space: nowrap;
}

.stats-markers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.stats-markers-table th,
.stats-markers-table td {
    text-align: left;
    padding: 4px 8px;
    border-bottom: 1px solid #e1e0d9;
}

.stats-markers-table th {
    color: #898781;
    font-weight: 600;
}

.stats-markers-cluster {
    font-weight: 600;
    color: #0b0b0b;
}
