/**
 * Mobile Enhancements CSS
 * Comprehensive mobile responsiveness for all pages
 */

/* ==========================================
   MOBILE HEADER IMPROVEMENTS
   ========================================== */
@media (max-width: 575.98px) {
    /* Better header structure */
    .main-header .container {
        padding-left: 8px;
        padding-right: 8px;
        max-width: 100%;
    }
    
    .main-header .row {
        margin-left: 0;
        margin-right: 0;
        align-items: center;
    }
    
    .main-header .row > * {
        padding-left: 4px;
        padding-right: 4px;
    }
    
    /* Fix column widths */
    .main-header .col-6:first-child {
        flex: 0 0 auto;
        width: auto;
        max-width: 60%;
    }
    
    .main-header .col-6:last-child {
        flex: 1 1 auto;
        width: auto;
    }
    
    /* Logo column */
    .main-header .col-6:first-child {
        display: flex;
        align-items: center;
    }
    
    /* Logo sizing */
    .logo {
        max-width: 100%;
    }
    
    .logo a {
        font-size: 16px !important;
        gap: 5px;
    }
    
    .logo-image {
        height: 28px !important;
        width: auto;
    }
    
    .logo-text {
        font-size: 16px !important;
        font-weight: 700;
    }
    
    /* Header actions column */
    .main-header .col-6:last-child {
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }
    
    /* Header actions container */
    .header-actions {
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
        gap: 6px !important;
        flex-wrap: nowrap;
        width: 100%;
        padding: 0;
        margin: 0;
    }
    
    /* Action buttons */
    .header-action-btn {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        min-height: 38px !important;
        font-size: 16px !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative;
        flex-shrink: 0;
        background: rgba(44, 95, 45, 0.08) !important;
        border: none !important;
        border-radius: 50% !important;
        color: var(--text-dark);
        transition: all 0.2s ease;
    }
    
    .header-action-btn:active,
    .header-action-btn:focus {
        background: var(--primary-color) !important;
        color: white !important;
    }
    
    .header-action-btn i {
        font-size: 16px;
    }
    
    /* Badge positioning */
    .badge-count,
    .cart-count,
    .wishlist-count {
        position: absolute;
        top: -4px;
        right: -4px;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        font-size: 11px;
        line-height: 18px;
        background: #dc3545;
        color: white;
        border-radius: 9px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        z-index: 1;
    }
    
    /* Hide user dropdown toggle */
    .dropdown-toggle-icon {
        display: none !important;
    }
    
    /* User dropdown wrapper */
    .user-dropdown-wrapper {
        position: relative;
    }
    
    /* Mobile menu toggle */
    .mobile-menu-toggle {
        order: 5;
        margin-left: 4px;
    }
    
    /* Hide search on mobile */
    .search-toggle {
        display: none !important;
    }
    
    /* Top bar adjustments */
    .top-bar {
        padding: 6px 0;
        font-size: 11px;
    }
    
    .promo-text {
        font-size: 11px !important;
        line-height: 1.3;
    }
    
    .promo-text span {
        font-size: 11px !important;
    }
    
    .signup-link {
        font-size: 11px !important;
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .header-actions {
        gap: 10px;
    }
    
    .header-action-btn {
        width: 38px;
        height: 38px;
    }
}

/* ==========================================
   MOBILE NAVIGATION IMPROVEMENTS
   ========================================== */
@media (max-width: 991.98px) {
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    .mobile-nav {
        left: -320px;
        width: 320px;
    }
    
    .mobile-nav.active {
        left: 0;
    }
    
    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 9998;
    }
    
    .mobile-nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* ==========================================
   SHOP PAGE MOBILE
   ========================================== */
@media (max-width: 991.98px) {
    /* Filter sidebar as mobile drawer */
    .filter-sidebar, .glass-filter-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 300px;
        height: 100vh;
        background: white;
        z-index: 9999;
        transition: left 0.3s ease;
        overflow-y: auto;
        padding: 20px;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    
    .filter-sidebar.active, .glass-filter-sidebar.active {
        left: 0;
    }
    
    /* Filter toggle button */
    .shop-toolbar::before {
        content: '';
        display: block;
    }
    
    .filter-toggle-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 10px 20px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 14px;
        margin-bottom: 15px;
        cursor: pointer;
    }
    
    .result-count {
        font-size: 13px;
    }
    
    .shop-actions select {
        font-size: 14px;
        padding: 8px 12px;
    }
}

@media (max-width: 767.98px) {
    .shop-toolbar {
        padding: 15px;
    }
    
    .shop-toolbar .row {
        gap: 15px;
    }
    
    .shop-toolbar .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .shop-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .shop-actions select {
        flex: 1;
    }
}

