/* ==========================================
 * ENHANCED MOBILE RESPONSIVENESS
 * Additional mobile optimizations
 * ========================================== */

/* ==================== Container Optimizations ==================== */
@media (max-width: 1200px) {
    .container-modern {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

@media (max-width: 768px) {
    .container-modern {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .container,
    .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }
}

@media (max-width: 576px) {
    .container-modern {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* ==================== Typography Scaling ==================== */
@media (max-width: 768px) {
    h1, .hero-title {
        font-size: 2rem !important;
    }
    
    h2 {
        font-size: 1.75rem !important;
    }
    
    h3 {
        font-size: 1.5rem !important;
    }
    
    h4 {
        font-size: 1.25rem !important;
    }
    
    h5 {
        font-size: 1.1rem !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
    }
    
    p {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    h1, .hero-title {
        font-size: 1.75rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
    }
    
    h3 {
        font-size: 1.3rem !important;
    }
}

/* ==================== Hero Section Mobile ==================== */
@media (max-width: 768px) {
    .hero-section {
        padding: 3rem 0 2rem !important;
        min-height: 250px !important;
    }
    
    .hero-content {
        text-align: center;
        padding: 0 1rem;
    }
}

@media (max-width: 480px) {
    .hero-section {
        padding: 2rem 0 1.5rem !important;
        min-height: 200px !important;
    }
}

/* ==================== Cards Mobile Optimization ==================== */
@media (max-width: 768px) {
    .card-modern, .movie-card-modern {
        margin-bottom: 1rem;
    }
    
    .movie-poster {
        height: 300px;
    }
    
    .card-modern-body,
    .movie-info {
        padding: 1rem;
    }
    
    .card-modern-header {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .movie-poster {
        height: 250px;
    }
    
    .movie-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
}

/* ==================== Movie Grid Responsive ==================== */
.movies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .movies-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .movies-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* ==================== Search Bar Mobile ==================== */
@media (max-width: 768px) {
    .search-bar-modern {
        margin: -2rem 1rem 1.5rem;
        padding: 1.5rem 1rem;
    }
    
    .search-input-modern {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .search-input-modern input {
        width: 100%;
    }
    
    .search-input-modern button {
        width: 100%;
    }
    
    .search-input-modern i {
        position: absolute;
        left: 1rem;
        top: 1rem;
    }
    
    .search-input-modern input {
        padding-left: 2.5rem;
    }
}

/* ==================== Filter Chips Mobile ==================== */
@media (max-width: 768px) {
    .filter-chips {
        overflow-x: auto;
        overflow-y: hidden;
        display: flex;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .filter-chip {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
    
    /* Hide scrollbar but keep functionality */
    .filter-chips::-webkit-scrollbar {
        height: 3px;
    }
}

/* ==================== Button Optimizations ==================== */
@media (max-width: 768px) {
    .btn-modern,
    .btn-primary-modern,
    .btn-secondary-modern {
        padding: 0.65rem 1.25rem;
        font-size: 0.95rem;
    }
    
    .btn-lg-modern {
        padding: 0.875rem 1.75rem;
        font-size: 1rem;
    }
    
    .btn-block-modern {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .btn-modern {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

/* ==================== Form Elements Mobile ==================== */
@media (max-width: 768px) {
    .form-control-modern,
    .form-control,
    .form-select {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 0.75rem;
    }
    
    .form-group-modern {
        margin-bottom: 1.25rem;
    }
    
    .form-label-modern {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }
}

/* ==================== Table Responsive ==================== */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    th, td {
        padding: 0.5rem !important;
        white-space: nowrap;
    }
    
    /* Card-style table rows on mobile */
    .table-mobile-card {
        display: block;
    }
    
    .table-mobile-card thead {
        display: none;
    }
    
    .table-mobile-card tbody,
    .table-mobile-card tr {
        display: block;
        margin-bottom: 1rem;
    }
    
    .table-mobile-card tr {
        background: white;
        border-radius: 8px;
        padding: 1rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .table-mobile-card td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0 !important;
        border: none !important;
        white-space: normal;
    }
    
    .table-mobile-card td:before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 1rem;
        color: var(--gray);
    }
}

/* ==================== Seat Selection Mobile ==================== */
@media (max-width: 768px) {
    .seat-layout {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 1rem 0;
    }
    
    .seat {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
        margin: 2px;
    }
    
    .screen {
        font-size: 0.875rem;
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .seat-legend {
        flex-wrap: wrap;
        gap: 0.75rem;
        justify-content: center;
    }
    
    .legend-item {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .seat {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
        margin: 1px;
    }
}

/* ==================== Booking Summary Mobile ==================== */
@media (max-width: 768px) {
    .booking-summary-card {
        position: relative;
        margin-top: 1rem;
    }
    
    .sticky-booking-summary {
        position: sticky;
        bottom: 0;
        z-index: 100;
        background: white;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        padding: 1rem;
        border-radius: 12px 12px 0 0;
    }
}

/* ==================== Modal Mobile ==================== */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0 !important;
    }
    
    /* Full-screen modal on mobile */
    .modal-fullscreen-mobile {
        padding: 0 !important;
    }
    
    .modal-fullscreen-mobile .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }
    
    .modal-fullscreen-mobile .modal-content {
        height: 100%;
        border-radius: 0;
    }
}

/* ==================== Navigation Offcanvas ==================== */
@media (max-width: 768px) {
    .offcanvas {
        max-width: 85%;
    }
    
    .offcanvas-body {
        padding: 1rem;
    }
    
    .offcanvas-header {
        padding: 1rem;
        border-bottom: 1px solid #eee;
    }
}

/* ==================== Movie Details Page Mobile ==================== */
@media (max-width: 768px) {
    .movie-details-hero {
        min-height: auto !important;
        padding: 2rem 0 !important;
    }
    
    .movie-details-content {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .movie-details-poster {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }
    
    .movie-details-info {
        text-align: center;
    }
    
    .movie-meta {
        justify-content: center;
    }
    
    .shows-container {
        padding: 1rem;
    }
    
    .theatre-card {
        padding: 1rem;
    }
    
    .show-times {
        gap: 0.5rem;
    }
    
    .show-time-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* ==================== Profile Page Mobile ==================== */
@media (max-width: 768px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
    }
    
    .profile-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .profile-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ==================== Bookings Page Mobile ==================== */
@media (max-width: 768px) {
    .booking-card {
        flex-direction: column;
    }
    
    .booking-poster {
        width: 100%;
        max-width: 200px;
        margin: 0 auto 1rem;
    }
    
    .booking-info {
        text-align: center;
    }
    
    .booking-actions {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .booking-actions .btn {
        width: 100%;
    }
}

/* ==================== Admin Dashboard Mobile ==================== */
@media (max-width: 991px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .chart-container {
        padding: 1rem;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
    }
}

/* ==================== Admin Forms Mobile ==================== */
@media (max-width: 768px) {
    .admin-form .row > [class*='col-'] {
        margin-bottom: 1rem;
    }
    
    .form-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .image-upload-preview {
        max-width: 100%;
        height: auto;
    }
}

/* ==================== Security Dashboard Mobile ==================== */
@media (max-width: 768px) {
    .security-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .security-card {
        padding: 1rem;
    }
    
    .log-container {
        max-height: 400px;
        font-size: 0.85rem;
    }
    
    .log-entry {
        padding: 8px;
        font-size: 0.8rem;
    }
    
    .filter-container {
        flex-direction: column;
    }
    
    .filter-container select,
    .filter-container button {
        width: 100%;
    }
}

/* ==================== Payment Page Mobile ==================== */
@media (max-width: 768px) {
    .payment-methods {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .payment-method-card {
        padding: 1rem;
    }
    
    .payment-summary {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        margin: 0 -1rem;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    }
}

/* ==================== Touch Improvements ==================== */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch target sizes */
    button, a, .btn, .nav-link, .filter-chip {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects on touch devices */
    .card:hover,
    .btn:hover,
    .movie-card-modern:hover {
        transform: none;
    }
    
    /* Better active states for touch */
    button:active,
    .btn:active,
    a:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* ==================== Loading States Mobile ==================== */
@media (max-width: 768px) {
    .loading-container {
        min-height: 200px;
    }
    
    .spinner-border {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .skeleton-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .skeleton-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== Footer Mobile ==================== */
@media (max-width: 768px) {
    .footer {
        padding: 2rem 1rem;
        text-align: center;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 1rem;
    }
    
    .footer-social {
        justify-content: center;
    }
}

/* ==================== Fixed Bottom Actions (Mobile floating action button) ==================== */
@media (max-width: 768px) {
    .mobile-bottom-action {
        position: fixed;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        z-index: 1000;
        background: white;
        padding: 1rem;
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    }
}

/* ==================== Landscape Orientation ==================== */
@media (max-width: 896px) and (orientation: landscape) {
    .hero-section {
        min-height: 200px !important;
        padding: 1.5rem 0 !important;
    }
    
    .modal-body {
        max-height: 60vh;
    }
    
    .seat-layout {
        max-height: 50vh;
    }
}

/* ==================== Extra Small Devices (320px) ==================== */
@media (max-width: 375px) {
    body {
        font-size: 14px;
    }
    
    .container-modern {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    h1 {
        font-size: 1.5rem !important;
    }
    
    .btn-modern {
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
    }
    
    .card-modern {
        padding: 0.75rem;
    }
}

/* ==================== Safe Area Insets (for iPhone notch, etc.) ==================== */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .navbar-modern,
    .modal-content,
    .offcanvas {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .mobile-bottom-action,
    .sticky-booking-summary {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* ==================== Print Styles ==================== */
@media print {
    .navbar-modern,
    .sidebar,
    .mobile-menu-toggle,
    .mobile-bottom-action,
    .filter-chips,
    .search-bar-modern,
    button:not(.no-print) {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .container-modern {
        max-width: 100%;
    }
}

/* ==================== Progressive Web App Support ==================== */
@media all and (display-mode: standalone) {
    /* App is installed as PWA */
    .install-prompt {
        display: none;
    }
    
    body {
        padding-top: max(0px, env(safe-area-inset-top));
    }
}

/* ==================== Accessibility Improvements ==================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-width: 2px !important;
    }
    
    .btn-modern,
    .card-modern {
        border: 2px solid currentColor !important;
    }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
}
