/* ============================================================
   Broadcastify Archives — Portal V2 Styles
   Theme-aware via --portalv2-* custom properties
   ============================================================ */

/* --- Archives custom properties (dark defaults) --- */

.archives-body {
    --archives-wave: #5b8a9a;
    --archives-progress: #39d0ff;
    --archives-cursor: #ff4444;
    --archives-timeline-empty: rgba(255, 255, 255, 0.06);
    --archives-timeline-filled: rgba(57, 208, 255, 0.35);
    --archives-timeline-active: #39d0ff;
    --archives-timeline-border: rgba(255, 255, 255, 0.08);
    --archives-row-active: rgba(57, 208, 255, 0.1);
    --archives-player-bg: rgba(0, 0, 0, 0.3);
    --archives-waveform-bg: #000;
}

/* --- Light theme overrides --- */

[data-coreui-theme="light"] .archives-body {
    --archives-wave: #64748b;
    --archives-progress: #3b82f6;
    --archives-cursor: #ef4444;
    --archives-timeline-empty: rgba(0, 0, 0, 0.06);
    --archives-timeline-filled: rgba(37, 99, 235, 0.45);
    --archives-timeline-active: #2563eb;
    --archives-timeline-border: rgba(0, 0, 0, 0.12);
    --archives-row-active: rgba(37, 99, 235, 0.1);
    --archives-player-bg: #f1f5f9;
    --archives-waveform-bg: #1e293b;
}

/* --- Layout --- */

body.archives-body .portalv2-content {
    padding-top: 1rem;
}

.archives-body .portalv2-breadcrumbs {
    margin-bottom: 0;
}

/* --- Hero --- */

.archives-hero {
    padding: 0.5rem 1rem 1.25rem;
    border-bottom: 1px solid var(--portalv2-border-subtle);
}

.archives-hero h1 {
    font-size: 1.375rem;
    margin-bottom: 0.25rem;
}

.archives-hero p {
    margin-bottom: 0;
    color: var(--portalv2-text-secondary);
    font-size: 0.875rem;
}

.archives-tz-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    border-radius: 10px;
    background: var(--portalv2-bg-raised);
    border: 1px solid var(--portalv2-border-subtle);
    color: var(--portalv2-text-muted);
}

.archives-trim-notice {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 6px;
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.25);
    color: var(--portalv2-text-secondary);
}

.archives-trim-notice i {
    margin-right: 0.375rem;
    color: #f97316;
}

/* --- Date Navigation --- */

.archives-date-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
    margin-bottom: 0.5rem;
}

.archives-date-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.625rem;
    border: 1px solid var(--portalv2-border-subtle);
    border-radius: 6px;
    background: var(--portalv2-bg-raised);
    color: var(--portalv2-text);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.archives-date-btn:hover {
    background: var(--portalv2-bg-hover);
    border-color: var(--portalv2-border);
}

