/* ================================================================
   GOLDEN CINEMA — MOBILE RESPONSIVE STYLES
   Covers: Navbar, Movies Index, Movie Show, Booking, Admin, Manager
   Breakpoints: 576px (xs), 768px (sm/md), 992px (md/lg)
   ================================================================ */

/* ================================================================
   GLOBAL RESETS & BASE
   ================================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
    min-height: 100dvh;
}

/* Body top padding — accounts for fixed navbar */
#cinema-body {
    padding-top: 90px;
}

@media (max-width: 768px) {
    #cinema-body {
        padding-top: 56px;
    }
}

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

/* ================================================================
   NAVBAR — MOBILE FIXES
   ================================================================ */
@media (max-width: 768px) {

    /* Shrink nav height on small screens */
    nav .flex.items-center.justify-between.h-16 {
        height: 56px !important;
    }

    body.font-sans {
        padding-top: 56px !important;
    }

    /* Logo size on mobile */
    nav .logo img,
    nav img[alt="Logo"] {
        height: 40px !important;
    }

    /* Hide text labels in nav on small screens, keep icons */
    nav span.font-semibold {
        display: none !important;
    }

    /* Logout / Login / Register buttons icon-only */
    nav button svg,
    nav a svg {
        width: 22px !important;
        height: 22px !important;
    }

    /* Search box — full width on mobile */
    #searchBox {
        width: calc(100vw - 16px) !important;
        left: 8px !important;
        right: 8px !important;
        transform: none !important;
        top: 56px !important;
    }

    /* Theaters dropdown — full width on mobile */
    #theatersBox {
        width: calc(100vw - 16px) !important;
        left: 8px !important;
        right: 8px !important;
        transform: none !important;
        top: 56px !important;
    }

    /* Mobile side menu — full width on very small screens */
    .mobile-menu {
        width: 80% !important;
        max-width: 320px;
    }

    /* Login modal — full width on small screens */
    #loginModal>div {
        width: 95vw !important;
        max-width: 100% !important;
        margin: 20px auto !important;
        top: 10px !important;
    }
}

@media (max-width: 480px) {

    /* Stack nav right-side buttons tightly */
    nav .flex.items-center.gap-4 {
        gap: 8px !important;
    }

    /* Profile icon smaller */
    nav a[id="profileLink"] svg {
        width: 20px !important;
        height: 20px !important;
    }
}

/* ================================================================
   MOVIES INDEX PAGE
   ================================================================ */
