/* ===========================================
   RESPONSIVE DESIGN - FULL DEVICE OPTIMIZATION
   =========================================== */

/* Base Responsive Setup */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

iframe,
embed,
object,
video {
    max-width: 100%;
}

/* Touch Target Optimization */
a, button, input[type="submit"], input[type="button"] {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* =========================================== 
   EXTRA LARGE DESKTOP (1920px and above)
   =========================================== */
@media (min-width: 1920px) {
    .container {
        max-width: 1600px;
    }
    
    .hero-content h1 {
        font-size: 5rem;
    }
    
    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    section h2 {
        font-size: 3.5rem;
    }
}

/* =========================================== 
   LARGE DESKTOP (1440px - 1919px)
   =========================================== */
@media (min-width: 1440px) and (max-width: 1919px) {
    .container {
        max-width: 1400px;
    }
    
    .hero-content h1 {
        font-size: 4.5rem;
    }
    
    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

/* =========================================== 
   STANDARD DESKTOP (1200px - 1439px)
   =========================================== */
@media (min-width: 1200px) and (max-width: 1439px) {
    .container {
        max-width: 1140px;
    }
    
    .movie-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* =========================================== 
   SMALL DESKTOP / LARGE TABLET (992px - 1199px)
   =========================================== */
@media (min-width: 992px) and (max-width: 1199px) {
    .container {
        max-width: 960px;
        padding: 0 2rem;
    }
    
    .hero-content h1 {
        font-size: 3.5rem;
    }
    
    .movie-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .slider-item {
        min-width: 200px;
    }
}

/* =========================================== 
   TABLET LANDSCAPE (768px - 991px)
   =========================================== */
@media (min-width: 768px) and (max-width: 991px) {
    .container {
        max-width: 720px;
        padding: 0 1.5rem;
    }
    
    .hero-content h1 {
        font-size: 3rem;
    }
    
    .hero-content p {
        font-size: 1.1rem;
    }
    
    .movie-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    section h2 {
        font-size: 2.5rem;
    }
    
    /* Optimize touch interactions */
    .movie-card {
        transition: transform 0.2s;
    }
    
    .movie-card:active {
        transform: scale(0.98);
    }
    
    /* Better spacing for tablet */
    .navbar {
        padding: 1rem 0;
    }
    
    .widget {
        margin-bottom: 2rem;
    }
}

/* =========================================== 
   TABLET PORTRAIT (576px - 767px)
   =========================================== */
@media (min-width: 576px) and (max-width: 767px) {
    .container {
        max-width: 540px;
        padding: 0 1.5rem;
    }
    
    .navbar .container {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .nav-links {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 70%;
        height: calc(100vh - 70px);
        background: var(--card-bg);
        flex-direction: column;
        justify-content: flex-start;
        padding: 2rem;
        transition: left 0.3s ease-in-out;
        z-index: 999;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }

    .nav-links.active {
        left: 0;
    }

    .nav-menu {
        flex-direction: column;
        width: 100%;
        gap: 1rem;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu a {
        display: block;
        padding: 1rem;
        background: var(--bg);
        border-radius: 8px;
        font-size: 1.1rem;
    }

    .hamburger {
        display: flex;
        z-index: 1000;
    }

    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }

    body.menu-open {
        overflow: hidden;
    }

    .nav-actions {
        order: 2;
    }

    .logo {
        order: 1;
    }

    .search-box {
        width: 100%;
        order: 3;
        margin-top: 1rem;
    }

    .search-box input {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .hero-content h1 {
        font-size: 2.5rem;
        line-height: 1.2;
    }

    .hero-content p {
        font-size: 1rem;
        line-height: 1.6;
    }

    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .newsletter-form {
        flex-direction: column;
        gap: 1rem;
    }

    .newsletter-form input {
        width: 100%;
    }

    section h2 {
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }

    .slider-container {
        gap: 0.5rem;
    }

    .slider-btn {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
    
    .slider-item {
        min-width: 180px;
    }
    
    /* Better form controls on tablet */
    input[type="text"],
    input[type="email"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* =========================================== 
   MOBILE LANDSCAPE (481px - 575px)
   =========================================== */
@media (min-width: 481px) and (max-width: 575px) {
    .container {
        padding: 0 1.25rem;
    }
    
    .navbar .container {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .nav-links {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 80%;
        height: calc(100vh - 70px);
        background: var(--card-bg);
        flex-direction: column;
        justify-content: flex-start;
        padding: 2rem;
        transition: left 0.3s ease-in-out;
        z-index: 999;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }

    .nav-links.active {
        left: 0;
    }

    .nav-menu {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu a {
        display: block;
        padding: 0.875rem 1rem;
        background: var(--bg);
        border-radius: 8px;
        font-size: 1rem;
    }

    .hamburger {
        display: flex;
        z-index: 1000;
    }

    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }

    body.menu-open {
        overflow: hidden;
    }

    .nav-actions {
        order: 2;
    }

    .logo {
        order: 1;
    }

    .search-box {
        width: 100%;
        order: 3;
        margin-top: 1rem;
    }

    .search-box input {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px;
    }

    .hero-content h1 {
        font-size: 2.25rem;
    }

    .hero-content p {
        font-size: 0.95rem;
    }

    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .newsletter-form {
        flex-direction: column;
        gap: 0.75rem;
    }

    .newsletter-form input {
        width: 100%;
    }

    section h2 {
        font-size: 1.875rem;
    }

    .slider-btn {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .slider-item {
        min-width: 160px;
    }
}

/* =========================================== 
   MOBILE PORTRAIT (320px - 480px)
   =========================================== */
@media (max-width: 480px) {
    /* Base mobile optimizations */
    body {
        font-size: 14px;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    /* Header & Navigation */
    .logo a {
        font-size: 1.5rem;
    }

    .logo-icon {
        font-size: 2rem;
    }
    
    .navbar {
        padding: 0.75rem 0;
    }
    
    .navbar .container {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .nav-links {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 85%;
        height: calc(100vh - 60px);
        background: var(--card-bg);
        flex-direction: column;
        justify-content: flex-start;
        padding: 1.5rem;
        transition: left 0.3s ease-in-out;
        z-index: 999;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }

    .nav-links.active {
        left: 0;
    }

    .nav-menu {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu a {
        display: block;
        padding: 0.75rem 1rem;
        background: var(--bg);
        border-radius: 6px;
        font-size: 0.95rem;
    }

    .hamburger {
        display: flex;
        z-index: 1000;
        width: 40px;
        height: 40px;
    }
    
    .hamburger span {
        width: 25px;
        height: 2px;
    }

    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }

    body.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }

    .nav-actions {
        order: 2;
        gap: 0.5rem;
    }

    .logo {
        order: 1;
    }

    .search-box {
        width: 100%;
        order: 3;
        margin-top: 0.75rem;
    }

    .search-box input {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    /* Hero Section */
    .hero-section {
        min-height: 350px;
        padding: 3rem 0;
    }

    .hero-content {
        text-align: center;
    }

    .hero-content h1 {
        font-size: 1.75rem;
        line-height: 1.3;
        margin-bottom: 1rem;
    }
    
    .hero-content p {
        font-size: 0.875rem;
        line-height: 1.5;
        margin-bottom: 1.5rem;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    .btn {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
    }
    
    /* Movie Grid */
    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .movie-card {
        border-radius: 8px;
    }
    
    .movie-card img {
        border-radius: 8px 8px 0 0;
    }
    
    .movie-info {
        padding: 0.75rem;
    }
    
    .movie-info h3 {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    
    .movie-meta {
        font-size: 0.8rem;
    }
    
    /* Single Column Layouts */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .widget {
        margin-bottom: 1.5rem;
    }
    
    .widget-title {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .newsletter-form {
        flex-direction: column;
        gap: 0.75rem;
    }

    .newsletter-form input,
    .newsletter-form button {
        width: 100%;
        padding: 0.875rem 1rem;
        font-size: 16px; /* Prevents iOS zoom */
    }

    section {
        padding: 2rem 0;
    }

    section h2 {
        font-size: 1.75rem;
        margin-bottom: 1.25rem;
    }
    
    /* Slider Optimization */
    .slider-container {
        gap: 0.5rem;
        padding: 0 0.25rem;
    }

    .slider-btn {
        width: 35px;
        height: 35px;
        font-size: 1.125rem;
        padding: 0;
    }
    
    .slider-item {
        min-width: 140px;
    }
    
    .slider-track {
        gap: 0.75rem;
    }
    
    /* Review Items */
    .review-item a {
        flex-direction: column;
        text-align: center;
    }

    .review-thumb {
        width: 100%;
        margin-bottom: 1rem;
    }

    .review-thumb img {
        width: 100%;
        height: auto;
        border-radius: 8px;
    }
    
    .review-content {
        padding: 0;
    }
    
    /* Forms */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        width: 100%;
        padding: 0.875rem;
        font-size: 16px; /* Prevents iOS zoom */
        border-radius: 6px;
    }
    
    button,
    input[type="submit"],
    .btn {
        min-height: 48px;
        padding: 0.875rem 1.5rem;
        font-size: 16px;
    }
    
    /* Comments */
    .comment-list {
        padding-left: 0;
    }
    
    .comment .children {
        padding-left: 1rem;
    }
    
    /* Sidebar */
    .sidebar {
        margin-top: 2rem;
    }
    
    /* Tables */
    table {
        font-size: 0.875rem;
    }
    
    table td,
    table th {
        padding: 0.5rem;
    }
    
    /* Ratings */
    .star-rating {
        gap: 0.25rem;
    }
    
    .star {
        font-size: 1.5rem;
    }
    
    /* Social Share */
    .share-buttons {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .share-btn {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 0;
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }
}

/* =========================================== 
   EXTRA SMALL MOBILE (below 360px)
   =========================================== */
@media (max-width: 359px) {
    body {
        font-size: 13px;
    }
    
    .container {
        padding: 0 0.75rem;
    }
    
    .hero-content h1 {
        font-size: 1.5rem;
    }
    
    .movie-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .slider-item {
        min-width: 130px;
    }
    
    section h2 {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

/* =========================================== 
   LANDSCAPE ORIENTATION SPECIFIC
   =========================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        min-height: 300px;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .nav-links {
        height: calc(100vh - 60px);
        padding: 1rem;
    }
    
    .nav-menu {
        gap: 0.5rem;
    }
    
    .nav-menu a {
        padding: 0.5rem 1rem;
    }
}

/* =========================================== 
   HIGH DPI / RETINA DISPLAYS
   =========================================== */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* =========================================== 
   PRINT STYLES
   =========================================== */
@media print {
    .navbar,
    .hamburger,
    .search-box,
    .sidebar,
    .footer,
    .share-buttons,
    .btn,
    button {
        display: none !important;
    }
    
    body {
        color: #000;
        background: #fff;
    }
    
    a {
        text-decoration: underline;
    }
    
    .container {
        max-width: 100%;
    }
}

/* =========================================== 
   ACCESSIBILITY - MOTION PREFERENCES
   =========================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* =========================================== 
   DARK MODE PREFERENCE
   =========================================== */
@media (prefers-color-scheme: dark) {
    /* Theme already dark by default */
}

/* =========================================== 
   HOVER CAPABILITY DETECTION
   =========================================== */
@media (hover: none) {
    /* Touch devices - remove hover effects */
    .movie-card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
    
    /* Add active states instead */
    .movie-card:active,
    .btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}
