/* VisionCine - Optimized CSS */
:root {
    --primary-color: #e50914;
    --primary-dark: #b20710;
    --background-dark: #0f0f0f;
    --background-card: #1a1a1a;
    --background-nav: #141414;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #808080;
    --border-color: #333333;
    --accent-color: #46d369;
    --warning-color: #f5c518;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-heavy: rgba(0, 0, 0, 0.7);
}

/* Reset and Base Styles */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100vh;
    position: fixed;
    width: 100%;
    overscroll-behavior: none;
}

/* Performance optimizations */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    position: relative;
    will-change: transform;
    transform: translateZ(0);
}

/* Status Bar - Enhanced for different devices */
.status-bar {
    height: env(safe-area-inset-top, 24px);
    background: var(--background-dark);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

/* Header - Improved performance */
.app-header {
    background: var(--background-nav);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 20px;
    padding-top: calc(env(safe-area-inset-top, 24px) + 12px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    border-bottom: 1px solid var(--border-color);
    will-change: transform;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
}

.logo {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color) 0%, #ff6b6b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    will-change: transform;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    will-change: transform, background-color;
}

.icon-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

/* Main Content - Optimized scrolling */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: calc(env(safe-area-inset-top, 24px) + 60px);
    padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 80px);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    will-change: scroll-position;
}

/* Sections - Improved transitions */
.section {
    display: none;
    min-height: calc(100vh - 140px);
    will-change: opacity, transform;
}

.section.active {
    display: block;
    animation: sectionFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes sectionFadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Search Section - Enhanced UX */
.search-container {
    padding: 20px;
    position: relative;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    height: 48px;
    background: var(--background-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 0 20px 0 48px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: border-color, background-color;
}

.search-input:focus {
    border-color: var(--primary-color);
    background: rgba(229, 9, 20, 0.1);
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.1);
}

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

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1;
}

/* Content Grid - Optimized layout */
.content-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 20px 20px;
    contain: layout style;
}

@media (min-width: 480px) {
    .content-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .content-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
        padding: 0 24px 24px;
    }
}

@media (min-width: 1024px) {
    .content-grid {
        grid-template-columns: repeat(5, 1fr);
        max-width: 1200px;
        margin: 0 auto;
    }
}

/* Movie Cards - Enhanced performance */
.movie-card {
    background: var(--background-card);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid transparent;
    will-change: transform, border-color, box-shadow;
    contain: layout style paint;
    position: relative;
}

.movie-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: 0 8px 25px var(--shadow-light);
}

.movie-card:active {
    transform: scale(0.98);
}

.movie-poster {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background: linear-gradient(135deg, #333 0%, #555 100%);
    display: block;
    transition: opacity 0.3s ease;
    will-change: opacity;
}

.movie-poster.loading {
    opacity: 0.7;
}

.movie-poster.loaded {
    opacity: 1;
}

.movie-poster.error {
    opacity: 0.8;
}

.movie-info {
    padding: 12px;
}

.movie-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-year {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.movie-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--warning-color);
}

/* Genre Section - Improved layout */
.genre-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 20px;
}

@media (min-width: 768px) {
    .genre-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        padding: 24px;
    }
}

.genre-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
    position: relative;
    overflow: hidden;
}

.genre-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.genre-card:hover::before {
    opacity: 1;
}

.genre-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow-light);
}

.genre-card:active {
    transform: scale(0.98);
}

.genre-name {
    font-size: 16px;
    font-weight: 600;
    color: white;
    position: relative;
    z-index: 1;
}

/* Profile Section - Enhanced styling */
.profile-container {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.profile-header {
    text-align: center;
    padding: 30px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 40px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 20px rgba(229, 9, 20, 0.3);
}

.profile-name {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.profile-email {
    color: var(--text-muted);
    font-size: 14px;
}

.settings-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.settings-item {
    display: flex;
    align-items: center;
    padding: 18px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    margin-bottom: 2px;
}

.settings-item:hover {
    background: rgba(255, 255, 255, 0.05);
    padding-left: 8px;
    padding-right: 8px;
}

.settings-item:active {
    background: rgba(255, 255, 255, 0.1);
}

.settings-icon {
    width: 20px;
    height: 20px;
    margin-right: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.settings-text {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
}

.settings-arrow {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Bottom Navigation - Enhanced design */
.bottom-nav {
    background: var(--background-nav);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    padding: 8px 0;
    padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 8px);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    display: flex;
    justify-content: space-around;
    align-items: center;
    will-change: transform;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    min-width: 60px;
    position: relative;
    will-change: transform, color;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 2px;
    background: var(--primary-color);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nav-item.active::before {
    opacity: 1;
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item:not(.active) {
    color: var(--text-muted);
}

.nav-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    transition: transform 0.2s ease;
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    line-height: 1;
}

/* Loading States - Improved animations */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(229, 9, 20, 0.3);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* Empty States - Enhanced design */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.7;
}

.empty-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Toast - Improved styling */
.toast {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 20px) + 100px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    z-index: 4000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Performance optimizations */
.movie-card,
.genre-card,
.nav-item,
.settings-item {
    contain: layout style paint;
}

.main-content {
    contain: layout style;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .search-container {
        padding: 16px;
    }
    
    .content-grid {
        padding: 0 16px 16px;
        gap: 10px;
    }
    
    .genre-grid {
        padding: 16px;
        gap: 10px;
    }
    
    .profile-container {
        padding: 16px;
    }
}

@media (min-width: 768px) {
    .app-header {
        padding: 16px 32px;
        padding-top: calc(env(safe-area-inset-top, 24px) + 16px);
    }
    
    .logo {
        font-size: 24px;
    }
    
    .main-content {
        padding-top: calc(env(safe-area-inset-top, 24px) + 68px);
    }
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

