/* Modern Design System - Media Manager Portal */
:root {
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: #090d16;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99, 102, 241, 0.15);
    --badge-4k: #8b5cf6;
    --badge-hd: #3b82f6;
    --badge-sd: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --card-shadow: 0 10px 25px -5px rgba(0,0,0,0.4);
    --radius-lg: 12px;
    --radius-md: 8px;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #0f172a;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 15px -2px rgba(0,0,0,0.08);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1100;
    transition: transform 0.3s ease;
}

/* Hamburger toggle (hidden on desktop, shown at <=1024px) */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1050;
}

.sidebar-header {
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: #6366f1;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-item:hover, .nav-item.active {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
    border-left: 4px solid var(--accent-color);
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.theme-switcher {
    display: flex;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: var(--radius-md);
    justify-content: space-between;
}

.theme-btn {
    background: none;
    border: none;
    color: #94a3b8;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9rem;
}

.theme-btn.active {
    background-color: var(--accent-color);
    color: #fff;
}

.user-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #94a3b8;
}

/* Main Content Styling */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 2rem;
    max-width: calc(100vw - 260px);
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 950;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    padding-top: 1.5rem;
    padding-bottom: 0.75rem;
    margin-top: -1.5rem;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-color);
}

body.light-theme .top-header {
    background: rgba(248, 250, 252, 0.85);
}

.header-title {
    font-size: 1.75rem;
    font-weight: 700;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

/* Category Tabs (Movies vs TV Shows) */
.type-tabs-container {
    display: flex;
    gap: 0.5rem;
    position: sticky;
    top: 64px;
    z-index: 940;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    padding-top: 0.75rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0;
}

body.light-theme .type-tabs-container {
    background: rgba(248, 250, 252, 0.85);
}

.type-tab-btn {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.type-tab-btn:hover, .type-tab-btn.active {
    background-color: var(--accent-color);
    color: #ffffff;
    border-color: var(--accent-color);
}

/* Controls & Inputs */
.filter-bar {
    display: flex;
    gap: 1rem;
    position: sticky;
    top: 116px;
    z-index: 930;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    padding-top: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

body.light-theme .filter-bar {
    background: rgba(248, 250, 252, 0.85);
}

.search-input, .select-input {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
}

.search-input {
    flex: 1;
}

/* Inventory Layout & Right-Side Alphabet Strip */
.inventory-layout {
    display: flex;
    gap: 1.5rem;
    position: relative;
    width: 100%;
}

.inventory-grid {
    flex: 1;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.tv-inventory-container {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.az-jump-strip {
    width: 38px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: sticky;
    top: 190px;
    height: fit-content;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px 0;
    box-shadow: var(--card-shadow);
}

.az-letter-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 4px;
    cursor: pointer;
    border-radius: 3px;
    width: 28px;
    text-align: center;
    transition: all 0.15s ease;
}

.az-letter-btn:hover, .az-letter-btn.active {
    background-color: var(--accent-color);
    color: #ffffff;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s ease;
}

.btn-primary {
    background-color: var(--accent-color);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 4px;
}

/* Media Cards */
.media-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.2s ease;
}

.media-card:hover {
    transform: translateY(-4px);
}

.media-title {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-4k { background-color: var(--badge-4k); color: #fff; }
.badge-1080p { background-color: var(--badge-hd); color: #fff; }
.badge-sd { background-color: var(--badge-sd); color: #fff; }

.media-specs {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* TV Show Collapsible Season Cards */
.tv-show-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    width: 100%;
    box-sizing: border-box;
}

.tv-show-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    width: 100%;
}

.season-block {
    margin-bottom: 1.25rem;
    background-color: rgba(0,0,0,0.15);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid rgba(255,255,255,0.05);
    width: 100%;
    box-sizing: border-box;
}

.season-title {
    font-weight: 700;
    color: var(--accent-color);
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.episode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    width: 100%;
}

/* Log Terminal */
.log-terminal {
    background-color: #050811;
    color: #10b981;
    font-family: monospace;
    padding: 1rem;
    border-radius: var(--radius-md);
    height: 500px;
    overflow-y: auto;
    font-size: 0.85rem;
}

.log-line {
    margin-bottom: 0.4rem;
}

/* Section Cards & Admin */
.section-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: var(--radius-lg);
    width: 400px;
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 1rem; right: 1rem;
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 1.5rem; cursor: pointer;
}

/* Premium Glassmorphic Search Hero System */
.search-hero-card {
    position: relative;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.75), rgba(15, 23, 42, 0.95));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(99, 102, 241, 0.25);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    text-align: center;
    max-width: 850px;
    margin: 1rem auto 2rem auto;
    overflow: hidden;
}

.search-hero-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 300px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, rgba(0, 0, 0, 0) 70%);
    pointer-events: none;
}

.search-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #818cf8;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px #10b981;
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.search-hero-title {
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.search-hero-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 580px;
    margin: 0 auto 1.75rem auto;
    line-height: 1.5;
}

.search-tabs-pills {
    display: inline-flex;
    gap: 8px;
    background: rgba(15, 23, 42, 0.6);
    padding: 5px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.search-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-pill-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.search-pill-btn.active {
    color: #ffffff;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

/* Modern Glowing Search Bar Input */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.85);
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    padding: 6px 6px 6px 16px;
    transition: all 0.25s ease-in-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.search-input-wrapper:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.4), 0 0 0 1px #6366f1;
    background: rgba(15, 23, 42, 0.95);
}

