/**
 * Haven Styles
 * ============
 * Professional corporate design following UI SoT v2
 * Dark cinematic theme inspired by Plex
 */

/* ==========================================================================
   CSS CUSTOM PROPERTIES (from DESIGN constants)
   ========================================================================== */

:root {
    /* Colors */
    --color-primary: #E5A00D;
    --color-primary-hover: #CC8A00;
    
    --color-bg-primary: #1A1A1A;
    --color-bg-secondary: #242424;
    --color-bg-elevated: #2D2D2D;
    --color-bg-hover: #363636;
    
    --color-text-primary: #FFFFFF;
    --color-text-secondary: #A0A0A0;
    --color-text-muted: #666666;
    
    --color-success: #4CAF50;
    --color-warning: #FF9800;
    --color-error: #F44336;
    --color-info: #2196F3;
    
    --color-border: #333333;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-xxl: 48px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    
    /* Font Sizes */
    --font-xs: 12px;
    --font-sm: 14px;
    --font-base: 16px;
    --font-lg: 18px;
    --font-xl: 24px;
    --font-xxl: 32px;
    --font-hero: 48px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
    
    /* Layout */
    --sidebar-width: 240px;
    --header-height: 64px;
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: var(--font-base);
    line-height: 1.5;
    color: var(--color-text-primary);
    background: var(--color-bg-primary);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

img {
    max-width: 100%;
    display: block;
}

ul, ol {
    list-style: none;
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */

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

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-lg);
    overflow-x: hidden;
}

.page-header {
    margin-bottom: var(--space-xl);
}

.page-title {
    font-size: var(--font-xxl);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.page-subtitle {
    color: var(--color-text-secondary);
    font-size: var(--font-lg);
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--color-border);
    z-index: 100;
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-close-btn {
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    padding: var(--space-sm);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.mobile-close-btn:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}

.mobile-close-btn svg {
    width: 20px;
    height: 20px;
}

.logo-text {
    font-size: var(--font-xl);
    font-weight: 700;
    color: var(--color-primary);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md) 0;
}

.nav-section {
    margin-bottom: var(--space-md);
}

.nav-section-title {
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.nav-item:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

.nav-item.active {
    background: var(--color-bg-hover);
    color: var(--color-primary);
    border-left: 3px solid var(--color-primary);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 100%;
    height: 100%;
}

.sidebar-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.user-icon {
    width: 24px;
    height: 24px;
    color: var(--color-text-secondary);
}

.user-icon svg {
    width: 100%;
    height: 100%;
}

.user-name {
    font-size: var(--font-sm);
    color: var(--color-text-secondary);
}

.logout-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-error);
}

.logout-btn svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   SEARCH
   ========================================================================== */

.search-container {
    position: relative;
    max-width: 400px;
    margin-bottom: var(--space-lg);
}

.search-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    padding-left: 40px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: var(--font-base);
    transition: border-color var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.search-input::placeholder {
    color: var(--color-text-muted);
}

.search-icon {
    position: absolute;
    left: var(--space-sm);
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-top: var(--space-xs);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.result-section {
    padding: var(--space-sm);
}

.result-section-title {
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: var(--space-xs) var(--space-sm);
}

.result-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.result-item:hover {
    background: var(--color-bg-hover);
}

.result-icon {
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
}

.result-icon svg {
    width: 100%;
    height: 100%;
}

/* ==========================================================================
   MEDIA GRID
   ========================================================================== */

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-lg);
}

.media-section {
    margin-bottom: var(--space-xxl);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.section-title {
    font-size: var(--font-xl);
    font-weight: 600;
}

.section-link {
    color: var(--color-primary);
    font-size: var(--font-sm);
}

.section-link:hover {
    text-decoration: underline;
}

/* ==========================================================================
   MEDIA CARDS
   ========================================================================== */

.media-card {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.media-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-link {
    display: block;
}

.card-poster {
    position: relative;
    aspect-ratio: 2/3;
    background: var(--color-bg-elevated);
    overflow: hidden;
}

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

.card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
}

.card-placeholder svg {
    width: 48px;
    height: 48px;
}

.card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.media-card:hover .card-overlay {
    opacity: 1;
}

.play-icon {
    width: 48px;
    height: 48px;
    color: white;
}

.play-icon svg {
    width: 100%;
    height: 100%;
}

.card-info {
    padding: var(--space-sm);
}

.card-title {
    font-size: var(--font-sm);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-year {
    font-size: var(--font-xs);
    color: var(--color-text-muted);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all var(--transition-fast);
}

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

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

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

.btn-secondary:hover {
    background: var(--color-bg-hover);
}

.btn-danger {
    background: var(--color-error);
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-full);
}

.btn svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   FORMS
   ========================================================================== */

.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: var(--font-base);
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

.form-error {
    color: var(--color-error);
    font-size: var(--font-sm);
    margin-top: var(--space-xs);
}

/* ==========================================================================
   TABLES
   ========================================================================== */

.table-container {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table th {
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: var(--font-sm);
    text-transform: uppercase;
}

.table tr:hover td {
    background: var(--color-bg-hover);
}

.table tr:last-child td {
    border-bottom: none;
}

/* ==========================================================================
   TOASTS
   ========================================================================== */

#toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--color-bg-elevated);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-success {
    border-left: 4px solid var(--color-success);
}

.toast-error {
    border-left: 4px solid var(--color-error);
}

.toast-warning {
    border-left: 4px solid var(--color-warning);
}

.toast-info {
    border-left: 4px solid var(--color-info);
}

.toast-close {
    width: 24px;
    height: 24px;
    color: var(--color-text-muted);
}

.toast-close svg {
    width: 100%;
    height: 100%;
}

/* ==========================================================================
   MODALS
   ========================================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: var(--space-lg);
}

.modal {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}

.modal-title {
    font-size: var(--font-lg);
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--color-bg-hover);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-content {
    padding: var(--space-lg);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

/* ==========================================================================
   LOADING & EMPTY STATES
   ========================================================================== */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-xxl);
    color: var(--color-text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-xxl);
    text-align: center;
}