@media (max-width: 768px) {

    /* Container padding */
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Swiper carousel height - cover film poster fully on mobile */
    .movie-swiper .swiper-slide img {
        height: 480px !important;
        object-fit: cover !important;
        object-position: center top !important;
        border-radius: 12px;
    }

    .movie-swiper {
        padding: 0 !important;
        margin: 16px 0 !important;
    }

    /* Swiper nav buttons smaller */
    .movie-swiper .swiper-button-next,
    .movie-swiper .swiper-button-prev {
        width: 30px !important;
        height: 30px !important;
    }

    .movie-swiper .swiper-button-next::after,
    .movie-swiper .swiper-button-prev::after {
        font-size: 12px !important;
    }

    /* Filter section — wrap nicely on mobile */
    .filter-section .d-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    .button-group {
        margin-inline-start: 0 !important;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .category-select {
        width: 100%;
        margin: 0 !important;
    }

    .category-options {
        width: 100% !important;
    }

    /* Movies grid — 2 columns on mobile */
    .movies-grid>div {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 4px !important;
    }

    .movie-card {
        border-radius: 10px;
    }

    .movie-card .movie-img,
    .movie-card img {
        height: 200px;
        object-fit: cover;
        border-radius: 10px 10px 0 0;
    }

    .card-body h5,
    .card-title {
        font-size: 0.85rem !important;
        margin-bottom: 4px !important;
    }

    .card-body .badge {
        font-size: 0.7rem !important;
    }
}

@media (max-width: 400px) {

    /* 1 column on very tiny screens */
    .movies-grid>div {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .movie-card .movie-img,
    .movie-card img {
        height: 240px;
    }
}

/* ================================================================
   MOVIE SHOW / DETAIL PAGE
   ================================================================ */
@media (max-width: 768px) {

    /* Stack poster + info vertically */
    .movie-details .row {
        flex-direction: column !important;
    }

    .movie-details .col-md-4,
    .movie-details .col-md-8 {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
    }

    .movie-image img {
        max-height: 400px;
        width: auto;
        margin: 0 auto;
        display: block;
    }

    .movie-title {
        font-size: 1.5rem !important;
        margin-top: 1rem;
    }

    .movie-meta {
        font-size: 0.9rem !important;
    }

    .movie-summary {
        font-size: 0.95rem !important;
        padding: 0 !important;
    }

    /* Trailer section */
    .trailer-section {
        padding: 1rem !important;
        border-radius: 10px;
    }

    .trailer-container {
        max-width: 100% !important;
    }

    .no-trailer-container {
        padding: 1.5rem !important;
        min-height: 160px !important;
    }

    /* Showtimes — stack to 1 column */
    .showtimes-list .row>div {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 1rem;
    }

    .date-header {
        font-size: 1.1rem !important;
    }

    .showtime-badge {
        font-size: 0.8rem !important;
        padding: 4px 10px !important;
    }

    /* Related movies slider — make scrollable */
    .related-movies-slider {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 12px;
        padding-bottom: 10px;
    }

    .related-movies-slider .movie-card {
        flex: 0 0 160px !important;
        min-width: 160px !important;
        scroll-snap-align: start;
    }

    .related-movies-slider .movie-card img {
        height: 220px;
        object-fit: cover;
        width: 100%;
        border-radius: 8px 8px 0 0;
    }

    .related-movies h2 {
        font-size: 1.2rem !important;
    }
}

/* ================================================================
   BOOKING / SEAT SELECTION PAGE
   ================================================================ */
@media (max-width: 768px) {
    .container.mt-5 {
        margin-top: 1rem !important;
        padding: 0 8px !important;
    }

    .card.shadow-lg {
        padding: 12px !important;
        border-radius: 10px;
    }

    /* Movie title / subtitle */
    .card-title.text-center.mb-4 {
        font-size: 1.3rem !important;
    }

    .card-subtitle {
        font-size: 0.9rem !important;
    }

    /* Seat grid — reduce seat size on mobile */
    .seat {
        width: 28px !important;
        height: 28px !important;
        margin: 3px !important;
        font-size: 0.65rem !important;
        border-radius: 4px !important;
    }

    .row-label {
        width: 22px !important;
        font-size: 0.75rem !important;
    }

    /* Seat selection area */
    .seat-selection-area {
        padding: 12px !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .theater-layout {
        min-width: max-content;
        margin: 0 auto;
    }

    /* Seat legend — wrap tightly */
    .seat-legend {
        gap: 10px !important;
        justify-content: center;
    }

    .legend-item {
        font-size: 0.75rem !important;
    }

    /* Confirm button */
    #confirm-booking-btn {
        max-width: 100% !important;
        font-size: 1rem !important;
        padding: 12px !important;
    }

    /* Screen image */
    .screen-display img {
        width: 100% !important;
    }

    h3.text-center {
        font-size: 1rem !important;
    }
}

@media (max-width: 480px) {

    /* Even smaller seats on phones */
    .seat {
        width: 24px !important;
        height: 24px !important;
        margin: 2px !important;
        font-size: 0.6rem !important;
    }

    .row-label {
        width: 18px !important;
        font-size: 0.65rem !important;
    }
}

/* ================================================================
   CLIENT BOOKINGS / PROFILE PAGES
   ================================================================ */
@media (max-width: 768px) {

    /* My Bookings list */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* Profile modal */
    #profileModal>div,
    .profile-modal-content {
        width: 95vw !important;
        max-width: 100% !important;
        margin: 20px auto !important;
        padding: 16px !important;
    }
}

/* ================================================================
   REGISTER MODAL
   ================================================================ */
@media (max-width: 768px) {
    #registerModal>div {
        width: 95vw !important;
        max-width: 100% !important;
        margin: 20px auto !important;
        top: 10px !important;
        padding: 16px !important;
    }
}

/* ================================================================
   ADMIN & MANAGER PANELS — SIDEBAR + CONTENT
   ================================================================ */
@media (max-width: 992px) {

    /* Admin/Manager sidebar collapse */
    .sidebar,
    [class*="sidebar"],
    nav.sidebar {
        width: 100% !important;
        position: static !important;
        height: auto !important;
    }

    /* Main content full width when sidebar collapses */
    .main-content,
    [class*="main-content"],
    main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Admin tables */
    .table-responsive,
    .overflow-x-auto {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Admin forms */
    .form-group,
    .mb-4 {
        margin-bottom: 12px !important;
    }

    /* Admin cards / stats */
    .grid.grid-cols-4,
    .grid.grid-cols-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 576px) {

    /* Admin stats — 1 column */
    .grid.grid-cols-4,
    .grid.grid-cols-3,
    .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }

    /* Dashboard numbers */
    .stat-card,
    [class*="stat-card"] {
        padding: 12px !important;
    }

    .stat-number,
    [class*="stat-number"] {
        font-size: 1.5rem !important;
    }

    /* Admin forms — full width inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    textarea,
    select {
        width: 100% !important;
        font-size: 16px !important;
        /* Prevent iOS zoom on focus */
    }
}

/* ================================================================
   MANAGER LAYOUT (Bootstrap-based admin panel)
   ================================================================ */
@media (max-width: 768px) {

    /* Manager nav/sidebar */
    .manager-nav,
    #manager-sidebar {
        position: fixed !important;
        left: -100% !important;
        transition: left 0.3s ease !important;
        z-index: 1050 !important;
        width: 260px !important;
    }

    .manager-nav.open,
    #manager-sidebar.open {
        left: 0 !important;
    }

    /* Manager content */
    #manager-content,
    .manager-content {
        margin-left: 0 !important;
        padding: 12px !important;
    }

    /* Manager tables */
    .manager-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Manager dashboard cards — 2 per row */
    .manager-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Buttons row in manager forms */
    .form-actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px;
    }

    .form-actions .btn,
    .form-actions button {
        width: 100% !important;
    }
}

