/**
 * MOBILE ENHANCEMENTS
 * Additional responsive improvements and mobile-first utilities
 */

/* ====================================================
   MOBILE NAVIGATION ENHANCEMENTS
   ==================================================== */
.mobile-menu-toggle {
    position: relative;
    z-index: 1001;
    transition: transform 0.3s ease;
}

.mobile-menu-toggle.active {
    transform: rotate(90deg);
}

.mobile-menu-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--dark-text);
    z-index: 10;
}

@media (max-width: 992px) {
    .nav-menu.mobile-active .mobile-menu-close {
        display: block;
    }
}

/* ====================================================
   MOBILE SEARCH ENHANCEMENTS
   ==================================================== */
@media (max-width: 768px) {
    .search-overlay .search-container {
        width: 95%;
        padding: 0 10px;
    }
    
    .search-overlay .search-form-main {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .search-overlay .search-input {
        width: 100%;
        border-radius: var(--radius-md);
    }
    
    .search-overlay .btn {
        width: 100%;
        border-radius: var(--radius-md);
    }
}

/* ====================================================
   MOBILE PRODUCT CARDS - LIST VIEW
   ==================================================== */
@media (max-width: 768px) {
    .products-grid.list-view .product-card {
        display: grid;
        grid-template-columns: 120px 1fr;
        gap: 1rem;
        padding: 1rem;
    }
    
    .products-grid.list-view .product-image-wrapper {
        height: 120px;
        border-radius: var(--radius-md);
    }
    
    .products-grid.list-view .product-info {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding: 0;
    }
    
    .products-grid.list-view .product-actions-bottom {
        margin-top: auto;
    }
    
    .products-grid.list-view .product-actions-bottom .btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }
    
    .products-grid.list-view .product-badge {
        top: 8px;
        right: 8px;
        font-size: 0.65rem;
        padding: 4px 8px;
    }
    
    .products-grid.list-view .product-actions {
        display: none; /* Hide quick actions on mobile list view */
    }
}

/* ====================================================
   MOBILE FILTER SIDEBAR
   ==================================================== */
@media (max-width: 992px) {
    .filter-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        box-shadow: none;
    }
    
    .filter-sidebar.active {
        left: 0;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.3);
    }
    
    .filter-close {
        display: block;
    }
    
    .filter-toggle {
        display: inline-flex;
    }
    
    /* Add backdrop */
    .filter-sidebar.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 100%;
        width: calc(100vw - 320px);
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
}

/* ====================================================
   MOBILE CART IMPROVEMENTS
   ==================================================== */
@media (max-width: 768px) {
    .cart-item {
        border-radius: var(--radius-md);
        background: var(--white);
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    .cart-items-wrapper {
        padding: 0.5rem;
        background: transparent;
    }
    
    .cart-summary {
        position: static;
        margin-top: 0;
    }
    
    .quantity-control {
        justify-content: flex-start;
        margin: 0.75rem 0;
    }
    
    .item-actions {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--gray-200);
    }
}

/* ====================================================
   MOBILE CHECKOUT IMPROVEMENTS
   ==================================================== */
@media (max-width: 768px) {
    .checkout-card {
        padding: 1.5rem 1rem;
        margin-bottom: 1rem;
    }
    
    .payment-options {
        gap: 0.75rem;
    }
    
    .payment-option {
        padding: 0.875rem;
    }
    
    .payment-option label {
        font-size: 0.9rem;
    }
    
    .form-row {
        gap: 0.75rem;
    }
}

/* ====================================================
   MOBILE ADMIN DASHBOARD
   ==================================================== */
@media (max-width: 992px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .admin-sidebar.active {
        transform: translateX(0);
    }
    
    .stat-card {
        padding: 1.5rem;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-details h3 {
        font-size: 1.5rem;
    }
    
    .admin-topbar {
        padding: 1rem;
    }
    
    .topbar-right {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 0.5rem;
    }
}

/* ====================================================
   TOUCH-FRIENDLY IMPROVEMENTS
   ==================================================== */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .product-card:hover {
        transform: none;
    }
    
    .product-actions {
        opacity: 1;
        transform: translateX(0);
    }
    
    .action-btn {
        background: rgba(255, 255, 255, 0.9);
    }
    
    /* Make touch targets larger */
    .action-btn,
    .quantity-btn,
    .nav-icon,
    .filter-close,
    .mobile-menu-toggle {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover underlines on links */
    a {
        text-decoration: none;
    }
    
    /* Prevent accidental double-tap zoom */
    a, button, input, select, textarea {
        touch-action: manipulation;
    }
}

/* ====================================================
   HORIZONTAL SCROLL CONTAINERS
   ==================================================== */
.mobile-scroll-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-orange) var(--gray-200);
    gap: 1rem;
    padding: 1rem 0;
}

.mobile-scroll-container::-webkit-scrollbar {
    height: 6px;
}

.mobile-scroll-container::-webkit-scrollbar-track {
    background: var(--gray-200);
    border-radius: 3px;
}

