/* Diversity Explorer Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    color: #333;
    padding: 30px 20px;
    transition: background 0.3s, color 0.3s;
}

body.dark-theme {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 6px;
}

body.dark-theme header h1 {
    background: linear-gradient(90deg, #4FC3F7, #81D4FA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1rem;
    color: #666;
}

body.dark-theme .subtitle {
    color: #888;
}

/* Selectors */
.selector-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.selector-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selector-group label {
    font-weight: 600;
    font-size: 0.95rem;
    color: #555;
}

body.dark-theme .selector-group label {
    color: #aaa;
}

.selector-group select,
.count-input {
    padding: 8px 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s;
}

.selector-group select {
    min-width: 220px;
}

.count-input {
    width: 100px;
    text-align: center;
}

.selector-group select:focus,
.count-input:focus {
    border-color: #4FC3F7;
    outline: none;
}

body.dark-theme .selector-group select,
body.dark-theme .count-input {
    background: #2a2a3e;
    border-color: #444;
    color: #e0e0e0;
}

.run-btn {
    padding: 8px 20px;
    border: 2px solid #4FC3F7;
    border-radius: 8px;
    background: #4FC3F7;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.run-btn:hover {
    background: #29B6F6;
}

.run-btn:active {
    transform: scale(0.97);
}

body.dark-theme .run-btn {
    background: #1565c0;
    border-color: #1565c0;
}

body.dark-theme .run-btn:hover {
    background: #1976d2;
}

/* Filter row */
.filter-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: #f0f4f8;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

body.dark-theme .filter-row {
    background: #1e1e36;
    border-color: #3a3a55;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group > label:first-child {
    font-weight: 600;
    font-size: 0.88rem;
    color: #555;
    white-space: nowrap;
}

body.dark-theme .filter-group > label:first-child {
    color: #aaa;
}

.dur-input {
    width: 70px;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.88rem;
    text-align: center;
    background: #fff;
    color: #333;
}

body.dark-theme .dur-input {
    background: #2a2a3e;
    border-color: #444;
    color: #e0e0e0;
}

.dur-input:focus {
    border-color: #4FC3F7;
    outline: none;
}

.filter-sep {
    color: #999;
    font-size: 0.9rem;
}

.grade-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.88rem;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
}

body.dark-theme .grade-label {
    color: #bbb;
}

.grade-label input[type="checkbox"] {
    accent-color: #4FC3F7;
    cursor: pointer;
}

/* Diversity slider */
.diversity-slider {
    width: 100px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    vertical-align: middle;
}

body.dark-theme .diversity-slider {
    background: #444;
}

.diversity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4FC3F7;
    cursor: pointer;
}

.diversity-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4FC3F7;
    border: none;
    cursor: pointer;
}

.diversity-val {
    font-weight: 700;
    font-size: 0.9rem;
    color: #2e7d32;
    min-width: 20px;
    text-align: center;
}

body.dark-theme .diversity-val {
    color: #66bb6a;
}

.diversity-unit {
    font-size: 0.82rem;
    color: #888;
}

/* Loading */
.loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #666;
}

body.dark-theme .loading {
    color: #aaa;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #ddd;
    border-top-color: #4FC3F7;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty / Error states */
.dv-empty {
    text-align: center;
    padding: 60px 20px;
    color: #888;
    font-size: 1.1rem;
}

body.dark-theme .dv-empty {
    color: #666;
}

.dv-error {
    text-align: center;
    padding: 20px;
    color: #d32f2f;
    background: #ffebee;
    border-radius: 8px;
    margin: 20px 0;
}

body.dark-theme .dv-error {
    background: #3e1a1a;
    color: #ef9a9a;
}

.dv-error-icon {
    margin-right: 6px;
}

/* Stats bar */
.dv-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: #e3f2fd;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1565c0;
}

body.dark-theme .dv-stats {
    background: #1a2744;
    color: #81d4fa;
}

.dv-stat-sep {
    color: #90caf9;
}

/* Sort row */
.dv-sort-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 16px;
}

.dv-sort-row label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #666;
}