.archives-date-today {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.archives-date-picker-wrap {
    flex: 0 0 auto;
}

.archives-date-input {
    width: 10rem;
    height: 2.25rem;
    padding: 0 0.75rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid var(--portalv2-border-subtle);
    border-radius: 6px;
    background: var(--portalv2-bg-raised);
    color: var(--portalv2-text);
    cursor: pointer;
}

.archives-date-input:focus {
    outline: none;
    border-color: var(--portalv2-accent);
}

/* Flatpickr theme-aware overrides */
.archives-body .flatpickr-calendar {
    background: var(--portalv2-bg-raised);
    border: 1px solid var(--portalv2-border);
    box-shadow: var(--portalv2-shadow-card);
    color: var(--portalv2-text);
}

.archives-body .flatpickr-calendar .flatpickr-months,
.archives-body .flatpickr-calendar .flatpickr-month {
    background: var(--portalv2-bg-raised);
    color: var(--portalv2-text);
}

.archives-body .flatpickr-calendar .flatpickr-current-month .flatpickr-monthDropdown-months,
.archives-body .flatpickr-calendar .flatpickr-current-month input.cur-year {
    color: var(--portalv2-text);
    background: transparent;
}

.archives-body .flatpickr-calendar .flatpickr-current-month .flatpickr-monthDropdown-months option {
    background: var(--portalv2-bg-raised);
    color: var(--portalv2-text);
}

.archives-body .flatpickr-calendar .flatpickr-weekdays {
    background: var(--portalv2-bg-raised);
}

.archives-body .flatpickr-calendar span.flatpickr-weekday {
    color: var(--portalv2-text-muted);
    background: transparent;
}

.archives-body .flatpickr-calendar .flatpickr-day {
    color: var(--portalv2-text);
    border-color: transparent;
}

.archives-body .flatpickr-calendar .flatpickr-day:hover {
    background: var(--portalv2-bg-hover);
    border-color: var(--portalv2-border);
}

.archives-body .flatpickr-calendar .flatpickr-day.today {
    border-color: var(--portalv2-accent);
}

.archives-body .flatpickr-calendar .flatpickr-day.selected {
    background: var(--portalv2-accent);
    border-color: var(--portalv2-accent);
    color: #fff;
}

.archives-body .flatpickr-calendar .flatpickr-day.flatpickr-disabled,
.archives-body .flatpickr-calendar .flatpickr-day.prevMonthDay,
.archives-body .flatpickr-calendar .flatpickr-day.nextMonthDay {
    color: var(--portalv2-text-muted);
    opacity: 0.4;
}

.archives-body .flatpickr-calendar .flatpickr-months .flatpickr-prev-month,
.archives-body .flatpickr-calendar .flatpickr-months .flatpickr-next-month {
    color: var(--portalv2-text);
    fill: var(--portalv2-text);
}

.archives-body .flatpickr-calendar .flatpickr-months .flatpickr-prev-month:hover,
.archives-body .flatpickr-calendar .flatpickr-months .flatpickr-next-month:hover {
    color: var(--portalv2-accent);
    fill: var(--portalv2-accent);
}

.archives-body .flatpickr-calendar .flatpickr-months .flatpickr-prev-month svg,
.archives-body .flatpickr-calendar .flatpickr-months .flatpickr-next-month svg {
    fill: currentColor;
}

/* --- 24-Hour Timeline --- */

.archives-timeline-wrap {
    margin-bottom: 1rem;
}

.archives-timeline {
    display: flex;
    height: 2rem;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--archives-timeline-border);
    background: var(--portalv2-bg-deep);
}

.archives-timeline-slot {
    flex: 1;
    border-right: 1px solid var(--archives-timeline-border);
    background: var(--archives-timeline-empty);
    cursor: default;
    transition: background 0.15s;
    position: relative;
}

.archives-timeline-slot:last-child {
    border-right: none;
}

.archives-timeline-slot.has-archive {
    background: var(--archives-timeline-filled);
    cursor: pointer;
}

.archives-timeline-slot.has-archive:hover {
    background: var(--archives-timeline-active);
    opacity: 0.7;
}

.archives-timeline-slot.active {
    background: var(--archives-timeline-active) !important;
    opacity: 1;
}

.archives-timeline-labels {
    display: flex;
    justify-content: space-between;
    padding: 0.125rem 0;
    font-size: 0.625rem;
    color: var(--portalv2-text-muted);
    letter-spacing: 0.02em;
}

/* --- Archive Table --- */

@media (min-width: 992px) {
    .archives-table-panel {
        max-width: 60%;
        margin-left: auto;
        margin-right: auto;
    }
}

.archives-table {
    margin-bottom: 0;
}

.archives-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

.archives-table tbody tr:hover {
    background: var(--portalv2-bg-hover);
}

.archives-table tbody tr.active {
    background: var(--archives-row-active);
}

.archives-table tbody tr.active td {
    font-weight: 600;
}

.archives-table td {
    font-variant-numeric: tabular-nums;
    font-size: 0.875rem;
    vertical-align: middle;
}

.archives-table .archives-dl-btn {
    color: var(--portalv2-text-muted);
    font-size: 0.875rem;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.archives-table .archives-dl-btn:hover {
    opacity: 1;
    color: var(--portalv2-accent);
}

.archives-loading-row td {
    cursor: default !important;
}

.archives-empty-row td {
    cursor: default !important;
    font-style: italic;
}

/* --- Player Panel --- */

.archives-player-panel {
    margin-top: 1rem;
}

.archives-player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    background: var(--portalv2-bg-raised);
    border-bottom: 1px solid var(--portalv2-border-subtle);
}

.archives-player-now-playing {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--portalv2-text-secondary);
}

.archives-player-now-playing i {
    color: var(--archives-progress);
    font-size: 0.75rem;
}

.archives-action-btn {
    color: var(--portalv2-text-muted);
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    text-decoration: none;
    transition: color 0.15s;
}

.archives-action-btn:hover {
    color: var(--portalv2-text);
}

/* --- Waveform --- */

.archives-player-body {
    padding: 1rem;
}

.archives-waveform-wrap {
    position: relative;
    background: var(--archives-waveform-bg);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    min-height: 100px;
}