/* ==========================================
   PRODUCT DETAIL MOBILE
   ========================================== */
@media (max-width: 991.98px) {
    .product-name {
        font-size: 28px;
    }
    
    .current-price {
        font-size: 28px;
    }
    
    .original-price {
        font-size: 18px;
    }
    
    .product-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .product-actions .btn {
        width: 100%;
    }
    
    .quantity-selector {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 767.98px) {
    .product-gallery {
        margin-bottom: 30px;
    }
    
    .product-name {
        font-size: 24px;
    }
    
    .current-price {
        font-size: 24px;
    }
    
    .product-tabs .nav-tabs {
        flex-direction: column;
        border: none;
    }
    
    .product-tabs .nav-item {
        width: 100%;
    }
    
    .product-tabs .nav-link {
        border: 1px solid var(--border-color);
        margin-bottom: 5px;
        border-radius: 8px !important;
    }
    
    .product-tab-content {
        margin-top: 15px;
    }
    
    .variant-options {
        justify-content: flex-start;
    }
    
    .variant-option {
        padding: 8px 16px;
        font-size: 14px;
    }
}

/* ==========================================
   CART PAGE MOBILE
   ========================================== */
@media (max-width: 991.98px) {
    .cart-summary {
        position: static;
        margin-top: 30px;
    }
}

@media (max-width: 767.98px) {
    /* Stack cart table on mobile */
    .cart-table table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .cart-table thead {
        display: none;
    }
    
    .cart-table tbody,
    .cart-table tr,
    .cart-table td {
        display: block;
        width: 100%;
    }
    
    .cart-item {
        border: 1px solid var(--border-color);
        border-radius: 12px;
        margin-bottom: 15px;
        padding: 15px !important;
        background: white;
    }
    
    .cart-item td {
        border: none !important;
        padding: 8px 0 !important;
        text-align: left !important;
        position: relative;
    }
    
    .cart-item td::before {
        content: attr(data-label);
        font-weight: 600;
        display: inline-block;
        width: 100px;
        color: var(--text-dark);
    }
    
    .cart-product-info {
        flex-direction: row !important;
        align-items: center !important;
        gap: 15px;
    }
    
    .cart-product-image {
        width: 80px !important;
        height: 80px !important;
    }
    
    .quantity-selector {
        display: inline-flex;
        margin-left: 100px;
    }
    
    .remove-cart-item {
        position: absolute;
        top: 15px;
        right: 15px;
    }
    
    .coupon-section {
        padding: 15px;
    }
    
    .coupon-section .input-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .coupon-section .input-group .btn {
        width: 100%;
    }
}

/* ==========================================
   CHECKOUT PAGE MOBILE
   ========================================== */
@media (max-width: 991.98px) {
    .order-summary {
        position: static;
        margin-top: 30px;
    }
}

@media (max-width: 767.98px) {
    .checkout-section {
        padding: 20px 15px;
    }
    
    .address-option {
        padding: 12px;
        margin-bottom: 10px;
    }
    
    .address-option label {
        font-size: 14px;
        line-height: 1.6;
    }
    
    .payment-option {
        padding: 12px;
        margin-bottom: 10px;
    }
    
    .payment-option label {
        font-size: 14px;
    }
}

/* ==========================================
   MY ACCOUNT PAGE MOBILE
   ========================================== */
@media (max-width: 991.98px) {
    .account-sidebar {
        margin-bottom: 30px;
    }
    
    .account-nav {
        display: flex;
        flex-direction: column;
    }
}

@media (max-width: 767.98px) {
    .account-nav {
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        gap: 10px;
        padding-bottom: 10px;
    }
    
    .account-nav-link {
        flex: 0 0 auto;
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-card h4 {
        font-size: 24px;
    }
    
    .order-item {
        padding: 15px;
    }
    
    .order-details {
        flex-direction: column;
        gap: 10px;
    }
}

/* ==========================================
   FOOTER MOBILE
   ========================================== */
@media (max-width: 767.98px) {
    .footer-widget {
        margin-bottom: 30px;
        text-align: center;
    }
    
    .footer-widget ul {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .payment-methods {
        justify-content: center;
    }
}

/* ==========================================
   PAGE HEADERS MOBILE
   ========================================== */
@media (max-width: 767.98px) {
    .page-header {
        padding: 40px 0 30px;
    }
    
    .page-title {
        font-size: 28px;
    }
    
    .page-subtitle {
        font-size: 14px;
    }
}

/* ==========================================
   PRODUCT GRID MOBILE
   ========================================== */
@media (max-width: 575.98px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .product-card {
        border-radius: 12px;
    }
    
    .product-title {
        font-size: 14px;
    }
    
    .product-category {
        font-size: 11px;
    }
    
    .product-price {
        font-size: 15px;
    }
    
    .add-to-cart-btn {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .product-action-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }
}

/* Single column for very small devices */
@media (max-width: 359.98px) {
    .product-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
        padding: 10px;
    }
    
    .product-card {
        max-width: 100%;
    }
    
    .product-title {
        font-size: 14px;
    }
    
    .product-price {
        font-size: 16px;
    }
}

/* ==========================================
   FORMS MOBILE
   ========================================== */
@media (max-width: 767.98px) {
    .form-control, .form-select, .glass-input {
        font-size: 15px;
        padding: 12px 15px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    .btn-lg {
        padding: 14px 24px;
        font-size: 16px;
    }
}

/* ==========================================
   MODALS MOBILE
   ========================================== */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-content {
        border-radius: 16px;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* ==========================================
   TABLES MOBILE
   ========================================== */
@media (max-width: 767.98px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: 14px;
    }
    
    .table td, .table th {
        padding: 10px 8px;
    }
}

/* ==========================================
   WISHLIST MOBILE
   ========================================== */
@media (max-width: 767.98px) {
    .wishlist-item {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }
    
    .wishlist-item-image {
        margin: 0 auto 15px;
    }
    
    .wishlist-item-details {
        width: 100%;
    }
    
    .wishlist-item-actions {
        width: 100%;
        justify-content: center;
        margin-top: 15px;
        flex-direction: column;
        gap: 10px;
    }
    
    .wishlist-item-actions .btn {
        width: 100%;
    }
}

/* ==========================================
   BLOG PAGES MOBILE
   ========================================== */
@media (max-width: 991.98px) {
    .blog-sidebar {
        margin-top: 40px;
    }
}

@media (max-width: 767.98px) {
    .blog-card {
        margin-bottom: 20px;
    }
    
    .blog-title {
        font-size: 20px;
    }
    
    .blog-excerpt {
        font-size: 14px;
    }
}

/* ==========================================
   CONTACT PAGE MOBILE
   ========================================== */
@media (max-width: 767.98px) {
    .contact-info-card {
        margin-bottom: 20px;
        padding: 20px;
    }
    
    .contact-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

/* ==========================================
   ABOUT PAGE MOBILE
   ========================================== */
@media (max-width: 767.98px) {
    .about-section {
        padding: 40px 0;
    }
    
    .team-member {
        margin-bottom: 30px;
    }
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */
@media (max-width: 767.98px) {
    .mobile-hidden {
        display: none !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
    
    .mobile-text-center {
        text-align: center !important;
    }
    
    .mobile-mb-3 {
        margin-bottom: 1rem !important;
    }
}

/* ==========================================
   TOUCH OPTIMIZATIONS
   ========================================== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn, .header-action-btn, .product-action-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Remove hover states that don't work on touch */
    .product-card:hover {
        transform: none;
    }
    
    .product-actions {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==========================================
   LANDSCAPE ORIENTATION
   ========================================== */
@media (max-width: 991.98px) and (orientation: landscape) {
    .page-header {
        padding: 30px 0 20px;
    }
    
    .mobile-nav,
    .filter-sidebar,
    .glass-filter-sidebar {
        width: 280px;
    }
}

/* ==========================================
   ADMIN DASHBOARD MOBILE
   ========================================== */
@media (max-width: 991.98px) {
    .admin-sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s ease;
    }
    
    .admin-sidebar.active {
        left: 0;
    }
    
    .admin-content {
        margin-left: 0 !important;
    }
    
    .mobile-sidebar-toggle {
        display: block !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 9998;
        background: var(--primary-color);
        color: white;
        width: 44px;
        height: 44px;
        border-radius: 8px;
        border: none;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
}

@media (max-width: 767.98px) {
    .stat-card {
        margin-bottom: 15px;
    }
    
    .stat-card h3 {
        font-size: 24px;
    }
    
    .chart-container {
        height: 250px !important;
    }
    
    .admin-table {
        font-size: 13px;
    }
    
    .admin-table td,
    .admin-table th {
        padding: 8px 5px;
    }
}

/* ==========================================
   PERFORMANCE OPTIMIZATIONS
   ========================================== */
@media (max-width: 767.98px) {
    /* Disable expensive animations on mobile */
    .glass-card,
    .glass-product-card,
    .glass-button {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    
    /* Simplify shadows on mobile */
    .box-shadow-lg {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */
@media (max-width: 767.98px) {
    /* Ensure text is readable */
    body {
        font-size: 15px;
    }
    
    /* Larger tap targets */
    a, button, input[type="submit"], input[type="button"] {
        min-height: 44px;
    }
    
    /* Increase line height for readability */
    p, li {
        line-height: 1.6;
    }
}
