/* Theme-based visibility */
.tangerine-only { display: none; }
.classic-only { display: block; }
body.tangerine-theme .tangerine-only { display: block; }
body.tangerine-theme .classic-only { display: none; }

/* Main container */
.statistics-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
}

.stats-container {
    width: 80%;
}

/* Toggle container */
.toggle-container {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 5%;
    margin-bottom: 15px;
    font-size: 0.9em;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 15px;
    background-color: #2c2c2c;
    border-radius: 8px;
}

.toggle-item {
    display: flex;
    align-items: center;
    margin-right: 0;
    padding: 5px 10px;
    border-radius: 6px;
    background-color: #383838;
}

.toggle-label {
    margin-right: 8px;
    color: #fff;
    font-size: 0.95em;
    white-space: nowrap;
}

/* Theme selector styles */
.theme-selector {
    background: #2a2a2a;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.9em;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.theme-selector:hover {
    background: #333;
    border-color: #ff6b35;
}

.theme-selector:focus {
    border-color: #ff6b35;
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.2);
}

/* Toggle switch styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
    margin-left: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .3s;
    border-radius: 22px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
    background-color: #FFA500;
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Collection stats */
.stats-box.collection-stats {
    margin-bottom: 10px;
    background-color: #2c2c2c;
    border-radius: 8px;
    padding: 15px;
}

.stats-box.collection-stats .stat-items {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: space-around;
}

.stats-box.collection-stats .stat-item {
    flex: 1;
    min-width: 150px;
    text-align: center;
}

.stats-box.collection-stats .stat-item p {
    margin: 0;
    color: #FFA500;
    font-size: 1.1em;
}

.stats-box.collection-stats .stat-item p::before {
    content: attr(data-label);
    display: block;
    color: #fff;
    font-weight: bold;
    margin-bottom: 4px;
}

/* Top stats grid */
.top-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 10px;
}

/* Common stats box styles */
.stats-box {
    background-color: #2c2c2c;
    border-radius: 8px;
    padding: 15px;
}

.stats-box h3 {
    color: #fff;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2em;
}

/* List styles for aired/airing/upcoming */
.stats-box.recently-aired ul,
.stats-box.airing-soon ul,
.stats-box.upcoming-releases ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.stats-box.recently-aired li,
.stats-box.airing-soon li,
.stats-box.upcoming-releases li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #3a3a3a;
    position: relative;
}

.stats-box.recently-aired li:last-child,
.stats-box.airing-soon li:last-child,
.stats-box.upcoming-releases li:last-child {
    border-bottom: none;
}

.stats-box.recently-aired .show-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.stats-box.airing-soon li,
.stats-box.upcoming-releases li
    {
        flex-direction: column;
        align-items: left;
    }

.compact-view .stats-box.recently-aired .show-info {
    flex: 1;
    display: flex;
    flex-direction: row;
}

.compact-view .stats-box.recently-aired .air-time
    {
        min-width: 120px;
        text-align: right;
        margin-right: 34px;  /* This accounts for the button width (24px) + its left margin (10px) */
    }

.stats-box.recently-aired .show-title,
.stats-box.airing-soon .show-title,
.stats-box.upcoming-releases .titles {
    color: #FFA500;
    text-align: left;
}

.stats-box.recently-aired .air-time,
.stats-box.airing-soon .air-time,
.stats-box.upcoming-releases .release-date {
    color: #fff;
    margin-left: 20px;
    font-style: italic;
    font-size: 0.9em;
}

.rescrape-btn {
    background: none;
    border: none;
    color: #FFA500;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: 24px;
    position: absolute;
    right: 0;
}

.rescrape-btn:hover,
.search-episode-btn:hover {
    background-color: rgba(255, 165, 0, 0.2);
}

.rescrape-btn:disabled,
.search-episode-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.recrape-icon::before {
  font: var(--fa-font-solid); /* Automatically sets family and weight to 900 */
  content: "\f01e";                /* Unicode for fa-arrows-rotate */
}

.search-episode-btn {
    background: none;
    border: none;
    color: #FFA500;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: 24px;
    position: relative;
    right: 0;
}


/* Card styles */
.stats-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, 200px);
    gap: 15px;
    width: 100%;
    justify-content: center;
}