.archives-waveform-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
    color: #fff;
    font-size: 0.8125rem;
    z-index: 10;
    pointer-events: none;
}

.archives-waveform-loading.hidden {
    display: none;
}

/* --- Transport Controls --- */

.archives-player-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.archives-transport {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.archives-transport-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--portalv2-border-subtle);
    border-radius: 50%;
    background: var(--portalv2-bg-raised);
    color: var(--portalv2-text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.archives-transport-btn:hover {
    background: var(--portalv2-bg-hover);
    border-color: var(--portalv2-border);
}

.archives-play-btn {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1rem;
    background: var(--archives-progress);
    border-color: var(--archives-progress);
    color: #000;
}

.archives-play-btn:hover {
    opacity: 0.85;
    background: var(--archives-progress);
    border-color: var(--archives-progress);
}

.archives-time-display {
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    color: var(--portalv2-text-secondary);
    min-width: 7rem;
}

/* --- Sliders --- */

.archives-sliders {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.archives-slider-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.archives-slider-group label {
    margin-bottom: 0;
    font-size: 0.75rem;
    color: var(--portalv2-text-muted);
}

.archives-slider {
    width: 5rem;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--portalv2-border-subtle);
    border-radius: 2px;
    outline: none;
}

.archives-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--archives-progress);
    cursor: pointer;
}

.archives-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--archives-progress);
    cursor: pointer;
    border: none;
}

/* --- Autoplay --- */

.archives-autoplay-wrap {
    margin-left: auto;
}

.archives-autoplay-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--portalv2-text-secondary);
    cursor: pointer;
    margin-bottom: 0;
    user-select: none;
}

.archives-autoplay-label input[type="checkbox"] {
    accent-color: var(--archives-progress);
}

/* --- Premium Gate --- */

.archives-premium-gate {
    margin-top: 1rem;
}

.archives-premium-gate .portal-panel-body {
    background: var(--portalv2-bg-raised);
}

/* --- Landing Page --- */

.archives-landing-hero {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--portalv2-border-subtle);
    text-align: center;
}

.archives-landing-hero h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.archives-landing-hero p {
    color: var(--portalv2-text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 0;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.archives-landing-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.75rem;
    padding: 0.375rem 1rem;
    font-size: 0.8125rem;
    border-radius: 20px;
    background: var(--portalv2-bg-raised);
    border: 1px solid var(--portalv2-border-subtle);
    color: var(--portalv2-text-secondary);
}

/* --- YouTube Video Cards --- */

.archives-yt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.archives-yt-card {
    display: block;
    text-decoration: none;
    color: var(--portalv2-text);
    border-radius: 8px;
    overflow: hidden;
    background: var(--portalv2-bg-raised);
    border: 1px solid var(--portalv2-border-subtle);
    transition: border-color 0.15s, transform 0.15s;
}

.archives-yt-card:hover {
    border-color: var(--portalv2-border);
    transform: translateY(-2px);
    color: var(--portalv2-text);
    text-decoration: none;
}

.archives-yt-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.archives-yt-info {
    padding: 0.625rem 0.75rem;
}

.archives-yt-title {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.archives-yt-date {
    font-size: 0.6875rem;
    color: var(--portalv2-text-muted);
    margin-top: 0.25rem;
}

/* --- Top Downloads Table --- */

.archives-top-table td {
    font-size: 0.8125rem;
    vertical-align: middle;
}

.archives-top-table .archives-top-rank {
    font-weight: 700;
    color: var(--portalv2-text-muted);
    width: 2rem;
    text-align: center;
}

.archives-top-table .archives-top-plays {
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: var(--portalv2-text-secondary);
}

/* --- Notable Archives --- */

.archives-notable-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.archives-notable-list li {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--portalv2-border-subtle);
    font-size: 0.875rem;
}

.archives-notable-list li:last-child {
    border-bottom: none;
}

.archives-notable-date {
    display: inline-block;
    min-width: 5.5rem;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--portalv2-text-muted);
    font-variant-numeric: tabular-nums;
}

/* --- Responsive --- */

@media (max-width: 767px) {
    .archives-player-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .archives-sliders {
        width: 100%;
    }

    .archives-slider {
        flex: 1;
    }

    .archives-autoplay-wrap {
        margin-left: 0;
    }

    .archives-date-nav {
        flex-wrap: wrap;
    }

    .archives-time-display {
        order: -1;
        width: 100%;
        text-align: center;
        margin-bottom: 0.25rem;
    }
}

@media (max-width: 575px) {
    .archives-yt-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.75rem;
        padding: 0.75rem;
    }
}
