  /* ==========================================================================
   CSV-to-Table Pro (csv-to-php-pro.css)
   ========================================================================== */

.sr-only,
.csvt-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* ==========================================================================
   LEGACY: AutoTable-* sort headers
   ========================================================================== */

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable .sort-symbol {
    display: inline-block;
    width: 1.2em;
    text-align: center;
    font-size: 0.85em;
    margin-left: 0.25em;
    vertical-align: middle;
}

th.sortable[aria-sort="none"] .sort-symbol::after,
th.sortable:not([aria-sort]) .sort-symbol::after { content: "\21C5"; }
th.sortable[aria-sort="ascending"] .sort-symbol::after { content: "\25B2"; }
th.sortable[aria-sort="descending"] .sort-symbol::after { content: "\25BC"; }

th.sortable:focus-visible {
    outline: 3px solid #FFA500;
    outline-offset: -3px;
}

/* Legacy striping via JS-applied classes (replaces inline styles) */
.csvt-stripe-even td { background-color: #d6e0ec; }
.csvt-stripe-odd td { background-color: #f9f9f9; }
/* Hover overrides striping */
.csvt-stripe-even:hover td,
.csvt-stripe-odd:hover td { background-color: #cdd8e8; }

/* Legacy clear-search */
button[id^="clearSearch"] {
    color: #fff;
    background: #036;
    border: none;
    font-size: 0.8em;
    padding: 0 10px;
    line-height: 1.8em;
    cursor: pointer;
    border-radius: 3px;
}
button[id^="clearSearch"]:hover { background: #024; }
button[id^="clearSearch"]:focus-visible {
    outline: 3px solid #FFA500;
    outline-offset: 2px;
}

/* ==========================================================================
   V2: csvt-* component
   ========================================================================== */

.csv-table-component { margin-bottom: 2rem; }

/* Controls */
.csvt-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid #ccc;
    border-radius: 0.5rem;
    padding: 1rem;
    background: #fafafa;
}

.csvt-controls label {
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.95em;
    color: #1C1C1C;
}

.csvt-controls select,
.csvt-controls input[type="search"] {
    width: 100%;
    padding: 0.45rem 0.5rem;
    font-size: 1rem;
    border: 1px solid #767676;
    border-radius: 4px;
    background: #fff;
    color: #1C1C1C;
    margin: 0;
}

.csvt-controls select:focus-visible,
.csvt-controls input[type="search"]:focus-visible {
    outline: 3px solid #005a9c;
    outline-offset: 2px;
}

/* Scrollable wrapper */
.csvt-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.csvt-table-wrap:focus-visible {
    outline: 3px solid #005a9c;
    outline-offset: 2px;
}

/* Table */
.csv-table-component table {
    width: 100%;
    border-collapse: collapse;
}

/* Sort headers — allow wrapping on narrow viewports */
.csv-table-component thead th {
    cursor: pointer;
    user-select: none;
}

.csv-table-component thead th .csvt-sort-icon {
    display: inline-block;
    width: 1em;
    margin-left: 0.3em;
    opacity: 0.6;
    font-size: 0.85em;
    vertical-align: middle;
}

.csv-table-component thead th[aria-sort="ascending"] .csvt-sort-icon::after { content: "\25B2"; opacity: 1; }
.csv-table-component thead th[aria-sort="descending"] .csvt-sort-icon::after { content: "\25BC"; opacity: 1; }
.csv-table-component thead th:not([aria-sort]) .csvt-sort-icon::after,
.csv-table-component thead th[aria-sort="none"] .csvt-sort-icon::after { content: "\21C5"; }

.csv-table-component thead th:focus-visible {
    outline: 3px solid #FFA500;
    outline-offset: -3px;
}

/* Details header — not sortable, no pointer */
.csvt-detail-th {
    cursor: default !important;
    user-select: auto !important;
}

/* Body hover — uses outline instead of background to not fight striping */
.csv-table-component tbody tr:hover td {
    background-color: #eef4fb;
}

/* No results */
.csvt-no-results {
    text-align: center;
    padding: 2rem 1rem;
    font-style: italic;
    color: #555;
}

/* Detail button */
.csvt-detail-btn {
    white-space: nowrap;
    padding: 0.3rem 0.6rem;
    font-size: 0.9em;
    cursor: pointer;
    background: #036;
    color: #fff;
    border: 2px solid #036;
    border-radius: 4px;
    line-height: 1.4;
    transition: background-color 0.15s, border-color 0.15s;
}

.csvt-detail-btn:hover {
    background: #024;
    border-color: #024;
}

.csvt-detail-btn:focus-visible {
    outline: 3px solid #FFA500;
    outline-offset: 2px;
}

/* Pagination */
.csvt-pagination {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.csvt-pagination button {
    padding: 0.4rem 0.75rem;
    font-size: 0.95rem;
    cursor: pointer;
    border: 1px solid #767676;
    border-radius: 4px;
    background: #fff;
    color: #1C1C1C;
    transition: background-color 0.15s;
}

.csvt-pagination button:hover:not(:disabled) { background: #eee; }
.csvt-pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

.csvt-pagination button:focus-visible {
    outline: 3px solid #005a9c;
    outline-offset: 2px;
}

/* ==========================================================================
   DIALOG
   ========================================================================== */

.csv-table-component dialog {
    width: min(900px, 96vw);
    max-height: 90vh;
    border: 1px solid #777;
    border-radius: 10px;
    padding: 0;
}

.csv-table-component dialog[open] {
    display: flex;
    flex-direction: column;
}

.csv-table-component dialog::backdrop { background: rgba(0,0,0,0.55); }

.csvt-dlg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #ddd;
    background: #f7f7f7;
    border-radius: 10px 10px 0 0;
    flex-shrink: 0;
}

.csvt-dlg-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    padding: 0;
}

.csvt-dlg-header button,
.csvt-dlg-footer button {
    padding: 0.35rem 0.7rem;
    font-size: 1rem;
    cursor: pointer;
    border: 1px solid #767676;
    border-radius: 4px;
    background: #fff;
    color: #1C1C1C;
    transition: background-color 0.15s;
}

.csvt-dlg-header button:hover,
.csvt-dlg-footer button:hover { background: #eee; }

.csvt-dlg-header button:focus-visible,
.csvt-dlg-footer button:focus-visible {
    outline: 3px solid #005a9c;
    outline-offset: 2px;
}

.csvt-dlg-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.csvt-dlg-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #ddd;
    background: #f7f7f7;
    display: flex;
    justify-content: flex-end;
    border-radius: 0 0 10px 10px;
    flex-shrink: 0;
}

/* Key-value pairs */
dl.csvt-kv {
    display: grid;
    grid-template-columns: minmax(120px, auto) 1fr;
    gap: 0.4rem 0.75rem;
    margin: 0;
    padding: 0;
}

dl.csvt-kv dt {
    font-weight: 700;
    margin: 0;
    padding: 0.25rem 0;
    color: #1C1C1C;
}

dl.csvt-kv dd {
    margin: 0;
    padding: 0.25rem 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #1C1C1C;
}

dl.csvt-kv dd a { word-break: break-all; }

/* Images in table cells — compact indicator */
.csvt-img-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    font-size: 0.9em;
    color: #555;
    white-space: nowrap;
}

/* Images in detail dialog */
.csvt-img-divider {
    border: none;
    border-top: 1px solid #ddd;
    margin: 1rem 0;
}

.csvt-img-section {
    margin-bottom: 1rem;
}

.csvt-img-section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    padding: 0;
    color: #1C1C1C;
}

.csvt-images {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.csvt-img-figure {
    margin: 0;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    max-width: 400px;
    background: #fafafa;
}

.csvt-img-figure img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    background: #f0f0f0;
}

.csvt-img-figure figcaption {
    padding: 0.5rem 0.75rem;
    font-size: 0.9em;
    line-height: 1.4;
    color: #1C1C1C;
}

.csvt-img-figure figcaption a {
    font-weight: 600;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media screen and (max-width: 992px) {
    .table td { overflow-wrap: anywhere; }
}

@media (max-width: 640px) {
    .csvt-controls { grid-template-columns: 1fr; }
    dl.csvt-kv { grid-template-columns: 1fr; }
    .csvt-pagination {
        flex-direction: column;
        align-items: stretch;
    }
    .csvt-pagination button { width: 100%; }
    .csv-table-component dialog {
        width: 98vw;
        border-radius: 8px;
    }
    .csvt-dlg-header { border-radius: 8px 8px 0 0; }
    .csvt-dlg-footer { border-radius: 0 0 8px 8px; }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .csvt-detail-btn,
    .csvt-pagination button,
    .csvt-dlg-header button,
    .csvt-dlg-footer button {
        transition: none;
    }
}

/* ==========================================================================
   PRINT
   ========================================================================== */

@media print {
    .csvt-controls,
    .csvt-pagination,
    .csvt-detail-btn,
    .csvt-detail-th,
    .csv-table-component dialog {
        display: none !important;
    }

    .csvt-table-wrap {
        overflow: visible;
    }

    .csv-table-component table {
        width: 100%;
        page-break-inside: auto;
    }

    .csv-table-component tr {
        page-break-inside: avoid;
    }

    .csv-table-component thead {
        display: table-header-group;
    }

    .csv-table-component thead th {
        cursor: default;
        user-select: auto;
    }

    .csvt-sort-icon { display: none !important; }

    /* Show all rows when printing */
    .csv-table-component tbody tr {
        display: table-row !important;
    }
}