.empty-icon {
    width: 64px;
    height: 64px;
    color: var(--color-text-muted);
}

.empty-icon svg {
    width: 100%;
    height: 100%;
}

.empty-message {
    color: var(--color-text-secondary);
    font-size: var(--font-lg);
}

/* ==========================================================================
   LOGIN PAGE
   ========================================================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-bg-primary) 0%, var(--color-bg-secondary) 100%);
}

.login-card {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-xxl);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.login-logo h1 {
    font-size: var(--font-hero);
    font-weight: 700;
    color: var(--color-primary);
}

.login-form .form-group {
    margin-bottom: var(--space-lg);
}

.login-form .btn {
    width: 100%;
    padding: var(--space-md);
    font-size: var(--font-lg);
}

/* ==========================================================================
   SETUP WIZARD
   ========================================================================== */

.setup-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-bg-primary) 0%, var(--color-bg-secondary) 100%);
}

.setup-card {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-xxl);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.setup-steps {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.setup-step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-bg-elevated);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-sm);
    font-weight: 600;
}

.setup-step.active {
    background: var(--color-primary);
    color: #000;
}

.setup-step.complete {
    background: var(--color-success);
    color: white;
}

.setup-title {
    font-size: var(--font-xl);
    font-weight: 600;
    text-align: center;
    margin-bottom: var(--space-lg);
}

.setup-actions {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-xl);
}

/* ==========================================================================
   DETAIL PAGES
   ========================================================================== */

.detail-hero {
    position: relative;
    aspect-ratio: 16 / 9;
    max-height: 70vh;
    margin: calc(var(--space-lg) * -1);
    margin-bottom: var(--space-lg);
    background-size: cover;
    background-position: center top;
}

.detail-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--color-bg-primary) 0%, transparent 100%);
}

.detail-hero-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-lg);
    z-index: 1;
    display: flex;
    gap: var(--space-lg);
}

