/* ==========================================
 * COMPREHENSIVE MOBILE RESPONSIVE STYLES
 * Optimized for all devices (320px - 2560px)
 * ========================================== */

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

/* Prevent zoom on input focus (iOS) */
input, select, textarea {
    font-size: 16px !important; /* Prevents iOS zoom */
}

/* Better text rendering on mobile */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Loading States */
.loading-shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Better Focus Styles for Accessibility */
*:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Improved Transitions */
a, button, .btn, .card, .nav-link {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Better Image Loading */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

img[src=""], img:not([src]) {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Enhanced Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-image {
    height: 200px;
    width: 100%;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
}

/* Mobile-specific toast positioning */
@media (max-width: 768px) {
    .toast-container {
        top: 70px;
        left: 10px;
        right: 10px;
        width: calc(100% - 20px);
    }
    
    .toast {
        max-width: 100%;
    }
}

.toast {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    animation: slideInRight 0.3s ease-out;
    max-width: 350px;
}

.toast.success {
    border-left: 4px solid #27ae60;
}

.toast.error {
    border-left: 4px solid #e74c3c;
}

.toast.warning {
    border-left: 4px solid #f39c12;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Navbar Mobile Improvements */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.2rem !important;
    }

    /* Ensure navbar collapse works properly */
    .navbar-collapse {
        background: rgba(255, 255, 255, 0.98) !important;
        margin-top: 10px;
        border-radius: 10px;
        padding: 15px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
        position: relative;
        z-index: 1000;
    }

    /* Override any conflicting display properties */
    .navbar-collapse.collapse:not(.show) {
        display: none;
    }

    .navbar-collapse.collapsing {
        display: block;
        transition: height 0.35s ease;
        overflow: hidden;
    }

    .navbar-collapse.show {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
    }

    .navbar-nav {
        gap: 5px;
        display: flex !important;
        flex-direction: column !important;
    }

    .navbar-dark .navbar-collapse .nav-link {
        color: #333 !important;
        padding: 12px 15px !important;
        border-radius: 8px;
        display: flex;
        align-items: center;
        transition: all 0.3s ease;
        font-weight: 500;
        margin: 2px 0;
    }

    .navbar-dark .navbar-collapse .nav-link:hover,
    .navbar-dark .navbar-collapse .nav-link.active {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white !important;
    }

    .navbar-dark .navbar-collapse .nav-link i {
        font-size: 1.1rem;
        margin-right: 10px;
        width: 20px;
        text-align: center;
    }

    .navbar-toggler {
        border: 2px solid rgba(255, 255, 255, 0.8);
        padding: 0.5rem;
        background-color: transparent;
    }

    .navbar-toggler-icon {
        width: 1.2rem;
        height: 1.2rem;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.95%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    }

    .navbar-toggler:focus {
        box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
        outline: none;
    }

    .navbar-toggler:not(.collapsed) .navbar-toggler-icon {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.95%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M6 6L24 24M6 24L24 6'/%3e%3c/svg%3e");
    }
}

@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.1rem !important;
    }

    .navbar-collapse {
        padding: 12px;
    }

    .navbar-dark .navbar-collapse .nav-link {
        padding: 10px 12px !important;
        font-size: 0.95rem;
    }

    .navbar-dark .navbar-collapse .nav-link i {
        font-size: 1rem;
    }
}