body.dark-theme .dv-sort-row label {
    color: #aaa;
}

.dv-sort-row select {
    padding: 5px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.85rem;
    background: #fff;
    color: #333;
    cursor: pointer;
}

body.dark-theme .dv-sort-row select {
    background: #2a2a3e;
    border-color: #444;
    color: #e0e0e0;
}

/* Export CSV button */
.export-btn {
    margin-left: auto;
    padding: 5px 14px;
    border: 1px solid #4FC3F7;
    border-radius: 6px;
    background: transparent;
    color: #4FC3F7;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.export-btn:hover {
    background: #4FC3F7;
    color: #fff;
}

body.dark-theme .export-btn {
    border-color: #4FC3F7;
    color: #4FC3F7;
}

body.dark-theme .export-btn:hover {
    background: #4FC3F7;
    color: #1a1a2e;
}

/* Select all label in sort row */
.select-all-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: #666;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

body.dark-theme .select-all-label {
    color: #aaa;
}

.select-all-label input[type="checkbox"] {
    accent-color: #4FC3F7;
    cursor: pointer;
}

/* Card checkbox */
.dv-card-check {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    width: 18px;
    height: 18px;
    accent-color: #4FC3F7;
    cursor: pointer;
    opacity: 0.8;
}

.dv-card-check:hover {
    opacity: 1;
}

.dv-card {
    position: relative;
}

/* Unchecked card visual dimming */
.dv-card:has(.dv-card-check:not(:checked)) {
    opacity: 0.5;
}

.dv-card:has(.dv-card-check:not(:checked)):hover {
    opacity: 0.7;
}

/* Segment card grid */
.dv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Segment card */
.dv-card {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    cursor: default;
}

.dv-card:hover {
    border-color: #4FC3F7;
    box-shadow: 0 4px 16px rgba(79, 195, 247, 0.15);
    transform: translateY(-2px);
}

body.dark-theme .dv-card {
    background: #252540;
    border-color: #3a3a55;
}

body.dark-theme .dv-card:hover {
    border-color: #4FC3F7;
    box-shadow: 0 4px 16px rgba(79, 195, 247, 0.1);
}

/* Thumbnail */
.dv-card-thumb {
    width: 100%;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.dark-theme .dv-card-thumb {
    background: #1a1a30;
}

.dv-thumb-img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.dv-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8e8e8;
    color: #999;
    font-size: 0.85rem;
    aspect-ratio: 16 / 9;
    width: 100%;
}

body.dark-theme .dv-thumb-placeholder {
    background: #2a2a40;
    color: #666;
}

/* Lazy thumbnail loading + shimmer animation */
.dv-thumb-lazy {
    width: 100%;
    aspect-ratio: 16 / 9;
    position: relative;
    overflow: hidden;
    background: #e8e8e8;
}

body.dark-theme .dv-thumb-lazy {
    background: #2a2a40;
}

.dv-thumb-loaded {
    width: 100%;
}

.dv-thumb-loaded img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dv-shimmer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

body.dark-theme .dv-shimmer {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.06) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Card body */
.dv-card-body {
    padding: 12px 14px;
}

.dv-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dark-theme .dv-card-title {
    color: #e0e0e0;
}

.dv-card-time {
    font-size: 0.82rem;
    color: #888;
    margin-bottom: 6px;
}

body.dark-theme .dv-card-time {
    color: #777;
}

.dv-card-diversity {
    margin-bottom: 6px;
}

.dv-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #e8f5e9;
    color: #2e7d32;
    cursor: help;
}

body.dark-theme .dv-badge {
    background: #1b3a1b;
    color: #66bb6a;
}

