/* =============================================
   COMPREHENSIVE MOBILE RESPONSIVE DESIGN
   Mobile-First Approach for All Devices
   ============================================= */

/* === GLOBAL MOBILE FIXES === */
@media (max-width: 768px) {

    /* Prevent horizontal scroll */
    html,
    body {
        overflow-x: hidden;
        width: 100%;
    }

    /* Base font size for better readability */
    body {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Container adjustments */
    .container {
        padding: 0 1rem;
        max-width: 100%;
    }

    /* Better tap targets (Apple guideline: 44px minimum) */
    button,
    .btn-primary,
    .btn-secondary,
    a.btn {
        min-height: 48px;
        padding: 0.875rem 1.5rem;
        font-size: 16px;
    }

    /* Smooth scrolling on touch */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* === HEADER & NAVIGATION === */
@media (max-width: 768px) {
    .main-header {
        padding: 0.75rem 0;
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--bg-primary);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .header-content {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
        align-items: center;
        position: relative;
    }

    /* Logo */
    .logo {
        font-size: 1.1rem;
        justify-content: flex-start;
        flex: 1;
    }

    .logo img {
        height: 36px !important;
    }

    /* Search bar goes below logo+hamburger row */
    .search-bar {
        order: 3;
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Search bar full width */
    .search-bar {
        width: 100%;
        order: 2;
    }

    .search-bar input {
        width: 100%;
        font-size: 16px;
        /* Prevent zoom */
        padding: 0.75rem 1rem 0.75rem 2.5rem;
    }

    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: transparent;
        border: none;
        color: var(--text-primary);
        font-size: 1.5rem;
        position: absolute;
        right: 1rem;
        top: 0.5rem;
        z-index: 101;
    }

    /* Sidebar Navigation */
    .header-nav {
        position: fixed;
        top: 0;
        right: -300px;
        width: 280px;
        height: 100vh;
        background: var(--bg-primary);
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        z-index: 1000;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 0;
        overflow-y: auto;
    }

    .header-nav.active {
        right: 0;
    }

    /* Mobile Menu Header inside sidebar */
    .mobile-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1.5rem;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 1rem;
    }

    .mobile-menu-title {
        font-size: 1.25rem;
        font-weight: 800;
        color: var(--text-primary);
    }

    .mobile-menu-close {
        background: transparent;
        border: none;
        font-size: 1.5rem;
        color: var(--text-muted);
        cursor: pointer;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Navigation buttons in sidebar */
    .nav-btn {
        display: flex;
        align-items: center;
        flex-direction: row;
        width: 100%;
        padding: 1rem 1.5rem;
        gap: 1rem;
        font-size: 1.1rem;
        color: var(--text-primary);
        border: none;
        background: transparent;
        text-align: left;
        border-bottom: 1px solid rgba(0,0,0,0.03);
    }

    .nav-btn i {
        font-size: 1.25rem;
        width: 24px;
        color: var(--primary);
    }

    .nav-btn span {
        font-size: 1rem;
        white-space: nowrap;
    }

    .badge {
        position: relative;
        top: auto;
        right: auto;
        margin-left: auto;
        min-width: 24px;
        height: 24px;
        font-size: 0.85rem;
    }

    /* Mobile Menu Overlay */
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(3px);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        display: block;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* === HERO SECTION MOBILE === */
@media (max-width: 768px) {

    /* Switch to single column, text only */
    .hero-section {
        padding: 0;
        min-height: auto;
    }

    .hero-content-wrapper {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 0;
    }

    /* Show the motion gallery on mobile but adapt layout */
    .hero-motion-gallery {
        display: flex !important;
        height: 350px;
        margin-top: 1rem;
        width: 100%;
        overflow: hidden;
        border-radius: 12px;
    }
    
    .gallery-col {
        gap: 0.5rem;
    }
    
    .hero-box {
        height: 160px;
        border-radius: 10px;
    }

    .hero-text {
        padding-right: 0;
        margin-top: 0;
        text-align: left;
    }

    /* Title sizing */
    .hero-title {
        font-size: 2.4rem;
        line-height: 1.15;
        margin-bottom: 0.8rem;
    }

    /* Badge */
    .hero-badge {
        margin-bottom: 0.75rem;
        font-size: 0.75rem;
    }

    /* Description */
    .hero-description {
        font-size: 0.95rem;
        line-height: 1.7;
        margin-bottom: 1.5rem;
    }

    /* Buttons - side by side, full width on very small screens */
    .hero-cta-group {
        flex-direction: row;
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .cta-button {
        flex: 1;
        justify-content: center;
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    /* Features - all 3 in a row */
    .hero-features {
        gap: 1rem;
        flex-wrap: nowrap;
    }

    .hero-feature-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .hf-icon {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .hf-text strong {
        font-size: 0.75rem;
    }

    .hf-text span {
        font-size: 0.65rem;
    }
}

@media (max-width: 400px) {
    .hero-title {
        font-size: 2rem;
    }

    .hero-cta-group {
        flex-direction: column;
    }

    .cta-button {
        width: 100%;
        justify-content: center;
    }

    .hero-features {
        gap: 0.6rem;
    }
}

/* === HERO SLIDER === */
@media (max-width: 992px) {
    .hero-slider-section {
        height: auto;
        min-height: 50vh;
    }

    .poster-slider {
        height: 50vh;
    }

    .poster-item img,
    .poster-item video {
        height: 50vh;
        object-fit: cover;
    }

    .slider-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    .hero-slider-section {
        min-height: 40vh;
    }

    .poster-slider {
        height: 40vh;
    }

    .poster-item img,
    .poster-item video {
        height: 40vh;
    }

    .slider-btn {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .slider-indicators {
        bottom: 0.5rem;
    }

    .indicator {
        width: 8px;
        height: 8px;
    }
}

/* === QUICK ACTIONS === */
@media (max-width: 992px) {
    .quick-actions {
        padding: 1.5rem 1rem;
    }

    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .action-card {
        padding: 1.25rem;
    }

    .action-icon i {
        font-size: 1.75rem;
    }

    .action-content h3 {
        font-size: 1rem;
    }

    .action-content p {
        display: none;
    }
}

@media (max-width: 576px) {
    .quick-actions {
        padding: 1rem;
    }

    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .action-card {
        padding: 1rem;
    }

    .action-icon i {
        font-size: 1.5rem;
    }

    .action-content h3 {
        font-size: 0.9rem;
    }
}

/* === PRODUCTS GRID === */
@media (max-width: 1200px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.25rem;
    }
}

@media (max-width: 992px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .product-card {
        border-width: 1px !important;
    }

    .product-card-header {
        top: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
    }

    .product-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.6rem;
    }

    .wishlist-heart {
        width: 24px;
        height: 24px;
    }

    .wishlist-heart i {
        font-size: 0.65rem;
    }

    .product-image i {
        font-size: 3.5rem;
    }

    .product-info {
        padding: 0.5rem 0.75rem 0.75rem;
    }

    .product-brand {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .product-name {
        font-size: 0.95rem;
        line-height: 1.3;
        margin-bottom: 0.5rem;
    }

    .product-price-label {
        font-size: 0.7rem;
        margin-bottom: 0.2rem;
    }

    .product-price {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    .btn-buy-now {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    .carousel-indicators {
        bottom: 0.75rem;
    }

    .carousel-indicators .dot {
        width: 6px;
        height: 6px;
    }

    .carousel-indicators .dot.active {
        width: 18px;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0 0.75rem;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .product-card {
        border-width: 1px !important;
        border-radius: 0;
    }

    .product-card-header {
        top: 0.4rem;
        left: 0.4rem;
        right: 0.4rem;
    }

    .product-badge {
        padding: 0.2rem 0.4rem;
        font-size: 0.55rem;
    }

    .wishlist-heart {
        width: 22px;
        height: 22px;
    }

    .wishlist-heart i {
        font-size: 0.6rem;
    }

    .product-image i {
        font-size: 2.5rem;
    }

    .product-info {
        padding: 0.4rem 0.6rem 0.6rem;
    }

    .product-brand {
        font-size: 0.7rem;
        margin-bottom: 0.2rem;
    }

    .product-name {
        font-size: 0.85rem;
        line-height: 1.2;
        margin-bottom: 0.4rem;
    }

    .product-price-label {
        font-size: 0.65rem;
        margin-bottom: 0.15rem;
    }

    .product-price {
        font-size: 1rem;
        margin-bottom: 0.6rem;
    }

    .product-price small {
        display: none;
    }

    .btn-buy-now {
        padding: 0.65rem 0.75rem;
        font-size: 0.8rem;
        border-radius: 8px;
    }

    .carousel-indicators {
        bottom: 0.5rem;
        gap: 0.25rem;
    }

    .carousel-indicators .dot {
        width: 5px;
        height: 5px;
    }

    .carousel-indicators .dot.active {
        width: 14px;
    }

    .product-colors {
        margin-top: 0.5rem;
        gap: 0.25rem;
    }

    .color-dot {
        width: 14px;
        height: 14px;
    }
}

/* === CATEGORY SECTIONS === */
@media (max-width: 768px) {
    .product-category {
        padding: 2rem 0;
    }

    .category-header {
        padding: 0 1rem;
        margin-bottom: 1.5rem;
    }

    .category-header h2 {
        font-size: 1.5rem;
    }

    .category-header p {
        font-size: 0.9rem;
    }
}

/* === MODALS - FULL SCREEN ON MOBILE === */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        padding: 1.5rem;
        overflow-y: auto;
    }

    /* Login Modal */
    .login-modal {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    /* Order Modal */
    .order-modal {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        padding: 1rem;
    }

    /* Payment Modal */
    .payment-modal {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    /* Modal Headers */
    .modal-content h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .modal-subtitle {
        font-size: 0.9rem;
    }

    /* Close button larger */
    .modal-close {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
        top: 1rem;
        right: 1rem;
    }
}

@media (max-width: 576px) {
    .modal-content {
        padding: 1rem;
    }

    .modal-content h2 {
        font-size: 1.25rem;
    }
}

/* === FORMS - TOUCH FRIENDLY === */
@media (max-width: 768px) {
    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-group label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.875rem 1rem;
        font-size: 16px;
        /* Prevent zoom */
        border-radius: 8px;
        min-height: 48px;
    }

    .form-group textarea {
        min-height: 120px;
    }

    /* Form rows stack vertically */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-row .form-group {
        width: 100%;
    }

    /* Form actions */
    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }

    .form-actions button {
        width: 100%;
        min-height: 52px;
        font-size: 16px;
    }
}

/* === ORDER FORM SPECIFIC === */
@media (max-width: 768px) {
    .price-summary {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        margin-top: 1.5rem;
        padding: 1.25rem;
    }

    .price-row {
        font-size: 0.95rem;
    }

    .price-row.total {
        font-size: 1.1rem;
    }

    /* Upload area */
    .upload-area {
        padding: 1.5rem;
        min-height: 140px;
    }

    .uploaded-files {
        gap: 0.5rem;
    }
}

/* === WISHLIST === */
@media (max-width: 768px) {
    .wishlist-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem !important;
    }

    .wishlist-item {
        flex-direction: row;
        gap: 1rem;
    }

    .wishlist-item-image {
        width: 100px;
        height: 100px;
    }
}

/* === MY ORDERS === */
@media (max-width: 768px) {
    .my-orders-container {
        padding: 1rem;
    }

    .orders-header h1 {
        font-size: 1.5rem;
    }

    .order-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .order-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .order-id {
        font-size: 0.9rem;
    }

    .order-status {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    .order-details {
        gap: 0.75rem;
    }

    .order-detail-item {
        font-size: 0.9rem;
    }
}

/* === FOOTER === */
@media (max-width: 768px) {
    .main-footer {
        padding: 2rem 0 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 0 1rem;
    }

    .footer-section h3 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    .footer-section p {
        font-size: 0.9rem;
    }

    .social-links {
        gap: 1rem;
    }

    .social-links a {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        padding: 1rem;
        font-size: 0.85rem;
    }
}

/* === ADMIN PANEL RESPONSIVE === */
@media (max-width: 992px) {
    .admin-container {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        position: relative;
        min-height: auto;
    }

    .admin-main {
        margin-left: 0;
        padding: 1rem;
    }

    /* Dashboard stats */
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Admin tables */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 700px;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .admin-main {
        padding: 0.75rem;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 1.25rem;
    }

    /* Section headers */
    .section-header h2 {
        font-size: 1.25rem;
    }

    .section-header .btn-primary {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

/* === CATALOGUE MODAL === */
@media (max-width: 768px) {
    .catalogue-modal {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .catalogues-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .catalogue-card {
        padding: 1.5rem;
    }
}

/* === TOUCH DEVICE OPTIMIZATIONS === */
@media (hover: none) and (pointer: coarse) {

    /* Disable hover effects on touch devices */
    .product-card:hover {
        transform: none;
    }

    .action-card:hover {
        transform: none;
    }

    .btn-primary:hover,
    .btn-secondary:hover {
        transform: none;
    }

    /* Add active states for touch feedback */
    .product-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }

    button:active,
    .btn-primary:active,
    .btn-secondary:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* === LANDSCAPE MOBILE === */
@media (max-width: 896px) and (orientation: landscape) {
    .hero-slider-section {
        min-height: 70vh;
    }

    .poster-slider {
        height: 70vh;
    }

    .actions-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* === TABLET SPECIFIC (577px - 992px) === */
@media (min-width: 577px) and (max-width: 992px) {

    /* Products grid: 3 columns */
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    /* Quick actions: 4 columns */
    .actions-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Modals: 85% width */
    .modal-content {
        width: 90%;
        max-width: 600px;
        height: auto;
        max-height: 90vh;
        border-radius: 16px;
    }

    .login-modal,
    .payment-modal {
        max-width: 500px;
    }
}

/* === LARGE DESKTOP (1200px+) === */
@media (min-width: 1200px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .container {
        max-width: 1320px;
    }
}

@media (min-width: 1400px) {
    .products-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .container {
        max-width: 1400px;
    }
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === PRINT STYLES === */
@media print {

    .main-header,
    .main-footer,
    .modal-overlay,
    .quick-actions,
    .nav-btn,
    button {
        display: none;
    }

    .product-card {
        break-inside: avoid;
    }

    * {
        color: #000 !important;
        background: #fff !important;
    }
}

/* === TABLET (iPad, 769px-1024px) === */
@media (min-width: 769px) and (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .product-card {
        border-width: 2px !important;
    }

    .product-image {
        height: 240px;
    }

    .product-image i {
        font-size: 5rem;
    }

    .product-info {
        padding: 1.1rem 1.25rem 1.35rem;
    }

    .product-name {
        font-size: 1rem;
    }

    .product-price {
        font-size: 1.25rem;
    }

    .btn-buy-now {
        padding: 0.8rem 1.25rem;
        font-size: 0.9rem;
    }
}