/* Base Mobile Styles */
@media (max-width: 768px) {
    /* Typography */
    body {
        font-size: 14px;
        line-height: 1.6;
    }

    h1 {
        font-size: 1.75rem !important;
        line-height: 1.3;
    }

    h2 {
        font-size: 1.5rem !important;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.25rem !important;
        line-height: 1.3;
    }

    p {
        line-height: 1.7;
    }

    /* Containers */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Cards */
    .card {
        margin-bottom: 15px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border: none;
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }

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

    .card-body {
        padding: 15px;
    }

    /* Buttons */
    .btn {
        padding: 8px 16px;
        font-size: 14px;
        font-weight: 500;
        border-radius: 8px;
        transition: all 0.3s ease;
    }

    .btn:active {
        transform: scale(0.95);
    }

    .btn-sm {
        padding: 5px 10px;
        font-size: 12px;
    }

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

    table {
        font-size: 13px;
    }

    table th,
    table td {
        padding: 10px 12px;
        border-radius: 8px;
        border: 1px solid #ddd;
        transition: border-color 0.3s ease, box-shadow 0.3s ease;
    }

    .form-control:focus,
    .form-select:focus {
        border-color: #667eea;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }

    .form-label {
        font-weight: 500;
        margin-bottom: 6px;
        color: #333;
        padding: 8px 5px;
    }

    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Modals */
    .modal-dialog {
        margin: 10px;
    }

    .modal-body {
        padding: 15px;
    }

    /* Navigation */
    .navbar-brand {
        font-size: 1.1rem;
    }

    .nav-link {
        padding: 10px 15px;
    }

    /* Sidebar */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 1550;
    }

    .sidebar.show {
        left: 0;
    }

    /* Movie Cards */
    .movie-card {
        margin-bottom: 20px;
    }

    .movie-card img {
        height: auto;
        max-height: 300px;
        object-fit: cover;
    }

    /* Seat Selection */
    .seat {
        width: 30px !important;
        height: 30px !important;
        font-size: 10px !important;
        margin: 2px !important;
    }

    .screen-label {
        font-size: 12px !important;
        padding: 8px !important;
    }

    /* Booking Summary */
    .booking-details {
        font-size: 14px;
    }

    /* Stats Cards */
    .stat-card {
        margin-bottom: 15px;
    }

    .stat-card h3 {
        font-size: 1.5rem !important;
    }

    /* Action Buttons */
    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }

    .action-buttons .btn {
        flex: 1;
        min-width: 45%;
    }

    /* Hide text on small buttons */
    .btn-sm .btn-text {
        display: none;
    }

    /* Pagination */
    .pagination {
        font-size: 14px;
    }

    .page-link {
        padding: 6px 12px;
    }

    /* Search Bars */
    .search-bar {
        margin-bottom: 15px;
    }

    .search-bar input {
        font-size: 16px;
    }

    /* Filters */
    .filter-section {
        margin-bottom: 20px;
    }

    .filter-section select {
        font-size: 16px;
        margin-bottom: 10px;
    }
}

/* Extra Small Devices (phones < 576px) */
@media (max-width: 576px) {
    /* Movie Grid - Single Column */
    .movie-grid {
        grid-template-columns: 1fr !important;
    }

    /* Stats - Full Width */
    .stat-card {
        width: 100%;
    }

    /* Hide certain columns in tables */
    .hide-mobile {
        display: none !important;
    }

    /* Make forms full width */
    .col-md-6,
    .col-lg-4,
    .col-lg-6 {
        width: 100%;
        max-width: 100%;
    }

    /* Seat legend */
    .seat-legend {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .seat-legend-item {
        margin: 5px 0 !important;
    }

    /* Navbar collapse */
    .navbar-collapse {
        background-color: white;
        padding: 15px;
        border-radius: 8px;
        margin-top: 10px;
    }

    /* Image uploads */
    .image-preview {
        max-width: 100%;
    }

    /* Date time inputs */
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        font-size: 16px;
    }

    /* Alert messages */
    .alert {
        font-size: 14px;
        padding: 12px;
    }

    /* Login/Register Forms */
    .login-form-container,
    .register-form-container {
        padding: 20px !important;
    }

    /* Payment Details */
    .payment-summary {
        font-size: 14px;
    }

    .payment-amount {
        font-size: 1.5rem !important;
    }
}

/* Landscape Mobile (small height) */
@media (max-width: 896px) and (orientation: landscape) {
    .modal-dialog {
        max-width: 90%;
    }

    .seat-selection-container {
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .nav-link,
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
    }

    /* Better dropdown spacing */
    .dropdown-item {
        padding: 12px 20px;
    }
}

/* Fix for iOS Safari bottom bar */
@supports (-webkit-touch-callout: none) {
    .min-vh-100 {
        min-height: -webkit-fill-available;
    }
}

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
}

