/* ===== My Media Library - Static Site Styles ===== */

:root {
    --bg: #1a1a1a;
    --bg-secondary: #242424;
    --bg-card: #2a2a2a;
    --bg-hover: #333;
    --border: #444;
    --text: #e0e0e0;
    --text-bright: #f0f0f0;
    --text-muted: #bbb;
    --text-dim: #888;
    --accent: #4a9eff;
    --accent-hover: #6ab0ff;
    --danger: #e74c3c;
    --warning: #f1c40f;
    --success: #2ecc71;
    --shadow: rgba(0, 0, 0, 0.4);
    --radius: 8px;
    --transition: 0.2s ease-in-out;
}

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

html, body {
    height: 100%;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: var(--bg);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===== Navbar ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #1f1f1f;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-bright);
    white-space: nowrap;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-bright);
    font-size: 1.25rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition);
}
.icon-btn:hover {
    background: var(--bg-hover);
}

.search-container {
    flex: 1;
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

#searchInput {
    width: 100%;
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
#searchInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}
#searchInput::placeholder {
    color: var(--text-dim);
}

.clear-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    display: none;
    line-height: 1;
    padding: 0 0.25rem;
}
.clear-btn:hover {
    color: var(--danger);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.result-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ===== Toggle Switch ===== */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 38px;
    height: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: background var(--transition), border-color var(--transition);
    flex-shrink: 0;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: #fff;
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Sidebar ===== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-overlay.open {
    display: block;
    opacity: 1;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: #1a1a1a;
    color: var(--text);
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
    overflow-y: auto;
}
.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-bright);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.sidebar-list {
    list-style: none;
    padding: 0.5rem 0.75rem;
    flex: 1;
    overflow-y: auto;
}

.sidebar-list li {
    margin-bottom: 0.25rem;
}

.sidebar-list button {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.6rem 0.9rem;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.95rem;
    text-align: left;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.sidebar-list button:hover {
    background: var(--bg-hover);
}
.sidebar-list button.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.sidebar-list .section-icon {
    width: 1.5rem;
    text-align: center;
    margin-right: 0.5rem;
    font-size: 1rem;
}

.sidebar-list .section-count {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-dim);
    background: var(--bg-secondary);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
}
.sidebar-list button.active .section-count {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-footer {
    padding: 0.75rem 1.25rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    text-align: center;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.loading-message {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}
.loading-message .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message {
    text-align: center;
    padding: 2rem;
    color: var(--danger);
    font-size: 1.1rem;
}

.content-container {
    min-height: 300px;
}

/* ===== Section Header ===== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}
.section-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-bright);
}
.section-header .section-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ===== Poster Grid ===== */
.poster-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.25rem;
}

.poster-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    display: flex;
    flex-direction: column;
}
.poster-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow);
    border-color: var(--accent);
}

.poster-item .poster-img-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 150%; /* 2:3 aspect ratio */
    overflow: hidden;
    background: var(--bg-secondary);
}
.poster-item .poster-img-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.poster-item .review-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--warning);
    color: #333;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 2;
}

.poster-item .poster-info {
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.poster-item .poster-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.poster-item .poster-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}
.empty-state p {
    font-size: 1.1rem;
}

/* ===== Details Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}
.modal-overlay.open {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-bright);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
}
.modal-close:hover {
    color: var(--danger);
}

.details-modal {
    position: relative;
}

.details-header {
    display: flex;
    gap: 1.25rem;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.details-poster {
    width: 180px;
    height: 270px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.details-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.details-info h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 0.25rem;
}

.details-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.details-meta strong {
    color: var(--text);
}

.details-filename {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.8rem;
    color: var(--text-dim);
    word-break: break-all;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    margin-top: 0.25rem;
}

.details-overview {
    padding: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text);
    text-align: justify;
}

.details-file-info {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.file-info-tag {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.details-episodes {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.details-episodes h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 0.75rem;
}

.episode-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.episode-item {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text);
    cursor: default;
}
.episode-item:last-child {
    border-bottom: none;
}
.episode-item:hover {
    background: var(--bg-hover);
}

.episode-item .episode-title {
    font-weight: 600;
    color: var(--text-bright);
}
.episode-item .episode-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .navbar-brand {
        font-size: 1rem;
    }
    .search-container {
        order: 3;
        width: 100%;
    }
    .poster-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
    }
    .details-header {
        flex-direction: column;
        align-items: center;
    }
    .details-poster {
        width: 140px;
        height: 210px;
    }
    .main-content {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .poster-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }
    .poster-item .poster-title {
        font-size: 0.8rem;
    }
}