/**
 * TV & Movie Tracker - Main Styles
 * Version 1.4.9 - List View Search & High Density Grid (12 Columns)
 * Author: South Florida Web Advisors
 */

#tvm-app-container {
    max-width: 1300px;
    margin: 0 auto;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Grouping Styles */
.tvm-group-title {
    font-size: 18px;
    font-weight: 800;
    color: #1d2327;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- NAVIGATION & TABS --- */
.tvm-nav-link {
    display: block;
    padding: 10px 0;
    text-decoration: none !important;
    color: #666;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.tvm-nav-link.active {
    color: #2271b1 !important;
    border-bottom-color: #2271b1 !important;
    font-weight: 700;
}

.tvm-type-tab {
    background: none;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid transparent;
}

.tvm-type-tab.active {
    color: #2271b1 !important;
    border-bottom-color: #2271b1 !important;
    font-weight: 700 !important;
}

/* --- FILTERS & CONTROLS --- */
.tvm-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap; 
}

.tvm-filter-btn {
    padding: 8px 18px;
    border-radius: 8px;
    border: 1px solid #ddd !important;
    background: #fff !important;
    color: #444 !important;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600 !important;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .tvm-filter-btn {
        padding: 6px 12px;
        font-size: 12px;
        flex: 1 1 auto; 
        text-align: center;
    }
}

.tvm-filter-btn.active {
    background: #2271b1 !important;
    color: #fff !important;
    border-color: #2271b1 !important;
}

/* --- GRID SYSTEM --- */
.tvm-locked-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr); /* High Density: 12 per row */
    gap: 12px; /* Tighter gap for smaller posters */
    width: 100%;
}

/* New High Density Grid for Unwatched Desktop View */
.tvm-unwatched-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px;
    width: 100%;
}

@media (max-width: 1200px) { 
    .tvm-locked-grid { grid-template-columns: repeat(8, 1fr); }
    .tvm-unwatched-grid { grid-template-columns: repeat(8, 1fr); } 
}
@media (max-width: 1000px) { 
    .tvm-locked-grid { grid-template-columns: repeat(6, 1fr); }
    .tvm-unwatched-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 700px) { 
    .tvm-locked-grid { grid-template-columns: repeat(4, 1fr); }
    .tvm-unwatched-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) { 
    .tvm-locked-grid { grid-template-columns: repeat(3, 1fr); }
    .tvm-unwatched-grid { grid-template-columns: repeat(3, 1fr); }
}

.tvm-movie-card {
    position: relative;
    width: 100%;
}

.tvm-poster-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    background: #000;
    aspect-ratio: 2 / 3;
    width: 100%;
}

.tvm-poster-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* --- PLACEHOLDER POSTERS --- */
.tvm-placeholder-poster {
    width: 100%;
    height: 100%;
    background: #2c3338;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #646970;
}

.tvm-placeholder-poster .dashicons {
    font-size: 32px; /* Smaller for high-density */
    width: 32px;
    height: 32px;
    margin-bottom: 5px;
    opacity: 0.5;
}

.tvm-placeholder-poster .placeholder-text {
    font-size: 8px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* --- OVERLAY CONTROLS --- */
.tvm-movie-card:hover .tvm-overlay-controls {
    opacity: 1;
    transform: translateY(0);
}

.tvm-overlay-controls {
    position: absolute;
    top: 5px;
    left: 5px;
    display: flex;
    gap: 5px;
    z-index: 11;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s ease;
}

.tvm-overlay-controls .dashicons {
    background: rgba(0,0,0,0.7);
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- BADGES --- */
.tvm-badge-upcoming {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: #2271b1;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: bold;
    z-index: 10;
}

.tvm-badge-stats {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: bold;
    z-index: 10;
}

/* --- SETTINGS GRID --- */
.tvm-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 15px;
    align-items: start;
}

.tvm-setting-card {
    position: relative;
    cursor: pointer;
    border-radius: 10px;
    padding: 15px 10px;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 110px;
    transition: all 0.2s;
    border: 2px solid #eee;
}

.tvm-setting-card.active {
    background: #f0fdf4 !important;
    border-color: #46b450 !important;
}

.tvm-setting-card img {
    width: 45px;
    height: 45px;
    object-fit: contain;
    margin-bottom: 10px;
    display: block;
}

/* --- SEASON TABS --- */
.tvm-season-tab {
    min-width: 100px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s, color 0.2s;
}

/* --- EPISODE LISTS --- */
.tvm-episode-row {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    border-left: 5px solid #ddd;
    transition: background 0.2s;
    margin-bottom: 15px;
    width: 100%;
}

.tvm-episode-row:hover {
    background: #fcfcfc;
}

.tvm-episode-sources {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tvm-episode-sources img {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    border: 1px solid #eee;
    object-fit: contain;
    background: #fff;
}

.tvm-ep-overview {
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.5;
    color: #666;
}

/* --- CALENDAR VIEW --- */
.tvm-calendar-container {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #eee;
    padding: 20px;
    margin-bottom: 25px;
}

.tvm-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-weight: 700;
    font-size: 18px;
}

.tvm-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-top: 1px solid #eee;
    border-left: 1px solid #eee;
}