.stats-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #3a3a3a;
}

.stats-card:last-child {
    border-bottom: none;
}

/* Poster styles */
.stats-poster-container {
    width: 200px;
    aspect-ratio: 2/3;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    margin: 0 auto;
}

.poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.stats-poster-hover {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stats-poster-container:hover .stats-poster-hover {
    opacity: 1;
}

.stats-poster-hover .title {
    color: #FFA500;
    font-size: 1.1em;
    margin-bottom: 8px;
}

.stats-poster-hover .metadata {
    color: #fff;
    font-size: 0.9em;
    margin-bottom: 4px;
}

.stats-poster-hover .filename {
    color: #888;
    font-family: monospace;
    font-size: 0.8em;
    word-break: break-all;
}

/* Recently added sections */
.recently-added {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.recently-added-section-top,
.recently-added-section-bottom,
.recently-upgraded-section {
    width: 100%;
    min-width: 0;
}

.recently-upgraded-section {
    margin-bottom: 20px;
}

/* File details */
.file-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-details .title {
    color: #FFA500;
    font-weight: normal;
}

.file-details .metadata {
    color: #fff;
    font-style: italic;
    font-size: 0.9em;
}

.file-details .filename {
    color: #888;
    font-family: monospace;
    font-size: 0.85em;
}

/* Add styling for From/To labels */
.file-details .filename::before {
    color: #fff;
    font-family: inherit;
}

.file-details .filename[data-label]::before {
    content: attr(data-label);
    color: white;
    margin-right: 4px;
    font-family: inherit;
}

.file-details .filename {
    color: #808080;  /* Keep the filename text gray */
    display: block;
    margin-top: 4px;
    font-family: monospace;
}

/* Compact view modifications */
.compact-view .stats-cards-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.compact-view .stats-card {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px 15px;
    margin: 0;
    border-bottom: 1px solid #3a3a3a;
}

.compact-view .stats-card:last-child {
    border-bottom: none;
}

.compact-view .stats-poster-container {
    display: none;
}

.compact-view .stats-box.recently-aired li,
.compact-view .stats-box.airing-soon li,
.compact-view .stats-box.upcoming-releases li {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.compact-view .stats-box.recently-aired .air-time,
.compact-view .stats-box.airing-soon .air-time,
.compact-view .stats-box.upcoming-releases .release-date {
    margin-left: auto;
    text-align: right;
}

.compact-view .file-details {
    width: 100%;
    padding-right: 10px;
}

.compact-view .file-details .title {
    font-size: 1em;
    margin-bottom: 4px;
    word-break: break-word;
}

.compact-view .file-details .metadata,
.compact-view .file-details .filename {
    font-size: 0.85em;
    word-break: break-word;
}

@media (max-width: 1280px) {
    .stats-container {
        width: 90%;
    }
}

/* Bottom sections grid layout for compact view (desktop only) */
@media screen and (min-width: 769px) {
    .statistics-wrapper.compact-view .recently-added {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
        width: 100%;
    }

    .statistics-wrapper.compact-view .recently-added-section-top,
    .statistics-wrapper.compact-view .recently-added-section-bottom,
    .statistics-wrapper.compact-view .recently-upgraded-section {
        margin: 0;
        height: auto;
    }
}

/* Scrollable containers for both mobile and desktop */
.statistics-wrapper.compact-view .stats-cards-container {
    overflow-y: visible;
}

.tmdb-info {
    margin-top: 10px;
    padding: 10px;
    color: red;
    font-style: italic;
    border-radius: 8px;
    text-align: center;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #compact_toggle {
        display: none;
    }

    .top-stats {
        grid-template-columns: 1fr;
    }

    .recently-added {
        flex-direction: column;
        width: 100%;
    }

    .stats-container {
        width: 95%;
    }

    /* Force compact view styles on mobile */
    .stats-cards-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        width: 100% !important;
    }

    .stats-card {
        flex-direction: row !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
        width: 100% !important;
        padding: 8px 15px !important;
        margin: 0 !important;
        border-bottom: 1px solid #3a3a3a !important;
        min-height: 50px !important;
        overflow: visible !important;
    }

    .stats-poster-container {
        display: none !important;
    }

    .file-details {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        padding-right: 10px !important;
        overflow: visible !important;
    }

    .file-details .title {
        font-size: 1em !important;
        margin-bottom: 4px !important;
        word-break: break-word !important;
        display: block !important;
    }

    .file-details .metadata,
    .file-details .filename {
        font-size: 0.85em !important;
        word-break: break-word !important;
        display: block !important;
        margin-bottom: 2px !important;
    }

    .toggle-container {
        padding: 8px 4%;
        gap: 10px;
        margin-bottom: 10px;
    }

    .toggle-item {
        padding: 4px 8px;
        flex: 0 1 auto;
    }

    .toggle-label {
        font-size: 0.9em;
    }

    .toggle-switch {
        width: 40px;
        height: 20px;
    }

    .toggle-slider:before {
        height: 14px;
        width: 14px;
    }

    input:checked + .toggle-slider:before {
        transform: translateX(20px);
    }

    .stats-box.airing-soon .air-time,
    .stats-box.upcoming-releases .release-date {
        margin-left: 0px !important;
        min-width: 0px !important;
        text-align: left !important;
    }

    /* Stats Box Styles */
    .stats-box.recently-aired .air-time {
        text-align: right !important;
        margin-right: 21px !important;
        margin-top: auto !important;
        margin-bottom: auto !important;
    }

    .stats-box.recently-aired .show-title {
        max-width: 180px !important;
    }

    .stats-box.airing-soon .show-title,
    .stats-box.upcoming-releases .titles 
    {
        max-width: 270px !important;
    }

    .modal-content {
        margin: 30% auto;
        width: 90%;
    }
}

/* Also add styles for the poster hover view */
.stats-poster-hover .filename[data-label]::before {
    content: attr(data-label);
    color: white;
    margin-right: 4px;
    font-family: inherit;
}

.stats-poster-hover .filename {
    color: #808080;
    font-family: monospace;
    font-size: 0.8em;
    word-break: break-all;
    display: block;
    margin-top: 4px;
}

/* Clickable items styling */
.stats-box.recently-aired li .show-info.clickable,
.stats-box.airing-soon li.clickable,
.stats-box.upcoming-releases li.clickable {
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 4px;
}

.stats-box.recently-aired li .show-info.clickable:hover,
.stats-box.airing-soon li.clickable:hover,
.stats-box.upcoming-releases li.clickable:hover {
    background-color: var(--bg-color-hover, rgba(255, 255, 255, 0.1));
}

/* Make sure the entire li is clickable in airing soon and upcoming releases */
.stats-box.airing-soon li.clickable,
.stats-box.upcoming-releases li.clickable {
    padding: 8px;
    margin: -8px 0;
}

/* Ensure the rescrape button remains clickable and doesn't trigger the modal */
.rescrape-btn {
    position: relative;
    z-index: 5;
}

/* Modal styles for external links */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

#external-links-modal-content {
    background-color: var(--bg-color, #1e1e1e);
    margin: 15% auto;
    padding: 20px;
    border: 1px solid var(--border-color, #444);
    border-radius: 8px;
    width: 300px !important;
    max-width: 80%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.close-modal {
    color: var(--text-color-secondary, #aaa);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover {
    color: var(--text-color, #fff);
}

.external-links {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.external-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background-color: var(--bg-color-secondary, #2a2a2a);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color, #fff);
    transition: background-color 0.2s;
}

.external-link:hover {
    background-color: var(--accent-color, #3498db);
    color: white;
}

.provider-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* ========================================
   Additional inline CSS from statistics.html
   ======================================== */
.stat-item p[data-label="Active Downloads"].warning,
.stat-item p[data-label="Daily Usage"].warning {
    color: #ffa500; /* Orange/Yellow for warning */
}
.stat-item p[data-label="Active Downloads"].critical,
.stat-item p[data-label="Daily Usage"].critical {
    color: #ff4444; /* Red for critical */
}
.stats-box.recently-aired .show-title.uncollected {
    color: #ff4444; /* Red for uncollected */
}
.stats-box.recently-aired .show-title.checking_upgrade {
    color: #00aeff; /* Orange/Yellow for checking upgrade */
}
.modal-content {
    background-color: #1e1e1e !important;
}
.toggle-container .toggle-item .refresh-btn { /* Style for the specific size refresh */
    background: none;
    border: none;
    color: #aaa; /* Match icon color */
    cursor: pointer;
    font-size: 1em; /* Match icon size */
    padding: 0 3px;
    margin-left: 3px;
    vertical-align: middle;
}
.toggle-container .toggle-item .refresh-btn:hover {
    color: #fff;
}
.toggle-container .toggle-item .refresh-btn i.fa-spin { /* Style for spinning icon */
    /* Optional: add animation if not default */
}
/* Subscription days critical color */
.toggle-container .toggle-item #subscription-days-toggle.critical {
    color: #ff4444;
}
#library-size-display {
    margin-right: 2px; /* Add a little space before the button */
}
/* General page refresh button style (if keeping it) */
 .page-refresh-btn {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 1.1em;
    padding: 0 5px;
    margin-left: 5px;
    vertical-align: middle;
}
.page-refresh-btn:hover {
    color: #fff;
}

/* Tangerine Theme - Recently Upgraded Section Inline Formatting */
/* Note: The combining of From/To filenames is handled by JavaScript in tangerine_filename_formatter.js */
body[data-theme="tangerine"] .recently-upgraded-section .file-details .filename[data-label="From:"]::before,
body[data-theme="tangerine"] .recently-upgraded-section .file-details .filename[data-label="To:"]::before {
    display: none !important;
}

body[data-theme="tangerine"] .recently-upgraded-section .stats-poster-hover .filename[data-label="From:"]::before,
body[data-theme="tangerine"] .recently-upgraded-section .stats-poster-hover .filename[data-label="To:"]::before {
    display: none !important;
}

/* Classic theme fallbacks for new topbar HTML structure */
body:not([data-theme="tangerine"]) .topbar-inner { display: contents; }
body:not([data-theme="tangerine"]) .tb-pill,
body:not([data-theme="tangerine"]) .tb-toggle-wrap,
body:not([data-theme="tangerine"]) .tb-theme {
    display: flex; align-items: center; margin-right: 0;
    padding: 5px 10px; border-radius: 6px; background-color: #383838;
}
body:not([data-theme="tangerine"]) .tb-label { margin-right: 6px; color: #fff; font-size: 0.95em; white-space: nowrap; }
body:not([data-theme="tangerine"]) .tb-val { color: #fff; }
body:not([data-theme="tangerine"]) .tb-val.critical { color: #ff4444; }
body:not([data-theme="tangerine"]) .tb-sep { display: none; }
body:not([data-theme="tangerine"]) .tb-break { display: none; }
body:not([data-theme="tangerine"]) .tb-refresh {
    background: none; border: none; color: #aaa; cursor: pointer;
    font-size: 1em; padding: 0 3px; margin-left: 3px; vertical-align: middle;
}
body:not([data-theme="tangerine"]) .tb-refresh:hover { color: #fff; }
body:not([data-theme="tangerine"]) .tb-swatch { display: none; }
body:not([data-theme="tangerine"]) .theme-selector {
    background: #2a2a2a; color: #f0f0f0; border: 1px solid #444;
    border-radius: 4px; padding: 4px 8px; font-size: 0.9em;
    cursor: pointer; outline: none;
}
body:not([data-theme="tangerine"]) .tb-search {
    display: flex; align-items: center; flex: 1; min-width: 140px; max-width: 240px; position: relative;
}
body:not([data-theme="tangerine"]) .toggle-switch { width: 44px; height: 22px; }
body:not([data-theme="tangerine"]) .toggle-slider { background-color: #555; border-radius: 22px; border: none; }
body:not([data-theme="tangerine"]) .toggle-slider:before { width: 16px; height: 16px; left: 3px; bottom: 3px; background-color: #fff; top: auto; }
body:not([data-theme="tangerine"]) input:checked + .toggle-slider { background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%); }
body:not([data-theme="tangerine"]) input:checked + .toggle-slider:before { transform: translateX(22px); }

/* Style the upgrade arrow - white and bold */
body[data-theme="tangerine"] .upgrade-arrow {
    color: #fff;
    font-weight: bold;
}