.search-input-icon {
    color: #64748b;
    display: flex;
    align-items: center;
    margin-right: 12px;
    transition: color 0.2s ease;
}

.search-input-wrapper:focus-within .search-input-icon {
    color: #818cf8;
}

.modern-search-field {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #f8fafc;
    font-size: 1.05rem;
    font-family: inherit;
    font-weight: 500;
}

.modern-search-field::placeholder {
    color: #64748b;
    font-weight: 400;
}

.search-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.search-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.55);
    background: linear-gradient(135deg, #4f46e5, #4338ca);
}

.search-submit-btn:active {
    transform: translateY(0);
}

/* Inventory Search Input Styling */
.inventory-search-box {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.search-box-icon {
    position: absolute;
    left: 14px;
    color: #64748b;
    pointer-events: none;
    transition: color 0.2s ease;
}

.filter-bar .search-input {
    width: 100%;
    padding-left: 2.75rem;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.filter-bar .search-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.25);
    background: rgba(30, 41, 59, 0.95);
}

.inventory-search-box:focus-within .search-box-icon {
    color: #818cf8;
}

/* Scoring Guide Component */
.scoring-guide-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.scoring-guide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.15);
    user-select: none;
    transition: background-color 0.2s ease;
}

.scoring-guide-header:hover {
    background: rgba(0, 0, 0, 0.25);
}

.scoring-guide-header .chevron-icon {
    transition: transform 0.3s ease;
}

.scoring-guide-card.collapsed .chevron-icon {
    transform: rotate(-90deg);
}

.scoring-guide-card.collapsed .scoring-guide-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.scoring-guide-body {
    padding: 1.25rem;
    max-height: 1000px;
    opacity: 1;
    transition: all 0.3s cubic-bezier(0,1,0,1);
}

.scoring-table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
}

.scoring-col h4 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

.scoring-col ul {
    list-style: none;
    font-size: 0.85rem;
}

.scoring-col li {
    padding: 3px 0;
    color: var(--text-secondary);
}

.scoring-col strong {
    color: var(--text-primary);
}

/* Calendar Row Hover Animation */
.calendar-row:hover {
    transform: translateX(4px);
    border-color: var(--accent-color);
}

/* ==========================================================================
   Responsive Layout — Tablet & Mobile
   ========================================================================== */

/* Tablet and below: sidebar becomes an off-canvas drawer */
@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: inline-flex;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        margin-left: 0;
        max-width: 100vw;
    }

    .inventory-grid,
    .episode-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

/* Mobile phones */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    /* Sticky pixel-stacked headers get fragile with wrapped content on small
       screens — drop them back into normal flow instead. */
    .top-header,
    .type-tabs-container,
    .filter-bar {
        position: static;
        backdrop-filter: none;
        margin-top: 0;
    }

    .top-header {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding-top: 0;
    }

    .header-title {
        font-size: 1.35rem;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .select-input {
        width: 100%;
    }

    /* The vertical A-Z strip needs more width than a phone has to spare */
    .az-jump-strip {
        display: none;
    }

    /* media-card content (title, codec, size, full path, delete button) is
       too dense for a fixed 2-up grid on phone-width screens — let cards
       flow to 1 column when there isn't room for a legible 2nd column. */
    .inventory-grid,
    .episode-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 0.75rem;
    }

    .media-card {
        padding: 0.9rem;
    }

    .tv-show-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .scoring-table-grid {
        grid-template-columns: 1fr;
    }

    .search-hero-card {
        padding: 1.5rem 1rem;
    }

    .search-hero-title {
        font-size: 1.5rem;
    }

    .search-tabs-pills {
        flex-wrap: wrap;
        justify-content: center;
    }

    .search-input-wrapper {
        flex-wrap: wrap;
        padding: 10px;
    }

    .modern-search-field {
        width: 100%;
        margin-bottom: 8px;
    }

    .search-submit-btn {
        width: 100%;
        justify-content: center;
    }

    .modal-card {
        width: 90vw;
        padding: 1.5rem;
    }

    .log-terminal {
        height: 60vh;
    }

    .log-controls {
        flex-direction: column;
        align-items: stretch !important;
    }
}

/* Small phones */
@media (max-width: 420px) {
    .inventory-grid,
    .episode-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .sidebar {
        width: 85vw;
    }
}
