/**
 * Draws Table - Component styles for the SSR draw list/grid.
 *
 * Used by server-side rendered partials (homepage-draws-render.php,
 * Read_SeqExtractions.tmpl.php, Read_Extractions.tmpl.php, ...).
 * The "dt-" class prefix stands for "draws table" in this context.
 *
 * Optional CSS custom properties (set on .dt-container by callers):
 *   --dt-primary, --dt-secondary, --dt-accent    (theme colors)
 *   --dt-row-even, --dt-row-hover                 (row backgrounds)
 *   --dt-badge-text                               (badge text color)
 *   --dt-badge-size                               (badge width/height in px)
 *   --dt-font-size                                (badge font size in px)
 *   --dt-header-font                              (header date/time font size in px)
 *   --dt-gap                                      (gap between badges in px)
 */

/* ── Container ──────────────────────────────────────────── */
.dt-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    width: 100%;
}

/* ── Title ──────────────────────────────────────────────── */
.dt-title {
    padding: 16px 20px;
    font-size: 1.3em;
    font-weight: 600;
    text-align: center;
    color: #fff;
    background: var(--dt-primary, #0033cc);
}

/* ── Controls bar ───────────────────────────────────────── */
.dt-controls {
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.dt-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
    cursor: pointer;
    color: #334155;
    white-space: nowrap;
}
.dt-controls input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.dt-controls select {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
    cursor: pointer;
}

/* ── Row ────────────────────────────────────────────────── */
.dt-row {
    display: flex;
    flex-wrap: wrap;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    gap: 10px;
    align-items: flex-start;
    transition: background-color 0.15s ease;
}
@media (min-width: 480px) {
    .dt-row {
        gap: 16px;
    }
}
.dt-row:nth-child(odd) { background: #ffffff; }
.dt-row:nth-child(even) { background: var(--dt-row-even, #edf2fc); }
.dt-row:hover { background: var(--dt-row-hover, #d6e6f8); }

/* ── Row header (date/time) ─────────────────────────────── */
.dt-row-header {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-self: stretch;
    padding: 6px;
    border-radius: 8px;
    min-width: 0;
    width: 70px;
    gap: 2px;
    text-align: center;
}
@media (min-width: 480px) {
    .dt-row-header {
        padding: 12px 16px;
        width: auto;
        min-width: 120px;
        gap: 4px;
    }
}
.dt-row-header.colored {
    background: var(--dt-secondary, #2563eb);
    color: #fff;
}
.dt-row-id {
    font-weight: 700;
}
.dt-row-prog {
    opacity: 0.85;
    font-weight: 700;
    line-height: 1.2;
    font-size: calc(var(--dt-header-font, 16px) * 0.85);
}
.dt-row-date,
.dt-row-time {
    opacity: 0.95;
    font-weight: 700;
    line-height: 1.2;
    font-size: var(--dt-header-font, 16px);
}

/* ── Row content ────────────────────────────────────────── */
.dt-row-content {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
    min-width: 0;
}
@media (min-width: 480px) {
    .dt-row-content {
        gap: 16px;
    }
}

/* ── Sections (numbers group with label) ────────────────── */
.dt-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dt-section.main {
    flex: 1;
    min-width: 200px;
}
.dt-section.special {
    flex-shrink: 0;
}
.dt-section.dt-secondary-section {
    flex-basis: 100%;
}
.dt-section-label {
    font-size: 1rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.3px;
    text-transform: capitalize;
}

/* ── Numbers grid ───────────────────────────────────────── */
.dt-numbers-grid {
    display: grid;
    gap: var(--dt-gap, 5px);
}

/* ── Special columns (right side) ───────────────────────── */
.dt-special-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    justify-content: flex-start;
}
.dt-special-right.dt-special-inline {
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
}

/* ── Main column ────────────────────────────────────────── */
.dt-main-column {
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

/* ── Footer ─────────────────────────────────────────────── */
.dt-footer {
    padding: 10px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 1rem;
    color: #64748b;
    display: flex;
    justify-content: space-between;
}

/* ── Empty / Loading states ─────────────────────────────── */
.dt-empty,
.dt-loading {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
    font-size: 1rem;
}
.dt-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top-color: var(--dt-secondary, #2563eb);
    border-radius: 50%;
    animation: dt-spin 0.8s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}
@keyframes dt-spin {
    to { transform: rotate(360deg); }
}

/* ── Plain-text badge (server-side default) ─────────────── */
.dt-badge-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--dt-badge-size, 40px);
    height: var(--dt-badge-size, 40px);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: var(--dt-font-size, 16px);
    font-weight: 700;
    color: var(--dt-badge-text, #ffffff);
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 8px;
    box-shadow: 0 2px 3px rgba(0,0,0,0.15);
}
/* Special section themes (colorKey set by template) — colors match dynamic-table.js SPECIAL_COLORS */
.dt-section.special.special_1 .dt-badge-text {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1e293b;
    box-shadow: 0 2px 3px rgba(245,158,11,0.4);
}
.dt-section.special.special_2 .dt-badge-text {
    background: linear-gradient(135deg, #fb923c, #ea580c);
    color: #ffffff;
    box-shadow: 0 2px 3px rgba(234,88,12,0.4);
}
.dt-section.special.special_3 .dt-badge-text {
    background: linear-gradient(135deg, #ec4899, #db2777);
    color: #ffffff;
    box-shadow: 0 2px 3px rgba(236,72,153,0.4);
}
.dt-section.special.secondary .dt-badge-text,
.dt-section.dt-secondary-section .dt-badge-text {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    box-shadow: 0 2px 3px rgba(16,185,129,0.3);
}
/* Dimmed state (set on container by Read_Extractions.js when ≥1 number selected) */
#extractionsTable.has-selection .dt-badge-text:not(.selected) {
    opacity: 0.25;
}

/* ── SVG badge ──────────────────────────────────────────── */
.dt-badge-svg {
    display: block;
}

/* ── Main numbers grid: flex-wrap so badges wrap before overflowing ── */
.dt-section.main .dt-numbers-grid {
    display: flex;
    flex-wrap: wrap;
}

/* ── Chunked rows (groups of 5 for ≥10-number grids) ────── */
.dt-numbers-rows {
    display: flex;
    flex-wrap: wrap;
    gap: var(--dt-gap, 5px);
}
.dt-numbers-row {
    display: flex;
    flex-shrink: 0;
    gap: var(--dt-gap, 5px);
}

/* ── No-wrap: ≤6 numbers always on a single row ─────────── */
.dt-numbers-grid.dt-grid-nowrap {
    flex-wrap: nowrap;
}

/* ── Single-column layout (<768px) ─────────────────────── */
@media (max-width: 767px) {
    /* Special columns always below main numbers, side by side among themselves */
    .dt-special-right {
        flex-basis: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    /* Grids with ≥10 numbers (multiple of 5): max 5 per row */
    .dt-numbers-grid.dt-grid-wrap5 {
        display: grid;
        grid-template-columns: repeat(5, var(--dt-badge-size, 40px));
    }
}
