/**
 * episodeRatings.css - Episode Ratings Visualization Styles
 */

/* ========================================
   Tab Navigation
   ======================================== */
.er-tabs {
    max-width: 400px;
}

/* ========================================
   Overview Tab
   ======================================== */
.er-overview-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.er-episode-count {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--mv-text-primary);
}

.er-show-scores {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Chart container */
.er-chart-container {
    position: relative;
    height: 280px;
    margin-bottom: 24px;
    background: var(--mv-bg-card);
    border: 1px solid var(--mv-border-color);
    border-radius: 8px;
    padding: 16px;
}

/* Highlight cards (highest/lowest episode/season) */
.er-highlight-section {
    margin-bottom: 20px;
}

.er-highlight-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--mv-text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.er-highlight-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--mv-bg-card);
    border: 1px solid var(--mv-border-color);
    border-radius: 8px;
}

.er-highlight-thumb {
    width: 80px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.er-highlight-info {
    flex: 1;
    min-width: 0;
}

.er-highlight-ep-code {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--mv-text-muted);
    text-transform: uppercase;
}

.er-highlight-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--mv-text-primary);
    margin-bottom: 2px;
}

.er-highlight-meta {
    font-size: 0.75rem;
    color: var(--mv-text-secondary);
    margin-bottom: 4px;
}

.er-highlight-scores {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* Season highlight card (no thumbnail) */
.er-season-highlight-card {
    padding: 12px;
    background: var(--mv-bg-card);
    border: 1px solid var(--mv-border-color);
    border-radius: 8px;
}

.er-season-highlight-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--mv-text-primary);
    margin-bottom: 2px;
}

.er-season-highlight-meta {
    font-size: 0.75rem;
    color: var(--mv-text-secondary);
}

/* ========================================
   Highlights Row (4-col on desktop)
   ======================================== */
.er-highlights-row {
    display: flex;
    flex-direction: column;
}

.er-highlights-col .er-highlight-section {
    margin-bottom: 16px;
}

@media (min-width: 768px) {
    .er-highlights-row {
        flex-direction: row;
        gap: 16px;
    }

    .er-highlights-col {
        flex: 1;
        min-width: 0;
    }

    .er-highlights-col .er-highlight-section {
        margin-bottom: 0;
    }
}

/* ========================================
   Episode Ratings Grid (Heatmap)
   ======================================== */
.er-grid-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
}

.er-grid {
    display: grid;
    gap: 3px;
    min-width: fit-content;
}

/* Row/Column header cells */
.er-grid-header {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--mv-text-secondary);
    padding: 4px 8px;
    min-width: 70px;
}

.er-grid-row-header {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--mv-text-muted);
    min-width: 40px;
    padding: 4px;
}

/* Rating cell */
.er-grid-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    min-height: 52px;
    border-radius: 4px;
    padding: 4px 6px;
    cursor: default;
    transition: transform 0.1s ease;
}

.er-grid-cell:hover {
    transform: scale(1.08);
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.er-grid-cell-empty {
    min-width: 70px;
    min-height: 52px;
}

.er-cell-rating {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
}

.er-cell-votes {
    font-size: 0.55rem;
    opacity: 0.8;
    line-height: 1.1;
}

/* AVG row styling */
.er-grid-cell.er-avg-cell {
    min-height: 52px;
    border: 2px solid rgba(255,255,255,0.2);
}

/* Heatmap color scale */
.er-color-9   { background-color: #1b7a1b; color: #fff; }
.er-color-8-5 { background-color: #2d8e2d; color: #fff; }
.er-color-8   { background-color: #4ea84e; color: #fff; }
.er-color-7-5 { background-color: #7bbf3e; color: #fff; }
.er-color-7   { background-color: #b8c225; color: #000; }
.er-color-6-5 { background-color: #d4c524; color: #000; }
.er-color-6   { background-color: #e8b820; color: #000; }
.er-color-5-5 { background-color: #e89820; color: #000; }
.er-color-5   { background-color: #e07020; color: #fff; }
.er-color-4-5 { background-color: #d44e20; color: #fff; }
.er-color-4   { background-color: #c43020; color: #fff; }
.er-color-low { background-color: #a01818; color: #fff; }

/* Grid legend */
.er-grid-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 12px;
    font-size: 0.7rem;
    color: var(--mv-text-muted);
}

.er-legend-swatch {
    width: 16px;
    height: 12px;
    border-radius: 2px;
}

/* ========================================
   Desktop: no tabs, show everything
   ======================================== */
@media (min-width: 768px) {
    /* Override Bootstrap tab-pane hiding so both panels show */
    #erTabContent > .tab-pane {
        display: block !important;
        opacity: 1 !important;
    }

    /* Add spacing between overview and grid on desktop */
    #er-episodes-panel {
        margin-top: 24px;
    }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 576px) {
    .er-grid-cell {
        min-width: 44px;
        min-height: 36px;
        padding: 2px 3px;
        border-radius: 3px;
    }

    .er-grid-cell.er-avg-cell {
        min-height: 36px;
    }

    .er-grid-cell-empty {
        min-width: 44px;
        min-height: 36px;
    }

    .er-grid-header {
        min-width: 44px;
        font-size: 0.65rem;
        padding: 2px 4px;
    }

    .er-grid-row-header {
        min-width: 30px;
        font-size: 0.6rem;
        padding: 2px;
    }

    .er-grid {
        gap: 2px;
    }

    .er-cell-rating {
        font-size: 0.7rem;
    }

    .er-cell-votes {
        font-size: 0.45rem;
    }

    .er-highlight-thumb {
        width: 64px;
        height: 40px;
    }

    .er-chart-container {
        height: 220px;
        padding: 10px;
    }
}

/* ========================================
   DARK MODE OVERRIDES
   ======================================== */
[data-bs-theme="dark"] .er-grid-cell.er-avg-cell {
    border-color: rgba(255,255,255,0.3);
}

[data-bs-theme="dark"] .er-grid-cell:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