.mobile-scroll-container::-webkit-scrollbar-thumb {
    background: var(--primary-orange);
    border-radius: 3px;
}

.mobile-scroll-container > * {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

@media (max-width: 768px) {
    .pillars,
    .gallery {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 1rem;
        padding: 1rem 0;
    }
    
    .pillar,
    .gallery .item {
        flex: 0 0 280px;
        scroll-snap-align: start;
    }
}

/* ====================================================
   MOBILE TYPOGRAPHY REFINEMENTS
   ==================================================== */
@media (max-width: 576px) {
    .page-title {
        font-size: 1.5rem;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .card-text {
        font-size: 0.875rem;
        line-height: 1.5;
    }
    
    p {
        line-height: 1.6;
    }
}

/* ====================================================
   MOBILE FORM IMPROVEMENTS
   ==================================================== */
@media (max-width: 576px) {
    .form-control,
    .form-select,
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .form-label {
        margin-bottom: 0.375rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group .form-control,
    .input-group .btn {
        border-radius: var(--radius-md) !important;
    }
    
    .input-group .btn {
        margin-top: 0.5rem;
    }
}

/* ====================================================
   MOBILE MODAL IMPROVEMENTS
   ==================================================== */
@media (max-width: 768px) {
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
}

/* ====================================================
   MOBILE UTILITY CLASSES
   ==================================================== */
@media (max-width: 768px) {
    .mobile-hide {
        display: none !important;
    }
    
    .mobile-show {
        display: block !important;
    }
    
    .mobile-text-center {
        text-align: center !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
    
    .mobile-no-padding {
        padding: 0 !important;
    }
    
    .mobile-no-margin {
        margin: 0 !important;
    }
    
    .mobile-stack {
        flex-direction: column !important;
    }
    
    .mobile-gap-sm {
        gap: 0.5rem !important;
    }
}

/* Desktop only classes */
@media (min-width: 769px) {
    .desktop-hide {
        display: none !important;
    }
}

/* ====================================================
   MOBILE NOTIFICATION/TOAST POSITION
   ==================================================== */
@media (max-width: 576px) {
    .toast {
        width: calc(100% - 20px);
        max-width: none;
        left: 10px;
        right: 10px;
        top: 10px;
    }
    
    .toast.show {
        right: 10px;
    }
    
    .alert {
        width: calc(100% - 20px);
        right: 10px;
        left: 10px;
    }
}

/* ====================================================
   MOBILE IMAGE GALLERY
   ==================================================== */
@media (max-width: 768px) {
    .product-image-gallery {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    
    .product-image-gallery img {
        flex: 0 0 100%;
        scroll-snap-align: center;
    }
    
    .gallery-thumbnails {
        display: flex;
        justify-content: center;
        gap: 0.5rem;
        margin-top: 0.75rem;
    }
    
    .gallery-thumbnails button {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--gray-400);
        border: none;
        padding: 0;
    }
    
    .gallery-thumbnails button.active {
        background: var(--primary-orange);
    }
}

/* ====================================================
   MOBILE ACCORDION/COLLAPSIBLE
   ==================================================== */
@media (max-width: 768px) {
    .collapse-on-mobile {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .collapse-on-mobile.open {
        max-height: 1000px;
    }
    
    .collapse-toggle {
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .collapse-toggle::after {
        content: '\f078';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        transition: transform 0.3s ease;
    }
    
    .collapse-toggle.open::after {
        transform: rotate(180deg);
    }
}

/* ====================================================
   SAFE AREA INSETS (iPhone X+)
   ==================================================== */
@supports (padding: env(safe-area-inset-bottom)) {
    .navbar {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .footer {
        padding-bottom: calc(3rem + env(safe-area-inset-bottom));
    }
    
    .whatsapp-float {
        bottom: calc(30px + env(safe-area-inset-bottom));
        right: calc(30px + env(safe-area-inset-right));
    }
    
    .scroll-to-top {
        bottom: calc(100px + env(safe-area-inset-bottom));
        right: calc(30px + env(safe-area-inset-right));
    }
}

/* ====================================================
   MOBILE SKELETON LOADING
   ==================================================== */
.skeleton {
    background: linear-gradient(90deg, 
        var(--gray-200) 25%, 
        var(--gray-100) 50%, 
        var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.skeleton-image {
    width: 100%;
    height: 200px;
    border-radius: var(--radius-md);
}

/* ====================================================
   PWA INSTALLATION PROMPT (Mobile)
   ==================================================== */
.pwa-install-prompt {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background: var(--white);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    padding: 1.5rem;
    z-index: 9999;
    transition: bottom 0.3s ease;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

.pwa-install-prompt.show {
    bottom: 0;
}

.pwa-install-prompt .btn-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

/* ====================================================
   MOBILE PERFORMANCE: WILL-CHANGE
   ==================================================== */
@media (max-width: 768px) {
    .mobile-menu-toggle,
    .nav-menu,
    .filter-sidebar,
    .mobile-menu-overlay {
        will-change: transform, opacity;
    }
}