.detail-poster {
    width: 200px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.detail-poster img {
    width: 100%;
}

.detail-info {
    flex: 1;
}

.detail-title {
    font-size: var(--font-xxl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.detail-meta {
    display: flex;
    gap: var(--space-md);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
}

.detail-actions {
    display: flex;
    gap: var(--space-sm);
}

.detail-plot {
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-top: var(--space-lg);
}

/* ==========================================================================
   VIDEO PLAYER
   ========================================================================== */

.player-page {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
}

.video-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-container video {
    max-width: 100%;
    max-height: 100%;
}

.player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-lg);
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.player-page:hover .player-controls {
    opacity: 1;
}

.progress-bar {
    height: 4px;
    background: var(--color-bg-elevated);
    border-radius: var(--radius-full);
    cursor: pointer;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: width 0.1s linear;
}

.player-buttons {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.player-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border-radius: var(--radius-full);
}

.player-btn:hover {
    background: rgba(255,255,255,0.1);
}

.player-btn svg {
    width: 24px;
    height: 24px;
}

.player-time {
    color: var(--color-text-secondary);
    font-size: var(--font-sm);
}

.player-close {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 200px;
    }
    
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
        --font-xxl: 24px;
        --font-xl: 20px;
        --font-hero: 32px;
    }
    
    /* Sidebar - slide out on mobile */
    #sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        z-index: 1000;
        width: var(--sidebar-width);
    }
    
    #sidebar.open {
        transform: translateX(0);
    }
    
    /* Overlay when sidebar open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Main content - full width */
    .main-content {
        margin-left: 0;
        padding: var(--space-md);
        padding-top: calc(var(--header-height) + var(--space-md));
    }
    
    /* Mobile header */
    .mobile-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--header-height);
        background: var(--color-bg-secondary);
        border-bottom: 1px solid var(--color-border);
        align-items: center;
        padding: 0 var(--space-md);
        z-index: 998;
    }
    
    .mobile-menu-btn {
        background: transparent;
        border: none;
        color: var(--color-text-primary);
        padding: var(--space-sm);
        margin-right: var(--space-md);
        cursor: pointer;
    }
    
    .mobile-menu-btn svg {
        width: 24px;
        height: 24px;
    }
    
    .mobile-logo {
        font-size: var(--font-lg);
        font-weight: 700;
        color: var(--color-primary);
    }
    
    /* Media grid - smaller cards */
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: var(--space-sm);
    }
    
    .card-info {
        padding: var(--space-sm);
    }
    
    .card-title {
        font-size: var(--font-sm);
    }
    
    .card-year, .card-subtitle {
        font-size: var(--font-xs);
    }
    
    /* Page header */
    .page-header {
        margin-bottom: var(--space-lg);
    }
    
    .page-title {
        font-size: var(--font-xl);
    }
    
    /* Detail pages */
    .detail-hero {
        height: auto;
        min-height: 300px;
        padding: var(--space-lg) var(--space-md);
    }
    
    .detail-hero-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: var(--space-lg);
    }
    
    .detail-poster {
        width: 150px;
        margin-bottom: var(--space-md);
    }
    
    .detail-info {
        align-items: center;
    }
    
    .detail-title {
        font-size: var(--font-xl);
    }
    
    .detail-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .detail-actions .btn {
        flex: 1;
        min-width: 120px;
    }
    
    /* Section headers */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
    
    /* Tables - card style on mobile */
    .table {
        display: block;
    }
    
    .table thead {
        display: none;
    }
    
    .table tbody {
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .table tr {
        display: flex;
        flex-direction: column;
        background: var(--color-bg-secondary);
        border-radius: var(--radius-md);
        padding: var(--space-md);
    }
    
    .table td {
        padding: var(--space-xs) 0;
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .table td::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--color-text-muted);
        font-size: var(--font-sm);
    }
    
    /* Forms */
    .form-group {
        margin-bottom: var(--space-md);
    }
    
    .form-input, .form-select, .form-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Buttons */
    .btn {
        padding: var(--space-sm) var(--space-md);
        font-size: var(--font-sm);
    }
    
    .btn-sm {
        padding: var(--space-xs) var(--space-sm);
    }
    
    /* Modal */
    .modal-content {
        width: calc(100% - var(--space-lg));
        max-width: none;
        margin: var(--space-md);
        max-height: calc(100vh - var(--space-lg));
    }
    
    /* Player controls */
    .player-controls {
        padding: var(--space-sm);
    }
    
    .player-controls-row {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }
    
    .volume-container {
        display: none; /* Hide on mobile, use device volume */
    }
    
    .speed-menu, .subtitle-menu {
        bottom: 50px;
        right: 0;
    }
    
    /* Search */
    .search-container {
        margin-bottom: var(--space-md);
    }
    
    .search-input {
        font-size: 16px;
    }
    
    /* Tabs */
    .admin-tabs {
        flex-wrap: wrap;
    }
    
    .admin-tab {
        flex: 1;
        min-width: 80px;
        text-align: center;
        padding: var(--space-sm);
        font-size: var(--font-sm);
    }
    
    /* Toast notifications */
    .toast {
        left: var(--space-md);
        right: var(--space-md);
        bottom: var(--space-md);
        max-width: none;
    }
    
    /* Empty states */
    .empty-state {
        padding: var(--space-xl) var(--space-md);
    }
    
    /* Music player */
    .music-player-bar {
        flex-wrap: wrap;
        padding: var(--space-sm);
        gap: var(--space-sm);
    }
    
    .now-playing-info {
        flex: 1 1 100%;
        order: 1;
    }
    
    .player-main-controls {
        order: 2;
        flex: 1;
    }
    
    .player-extra-controls {
        order: 3;
    }
}

/* Small phones */
@media (max-width: 480px) {
    :root {
        --font-xxl: 20px;
        --font-xl: 18px;
    }
    
    .media-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
    }
    
    .detail-poster {
        width: 120px;
    }
    
    .detail-actions {
        flex-direction: column;
    }
    
    .detail-actions .btn {
        width: 100%;
    }
    
    /* Stack action buttons */
    .table td:last-child {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-xs);
    }
    
    .table td:last-child > div {
        display: flex;
        gap: var(--space-xs);
        justify-content: flex-end;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        min-height: 48px;
    }
    
    .card-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
    }
    
    .play-icon {
        opacity: 0.9;
    }
    
    /* Remove hover effects */
    .media-card:hover .card-poster img {
        transform: none;
    }
    
    .media-card:hover .card-overlay {
        opacity: 1;
    }
}

/* Landscape phone */
@media (max-width: 768px) and (orientation: landscape) {
    .detail-hero {
        min-height: auto;
        padding: var(--space-md);
    }
    
    .detail-hero-content {
        flex-direction: row;
        text-align: left;
    }
    
    .detail-poster {
        width: 100px;
    }
    
    .detail-info {
        align-items: flex-start;
    }
}

/* Print styles */
@media print {
    #sidebar, .mobile-header, .player-container, .modal {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
}
