/**
 * DynamicTable - Component styles
 *
 * CSS for the DynamicTable JS component (www/js/dynamic-table.js).
 * Dynamic values (badge size, grid columns, etc.) are set via
 * CSS custom properties on .dt-container at runtime.
 *
 * Custom properties set by JS:
 *   --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-extra-group {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.25rem 0.5rem;
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px dashed var(--gray-300, #d1d5db);
}
.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;
    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 (showBadges=false) ────────────────── */
.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: 'SF Mono', Consolas, monospace;
    font-size: var(--dt-font-size, 16px);
    font-weight: 700;
}

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