/* =============================================
   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: column;
        gap: 0.75rem;
        padding: 0 1rem;
    }

    /* Logo */
    .logo {
        font-size: 1.25rem;
        justify-content: center;
    }

    .logo img {
        height: 32px !important;
    }

    /* 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;
    }

    /* Navigation buttons */
    .header-nav {
        display: flex;
        justify-content: space-around;
        width: 100%;
        order: 3;
        gap: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-btn {
        flex: 1;
        min-width: 80px;
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.25rem;
        font-size: 0.75rem;
    }

    .nav-btn i {
        font-size: 1.25rem;
    }

    .nav-btn span {
        font-size: 0.7rem;
        white-space: nowrap;
    }

    .badge {
        position: absolute;
        top: 0.25rem;
        right: 0.25rem;
        min-width: 18px;
        height: 18px;
        font-size: 0.7rem;
        padding: 0 0.3rem;
    }
}

/* === 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(3, 1fr);
        gap: 1.25rem;
    }
}

@media (max-width: 992px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .product-card {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .product-card {
        border-width: 2px !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: 32px;
        height: 32px;
    }

    .wishlist-heart i {
        font-size: 0.9rem;
    }

    .product-image {
        height: 220px;
    }

    .product-image img {
        object-fit: cover !important;
    }

    .product-image i {
        font-size: 3.5rem;
    }

    .product-info {
        padding: 1rem 1rem 1.25rem;
    }

    .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: 1.5px !important;
        border-radius: 16px;
    }

    .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: 28px;
        height: 28px;
    }

    .wishlist-heart i {
        font-size: 0.8rem;
    }

    .product-image {
        height: 200px;
    }

    .product-image img {
        object-fit: cover !important;
    }

    .product-image i {
        font-size: 2.5rem;
    }

    .product-info {
        padding: 0.75rem 0.75rem 1rem;
    }

    .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;
    }
}