.tvm-calendar-day-label {
    padding: 10px;
    text-align: center;
    background: #f9f9f9;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    color: #999;
}

.tvm-calendar-day {
    min-height: 120px;
    padding: 8px;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.tvm-calendar-day:hover { background: #f0f7ff; }
.tvm-calendar-day.empty { background: #fafafa; cursor: default; }
.tvm-calendar-day.today { background: #fff8e5; }

.tvm-calendar-date {
    font-size: 11px;
    font-weight: 700;
    color: #999;
    display: block;
    margin-bottom: 8px;
}

.tvm-cal-ep-item {
    font-size: 10px;
    margin-bottom: 4px;
    line-height: 1.3;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 4px;
}

.tvm-calendar-dots { display: none; }

@media (max-width: 800px) {
    .tvm-calendar-day { min-height: 50px; aspect-ratio: 1/1; text-align: center; }
    .tvm-cal-ep-item { display: none; }
    .tvm-calendar-dots { 
        display: flex; 
        flex-wrap: wrap; 
        gap: 3px; 
        margin-top: 5px; 
        justify-content: center; 
    }
}

.tvm-calendar-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2271b1;
}
.tvm-calendar-dot.watched { background: #46b450; }

/* --- UNWATCHED UI --- */
.tvm-unwatched-active {
    outline: 4px solid #2271b1;
    outline-offset: -4px;
    border-radius: 8px;
}

/* Mobile Dropdown Fix */
.tvm-unwatched-nav-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

@media (max-width: 600px) {
    .tvm-unwatched-nav-container select {
        flex: 1;
        min-width: 0; 
        max-width: calc(100% - 80px); 
    }
}

#tvm-unwatched-inline-container {
    width: 100%;
    clear: both;
}

.tvm-mark-season-watched {
    color: #fff !important;
}

.tvm-mark-season-watched:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* --- NEW: SEARCH LIST VIEW (v1.4.9) --- */
#tvm-frontend-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.tvm-search-row {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 12px 20px;
    transition: background 0.2s ease;
}

.tvm-search-row:hover {
    background: #fcfcfc;
}

.tvm-search-poster {
    flex: 0 0 60px;
    margin-right: 20px;
}

.tvm-search-poster img {
    width: 60px;
    height: auto;
    border-radius: 6px;
    display: block;
}

.tvm-search-meta {
    flex: 1;
}

.tvm-search-action {
    flex: 0 0 120px;
    text-align: right;
}

.tvm-search-type-tag {
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    background: #f0f0f1;
    padding: 2px 6px;
    border-radius: 4px;
    color: #666;
}

.tvm-search-toggles {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.tvm-search-filter {
    background: #fff;
    border: 1px solid #ddd;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

.tvm-search-filter.active {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

/* --- INDIVIDUAL EPISODE PROGRESS BAR --- */
.tvm-episode-row {
    position: relative; /* Required for absolute child */
    overflow: hidden;   /* Ensures the bar doesn't spill out of rounded corners */
    z-index: 1;
}

.tvm-ep-row-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgba(34, 113, 177, 0.08); /* Faint blue tint */
    border-right: 2px solid #2271b1;      /* Leading edge of the bar */
    z-index: -1;                          /* Sits behind text/content */
    transition: width 6.0s cubic-bezier(0.1, 0.5, 0.5, 1);
    pointer-events: none;
}

/* State when loading */
.tvm-episode-row.is-updating .tvm-ep-row-progress {
    width: 100%;
}