/* ================================================================
   UTILITY: PREVENT OVERFLOW EVERYWHERE
   ================================================================ */
.container,
.row,
section,
article,
main {
    max-width: 100%;
}

/* Overflow-x scroll for all Bootstrap rows */
@media (max-width: 576px) {
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    [class*="col-"] {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}

/* ================================================================
   TOUCH UX IMPROVEMENTS
   ================================================================ */
/* Larger tap targets */
@media (max-width: 768px) {

    a,
    button,
    [role="button"] {
        min-height: 36px;
    }

    /* Better tap highlight */
    a:active,
    button:active {
        opacity: 0.7;
    }

    /* Badges readable on mobile */
    .badge {
        font-size: 0.75rem !important;
        padding: 4px 8px !important;
    }

    /* Cards hover effect removed on mobile (no hover) */
    .movie-card:hover {
        transform: none !important;
    }

    /* Smoother scrolling areas */
    .related-movies-slider,
    .seat-selection-area,
    .table-responsive {
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 158, 27, 0.5) transparent;
    }

    .related-movies-slider::-webkit-scrollbar,
    .seat-selection-area::-webkit-scrollbar,
    .table-responsive::-webkit-scrollbar {
        height: 4px;
    }

    .related-movies-slider::-webkit-scrollbar-thumb,
    .seat-selection-area::-webkit-scrollbar-thumb,
    .table-responsive::-webkit-scrollbar-thumb {
        background: rgba(255, 158, 27, 0.5);
        border-radius: 4px;
    }
}

/* ================================================================
   SWIPER (used on index hero)
   ================================================================ */
@media (max-width: 480px) {

    .swiper-button-next,
    .swiper-button-prev {
        display: none !important;
        /* swipe gesture on mobile */
    }

    .swiper-pagination {
        bottom: 5px !important;
    }
}

/* ================================================================
   TYPOGRAPHY — Scale down on small screens
   ================================================================ */
@media (max-width: 576px) {
    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    h3 {
        font-size: 1.1rem !important;
    }

    h4 {
        font-size: 1rem !important;
    }

    h5 {
        font-size: 0.95rem !important;
    }

    .movie-details .movie-title {
        font-size: 1.4rem !important;
    }
}

/* ================================================================
   FOOTER (if exists)
   ================================================================ */
@media (max-width: 768px) {
    footer {
        text-align: center !important;
        padding: 20px 12px !important;
    }

    footer .row {
        flex-direction: column !important;
        gap: 16px;
    }

    footer [class*="col-"] {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ================================================================
   MOBILE MENU — ensure it slides in correctly
   ================================================================ */
.mobile-menu {
    transition: transform 0.3s ease !important;
}

/* Overlay when mobile menu is open */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-menu-overlay.active {
    display: block;
}

/* ================================================================
   PAYMENT PAGE
   ================================================================ */
@media (max-width: 768px) {

    .payment-form,
    [class*="payment"] .card {
        padding: 16px !important;
    }

    .payment-summary {
        font-size: 0.9rem !important;
    }
}

/* ================================================================
   SAFE AREA INSETS (for iOS notch/home bar)
   ================================================================ */
@supports (padding: max(0px)) {
    nav {
        padding-left: max(16px, env(safe-area-inset-left)) !important;
        padding-right: max(16px, env(safe-area-inset-right)) !important;
    }

    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ================================================================
   ADMIN NAV — specific fixes for the Alpine.js nav
   ================================================================ */
@media (max-width: 768px) {

    /* Show the admin logo smaller */
    nav .logo img {
        height: 36px !important;
        width: auto !important;
    }

    /* Admin/manager nav — make hamburger always visible */
    nav #list {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px;
        padding: 8px !important;
    }

    /* Stack nav links vertically on mobile for admin */
    nav div[id="list"] a {
        display: block !important;
        padding: 8px 12px !important;
        font-size: 0.9rem !important;
    }

    /* Manager header nav2 */
    #nav2 {
        flex-direction: column !important;
        gap: 8px !important;
        padding: 12px !important;
    }
}

/* ================================================================
   MANAGER NAV (uses different classes)
   ================================================================ */
@media (max-width: 992px) {

    /* Manager nav links wrap */
    nav.manager-nav-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .manager-nav-links {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 4px;
        padding: 4px;
    }

    .manager-nav-links a {
        white-space: nowrap;
        padding: 6px 10px !important;
        font-size: 0.85rem !important;
    }
}

/* ================================================================
   INDEX PAGE — fix container on small screens
   ================================================================ */
@media (max-width: 576px) {
    /* Cards touch-friendly */
    .movie-card {
        cursor: pointer;
    }

    /* Fix filter row overflow */
    .filter-section {
        overflow-x: hidden;
    }

    .filter-section .row {
        margin: 0;
    }

    /* Fix badge overflow on movie cards */
    .movie-card .badge {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}