/* Responsive Fixes for FMovies Clone */

/* Base responsive settings */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

/* Ensure proper display at all sizes */
.row > * {
    flex-shrink: 0;
    max-width: 100%;
}

/* Container fixes */
.container,
.container-fluid,
.container-xxxl {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

/* Row and column fixes */
.row {
    display: flex;
    flex-wrap: wrap;
}

.row > * {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
}

/* Grid columns for mobile */
.col-6 {
    flex: 0 0 auto;
    width: 50%;
}

/* Movie card container fixes */
.movie-card {
    display: block;
    width: 100%;
    height: auto;
}

/* Poster container - Default (Desktop) */
.movie-poster {
    position: relative;
    width: 100%;
    overflow: visible !important;
    background-color: #2a2d35;
    border-radius: 8px;
}

/* Poster image - Default (Desktop) - FORCE DISPLAY */
.movie-poster img,
.movie-poster {
    width: 100% !important;
    height: auto !important;
    display: block !important;
    object-fit: cover;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
}

/* Override for TMDB containers */
#movies-container .movie-poster,
#tvshows-container .movie-poster,
#top-imdb-container .movie-poster {
    padding-bottom: 0 !important;
    height: auto !important;
}

#movies-container .movie-poster img,
#tvshows-container .movie-poster img,
#top-imdb-container .movie-poster img {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Movie info section */
.movie-info {
    margin-top: 0.5rem;
    padding: 0 0.25rem;
}

.movie-title {
    font-size: 0.875rem;
    line-height: 1.3;
    margin-bottom: 0.25rem;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.movie-year {
    font-size: 0.75rem;
    color: #8e95a5;
    margin: 0;
}

/* Overlay with rating */
.movie-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.movie-card:hover .movie-overlay {
    opacity: 1;
}

.rating {
    background: rgba(255, 193, 7, 0.9);
    color: #000;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

/* Mobile devices (portrait) - 320px to 575px */
@media (max-width: 575px) {
    .container,
    .container-fluid,
    .container-xxxl {
        padding-right: 10px;
        padding-left: 10px;
    }
    
    .row.g-3 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }
    
    .col-6 {
        width: 50% !important;
    }
    
    .movie-card {
        margin-bottom: 0.5rem;
    }
    
    /* MOBILE ONLY: Fixed aspect ratio poster */
    .movie-poster {
        position: relative;
        width: 100%;
        padding-bottom: 0 !important; /* REMOVED: was 150% */
        overflow: visible !important;
        border-radius: 6px;
    }
    
    /* FORCE TMDB images to show on mobile */
    .movie-poster img,
    #movies-container .movie-poster img,
    #tvshows-container .movie-poster img,
    #top-imdb-container .movie-poster img {
        position: relative !important; /* CHANGED from absolute */
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        object-fit: cover;
        object-position: center;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .movie-title {
        font-size: 0.7rem;
        line-height: 1.2;
    }
    
    .movie-year {
        font-size: 0.65rem;
    }
    
    .rating {
        font-size: 0.65rem;
        padding: 2px 6px;
    }
    
    .movie-info {
        margin-top: 0.35rem;
        padding: 0 0.15rem;
    }
    
    /* Section titles */
    .fs-5 {
        font-size: 1rem !important;
    }
    
    /* Card spacing */
    .card.mb-4 {
        margin-bottom: 1.5rem !important;
    }
}

/* Small tablets (portrait) - 576px to 767px */
@media (min-width: 576px) and (max-width: 767px) {
    .col-sm-4 {
        flex: 0 0 auto;
        width: 33.333333% !important;
    }
    
    /* Tablet: Also use fixed aspect ratio */
    .movie-poster {
        position: relative;
        width: 100%;
        padding-bottom: 0 !important; /* REMOVED: was 150% */
        overflow: visible !important;
    }
    
    .movie-poster img,
    #movies-container .movie-poster img,
    #tvshows-container .movie-poster img,
    #top-imdb-container .movie-poster img {
        position: relative !important; /* CHANGED from absolute */
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        object-fit: cover;
        object-position: center;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .movie-title {
        font-size: 0.8rem;
    }
    
    .movie-year {
        font-size: 0.7rem;
    }
}

/* Tablets (portrait) - 768px to 991px */
@media (min-width: 768px) and (max-width: 991px) {
    .col-md-3 {
        flex: 0 0 auto;
        width: 25% !important;
    }
    
    /* Tablet portrait: Fixed aspect ratio */
    .movie-poster {
        position: relative;
        width: 100%;
        padding-bottom: 0 !important; /* REMOVED: was 150% */
        overflow: visible !important;
    }
    
    .movie-poster img,
    #movies-container .movie-poster img,
    #tvshows-container .movie-poster img,
    #top-imdb-container .movie-poster img {
        position: relative !important; /* CHANGED from absolute */
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        object-fit: cover;
        object-position: center;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .movie-title {
        font-size: 0.85rem;
    }
    
    .movie-year {
        font-size: 0.75rem;
    }
}

/* Tablets (landscape) and small desktops - 992px to 1199px */
@media (min-width: 992px) and (max-width: 1199px) {
    .col-lg-2 {
        flex: 0 0 auto;
        width: 16.666667% !important;
    }
    
    /* Desktop: Use fixed aspect ratio for consistency */
    .movie-poster {
        position: relative;
        width: 100%;
        padding-bottom: 0 !important;
        overflow: visible !important;
    }
    
    .movie-poster img,
    #movies-container .movie-poster img,
    #tvshows-container .movie-poster img,
    #top-imdb-container .movie-poster img {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        object-fit: cover;
        object-position: center;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* Medium desktops - 1200px and up */
@media (min-width: 1200px) {
    /* Ensure 6 columns on large screens */
    .col-lg-2 {
        flex: 0 0 auto;
        width: 16.666667% !important;
    }
    
    /* Desktop: Use fixed aspect ratio for consistency */
    .movie-poster {
        position: relative;
        width: 100%;
        padding-bottom: 0 !important;
        overflow: visible !important;
    }
    
    .movie-poster img,
    #movies-container .movie-poster img,
    #tvshows-container .movie-poster img,
    #top-imdb-container .movie-poster img {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        object-fit: cover;
        object-position: center;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .movie-title {
        font-size: 0.9rem;
    }
    
    .movie-year {
        font-size: 0.8rem;
    }
}

/* Large desktops - 1400px and up */
@media (min-width: 1400px) {
    .movie-title {
        font-size: 0.95rem;
    }
}

/* Extra large desktops - 1600px and up */
@media (min-width: 1600px) {
    .movie-title {
        font-size: 1rem;
    }
}

/* Landscape mode fixes for mobile */
@media (max-width: 991px) and (orientation: landscape) {
    .movie-poster {
        padding-bottom: 145%;
    }
}

/* Fix for very small screens */
@media (max-width: 360px) {
    .movie-title {
        font-size: 0.65rem;
    }
    
    .movie-year {
        font-size: 0.6rem;
    }
    
    .col-6 {
        padding: 0 0.2rem;
    }
}

/* Ensure images never overflow */
img {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

/* Override Bootstrap img-fluid if needed */
.img-fluid {
    max-width: 100%;
    height: auto;
}

/* Link fixes */
a {
    text-decoration: none;
    color: inherit;
}

a:hover {
    text-decoration: none;
}

/* Remove any unwanted margins on mobile */
@media (max-width: 575px) {
    .mb-3 {
        margin-bottom: 0.5rem !important;
    }
    
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    .py-3 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}