.dv-card-desc {
    font-size: 0.82rem;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

body.dark-theme .dv-card-desc {
    color: #888;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    color: #999;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

body.dark-theme footer {
    border-top-color: #333;
    color: #666;
}

.theme-toggle {
    background: none;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.82rem;
    color: #666;
    transition: border-color 0.2s;
}

.theme-toggle:hover {
    border-color: #4FC3F7;
}

body.dark-theme .theme-toggle {
    border-color: #444;
    color: #888;
}

/* Semantic Query Section */
.query-section {
    margin-top: 24px;
    padding: 16px 20px;
    background: #f0f4f8;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
}

body.dark-theme .query-section {
    background: #1e1e36;
    border-color: #3a3a55;
}

.query-header h3 {
    font-size: 1rem;
    color: #333;
    margin-bottom: 4px;
}

body.dark-theme .query-header h3 {
    color: #e0e0e0;
}

.query-hint {
    font-size: 0.82rem;
    color: #888;
    display: block;
    margin-bottom: 12px;
}

.query-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.query-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    color: #333;
}

body.dark-theme .query-input {
    background: #2a2a3e;
    border-color: #444;
    color: #e0e0e0;
}

.query-input:focus {
    border-color: #4FC3F7;
    outline: none;
}

.query-remove-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #999;
    font-size: 1rem;
    width: 32px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.query-remove-btn:hover {
    color: #d32f2f;
    border-color: #d32f2f;
}

body.dark-theme .query-remove-btn {
    border-color: #444;
    color: #666;
}

body.dark-theme .query-remove-btn:hover {
    color: #ef5350;
    border-color: #ef5350;
}

.query-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.query-image-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.query-image-label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
}

body.dark-theme .query-image-label {
    color: #aaa;
}

.query-image-input {
    font-size: 0.85rem;
    color: inherit;
    max-width: 260px;
}

.query-add-btn {
    background: none;
    border: 1px dashed #aaa;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.85rem;
    color: #666;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.query-add-btn:hover {
    border-color: #4FC3F7;
    color: #4FC3F7;
}

body.dark-theme .query-add-btn {
    border-color: #555;
    color: #888;
}

.query-cutoff-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.query-cutoff-group label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
}

body.dark-theme .query-cutoff-group label {
    color: #aaa;
}

.query-filter-btn {
    padding: 8px 18px;
    border: 2px solid #66bb6a;
    border-radius: 8px;
    background: #66bb6a;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.query-filter-btn:hover {
    background: #4caf50;
}

body.dark-theme .query-filter-btn {
    background: #2e7d32;
    border-color: #2e7d32;
}

.query-reset-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.85rem;
    color: #666;
    cursor: pointer;
}

.query-reset-btn:hover {
    border-color: #4FC3F7;
    color: #4FC3F7;
}

body.dark-theme .query-reset-btn {
    border-color: #444;
    color: #888;
}

/* Timelapse Player Overlay */
.player-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.player-overlay.active {
    display: flex;
}

.player-content {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 20px;
    max-width: 900px;
    width: 90%;
    position: relative;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.player-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #999;
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
}

.player-close:hover {
    color: #fff;
}

.player-screen {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #111;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-screen img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.player-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #aaa;
    background: rgba(0, 0, 0, 0.6);
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0 6px;
    color: #ccc;
    font-size: 0.9rem;
}

.player-controls button {
    background: #4FC3F7;
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.player-controls button:hover {
    background: #29B6F6;
}

#player-counter {
    font-variant-numeric: tabular-nums;
    min-width: 70px;
    text-align: center;
}

.player-speed-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    color: #888;
}

.player-speed-label select {
    background: #2a2a3e;
    border: 1px solid #444;
    border-radius: 4px;
    color: #ccc;
    padding: 2px 6px;
    font-size: 0.82rem;
    cursor: pointer;
}

.player-info {
    margin-left: auto;
    font-size: 0.82rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.player-scrubber {
    padding: 0 2px;
}

.player-scrubber input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.player-scrubber input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4FC3F7;
    cursor: pointer;
}

.player-scrubber input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4FC3F7;
    border: none;
    cursor: pointer;
}

/* Make cards clickable */
.dv-card {
    cursor: pointer;
}

/* Responsive tweaks */
@media (max-width: 768px) {
    .selector-row {
        flex-direction: column;
        gap: 12px;
    }

    .dv-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 12px;
    }

    header h1 {
        font-size: 1.6rem;
    }
}

@media (max-width: 480px) {
    .dv-grid {
        grid-template-columns: 1fr;
    }
}