.row {
    margin-left: 0;
    margin-right: 0;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1600;
    width: 45px;
    height: 45px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-size: 20px;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Loading Spinner Mobile */
@media (max-width: 576px) {
    .spinner-border {
        width: 2rem;
        height: 2rem;
    }
}

/* Better spacing for mobile */
@media (max-width: 768px) {
    .mb-4,
    .my-4 {
        margin-bottom: 1.5rem !important;
    }

    .mt-4,
    .my-4 {
        margin-top: 1.5rem !important;
    }

    .p-4 {
        padding: 1.5rem !important;
    }

    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
}

/* Admin Panel Mobile Styles */
@media (max-width: 991px) {
    /* Hide sidebar by default on mobile */
    .sidebar {
        position: fixed;
        left: -250px;
        transition: left 0.3s ease;
        z-index: 2000;
        height: 100vh;
        overflow-y: auto;
    }

    .sidebar.show {
        left: 0;
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.3);
    }

    /* Remove left margin from main content */
    .main-content {
        margin-left: 0 !important;
        padding: 15px;
    }

    /* Mobile menu toggle button */
    .mobile-menu-btn {
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1500;
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
        color: white;
        border: none;
        width: 50px;
        height: 50px;
        border-radius: 10px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
    }

    .sidebar.show + .mobile-menu-btn {
        left: 265px;
    }

    /* Overlay for sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1500;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Keep hamburger button above overlay */
    .mobile-menu-toggle {
        z-index: 1600 !important;
    }

    /* Top bar adjustments */
    .top-bar {
        padding: 15px;
        margin-left: 60px;
        flex-direction: column;
        gap: 10px;
        align-items: flex-start !important;
    }

    .top-bar h3 {
        font-size: 1.3rem;
        margin: 0;
    }

    .top-bar .btn {
        width: 100%;
        margin-top: 10px;
    }

    /* Stat cards - full width on mobile */
    .stat-card {
        padding: 20px;
        margin-bottom: 15px;
    }

    .stat-card h3 {
        font-size: 1.5rem;
    }

    .stat-card p {
        font-size: 0.9rem;
    }

    /* Content cards */
    .content-card {
        padding: 20px;
    }

    /* Admin forms */
    .admin-form .row {
        margin: 0;
    }

    .admin-form .col-md-6,
    .admin-form .col-md-4 {
        padding: 0;
        margin-bottom: 15px;
    }

    /* Admin tables */
    .admin-table {
        font-size: 0.85rem;
    }

    .admin-table th,
    .admin-table td {
        padding: 8px 5px;
    }

    /* Movie/Theatre cards */
    .movie-card,
    .theatre-card,
    .show-card {
        padding: 12px;
    }

    .movie-card img {
        max-width: 100px;
        height: auto;
    }

    /* Action buttons in cards */
    .card-actions .btn {
        padding: 6px 10px;
        font-size: 0.85rem;
        margin: 2px;
    }

    /* Charts */
    canvas {
        max-height: 250px !important;
    }

    /* Modals */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    .modal-body {
        padding: 15px;
    }

    .modal-header,
    .modal-footer {
        padding: 12px 15px;
    }

    /* Sidebar menu items */
    .sidebar-menu a {
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    .sidebar-header h4 {
        font-size: 1.2rem;
    }
}

@media (max-width: 576px) {
    /* Extra small devices */
    .mobile-menu-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }

    .top-bar {
        margin-left: 55px;
        padding: 12px;
    }

    .top-bar h3 {
        font-size: 1.1rem;
    }

    .main-content {
        padding: 10px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card h3 {
        font-size: 1.3rem;
    }

    .stat-card .icon {
        font-size: 2rem;
    }

    .content-card {
        padding: 15px;
    }

    /* Form inputs */
    .form-control,
    .form-select {
        font-size: 16px;
    }

    /* Buttons */
    .btn-admin-primary,
    .btn {
        font-size: 0.9rem;
        padding: 8px 15px;
    }

    /* Sidebar */
    .sidebar {
        width: 220px;
        left: -220px;
    }

    .sidebar.show {
        left: 0;
    }

    .sidebar.show + .mobile-menu-btn {
        left: 235px;
    }

    .sidebar-menu a {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .sidebar-menu i {
        width: 20px;
        font-size: 0.9rem;
    }

    /* Cards */
    .movie-card,
    .theatre-card {
        flex-direction: column;
    }

    .movie-card img {
        max-width: 100%;
        margin-bottom: 10px;
    }

    /* Table actions */
    .table-actions {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .table-actions .btn {
        width: 100%;
    }
}

/* Landscape mobile */
@media (max-width: 896px) and (orientation: landscape) {
    .sidebar {
        width: 200px;
    }

    .stat-card {
        padding: 12px;
    }

    .top-bar {
        padding: 10px;
    }
}
