/* ========================================
   MOBILE RESPONSIVE OPTIMIZATION
   Enhanced mobile styles for all devices
   ======================================== */

/* Mobile First - Base styles for all mobile devices */
@media (max-width: 991px) {
    /* Container adjustments */
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    /* Typography */
    h1 { font-size: 28px !important; }
    h2 { font-size: 24px !important; }
    h3 { font-size: 20px !important; }
    h4 { font-size: 18px !important; }
    
    /* Spacing */
    section {
        padding: 40px 0 !important;
    }
}

/* Tablet - Medium devices (768px - 991px) */
@media (max-width: 991px) and (min-width: 768px) {
    /* Header adjustments */
    .header-search {
        max-width: 400px;
    }
    
    .trust-badges {
        gap: 12px;
    }
    
    .trust-item {
        font-size: 11px;
    }
}

/* Mobile - Small devices (480px - 767px) */
@media (max-width: 767px) {
    /* Remove container padding on mobile for full width */
    .header-top .container {
        padding: 0;
    }
    
    /* Header top - Clean 3-row layout */
    .header-top {
        padding: 0.75rem 0;
        border-bottom: 1px solid #e9ecef;
    }
    
    .header-top-content {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        gap: 0;
        align-items: center;
        padding: 0;
    }
    
    /* Row 1: Logo (left) + Hotline + Cart (right) */
    .header-logo {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        justify-self: start;
        padding-left: 1rem;
    }
    
    .header-logo .brand-logo {
        height: 85px;
        width: auto;
    }
    
    .header-contact {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        justify-self: end;
        padding-right: 1rem;
    }
    
    .hotline-info {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
        padding: 0.6rem 1rem;
        border-radius: 25px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    }
    
    .hotline-info i {
        font-size: 1.2rem;
        color: white;
        min-width: 20px;
    }
    
    .hotline-text {
        display: flex;
        flex-direction: column;
        gap: 0.1rem;
    }
    
    .hotline-label {
        font-size: 9px;
        color: rgba(255,255,255,0.85);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }
    
    .hotline-number {
        font-size: 14px;
        font-weight: 700;
        color: white;
        letter-spacing: 0.3px;
    }
    
    .header-cart .cart-btn {
        width: 48px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        position: relative;
    }
    
    .header-cart .cart-btn i {
        font-size: 1.3rem;
        color: var(--primary-color);
    }
    
    .cart-count {
        top: -5px;
        right: -5px;
        font-size: 11px;
        min-width: 20px;
        height: 20px;
        padding: 0 5px;
    }
    
    /* Row 2: Search area container - FULL WIDTH parent */
    .header-search {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
        max-width: 100%;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 0;
        margin: 0;
    }
    
    /* Brand slogan - show FIRST (order: 1) - FULL WIDTH */
    .brand-slogan {
        order: 1;
        display: block !important;
        text-align: center;
        padding: 0.75rem 1rem;
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
        border-radius: 0;
        margin: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .brand-slogan::before {
        display: none !important;
    }
    
    /* Search box - show SECOND (order: 2) */
    .search-box {
        order: 2;
        width: 100%;
        position: relative;
        padding: 0.75rem 1rem 0.5rem 1rem;
        box-sizing: border-box;
        margin: 0;
    }
    
    .slogan-text {
        display: block;
        font-size: 13px;
        font-weight: 700;
        color: white;
        margin-bottom: 0.25rem;
        letter-spacing: 0.5px;
        text-shadow: none;
    }
    
    .slogan-subtitle {
        display: block;
        font-size: 11px;
        color: rgba(255,255,255,0.95);
        font-weight: 500;
        line-height: 1.4;
    }
    
    .search-input {
        width: 100%;
        padding: 14px 55px 14px 18px;
        font-size: 14px;
        border-radius: 8px;
        border: 2px solid #ddd;
    }
    
    .search-btn {
        padding: 14px 18px;
        border-radius: 0 8px 8px 0;
        right: 0;
    }
    
    /* Hide trust badges on mobile */
    .trust-badges {
        display: none !important;
    }
    
    /* Mobile menu toggle - ẨN cái ở header-top */
    .header-top-content .mobile-menu-toggle {
        display: none !important;
    }
    
    /* Remove container padding for nav */
    .header-nav .container {
        padding: 0;
        max-width: 100%;
    }
    
    /* Header nav - professional mobile */
    .header-nav {
        padding: 0.5rem 1rem;
        background: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        position: sticky;
        top: 0;
        z-index: 100;
        margin-top: 0;
    }
    
    .nav-layout {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 0.5rem;
        align-items: stretch;
        padding: 0;
        width: 100%;
    }
    
    /* Tạo hamburger menu toggle MỚI - BÊN TRÁI */
    .nav-layout .mobile-menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        background: white;
        border: 2px solid var(--primary-color);
        border-radius: 0;
        padding: 10px 12px;
        cursor: pointer;
        transition: all 0.3s ease;
        width: auto;
        height: auto;
        flex-shrink: 0;
        grid-column: 1;
    }
    
    .mobile-menu-toggle span {
        display: block;
        width: 24px;
        height: 3px;
        background: var(--primary-color);
        border-radius: 2px;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle:hover {
        background: var(--primary-color);
    }
    
    .mobile-menu-toggle:hover span {
        background: white;
    }
    
    /* Mobile menu overlay - show on mobile */
    .mobile-menu {
        display: block;
    }
    
    /* Category menu - takes remaining space - BÊN PHẢI */
    .category-menu-left {
        padding-left: 0;
        display: flex !important; /* Override navigation.css hiding */
        align-items: stretch;
        grid-column: 2;
    }
    
    .category-toggle {
        width: 100%;
        padding: 12px 16px;
        font-size: 14px;
        font-weight: 700;
        border-radius: 0;
        background: linear-gradient(135deg, #d32f2f 0%, #c62828 100%);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        box-shadow: none;
        transition: all 0.3s ease;
        margin: 0;
    }
    
    .category-toggle:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 14px rgba(211, 47, 47, 0.4);
    }
    
    .category-toggle i:first-child {
        font-size: 16px;
        display: none;
    }
    
    .category-toggle i:last-child {
        font-size: 13px;
        margin-left: 0.25rem;
    }
    
    .category-toggle span {
        letter-spacing: 0.6px;
        font-size: 13px;
        font-weight: 700;
        text-transform: uppercase;
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .category-dropdown {
        width: 100%;
        left: 0;
        max-height: 70vh;
        overflow-y: auto;
        border-radius: 10px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    }
    
    /* Hide desktop menu on mobile */
    .main-nav.desktop-only {
        display: none;
    }
    
    /* Navigation mobile */
    .header-nav {
        padding: 8px 0;
    }
    
    .category-toggle {
        font-size: 13px;
        padding: 8px 16px;
    }
    
    /* Product cards mobile - 2 COLUMNS like Tiki */
    .products-grid,
    .featured-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        padding: 0 8px;
    }
    
    .product-card {
        margin-bottom: 0;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .product-image {
        padding-top: 100%;
        border-radius: 8px 8px 0 0;
    }
    
    .product-info {
        padding: 8px;
    }
    
    .product-title {
        font-size: 13px !important;
        line-height: 1.3;
        height: 34px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        margin-bottom: 4px;
    }
    
    .price-container {
        margin: 4px 0;
    }
    
    .price-current {
        font-size: 15px !important;
        font-weight: 700;
    }
    
    .price-old {
        font-size: 11px;
    }
    
    .discount-badge {
        font-size: 10px;
        padding: 2px 4px;
    }
    
    .product-rating {
        font-size: 11px;
        margin: 4px 0;
    }
    
    .product-actions {
        padding: 8px;
        gap: 6px;
    }
    
    .btn-add-cart,
    .btn-buy-now {
        font-size: 12px;
        padding: 8px 12px;
        border-radius: 4px;
    }
    
    /* Product detail mobile */
    .product-detail-section {
        padding: 20px 0 !important;
    }
    
    .product-detail-layout {
        grid-template-columns: 1fr !important;
        gap: 24px;
    }
    
    .product-gallery {
        height: 300px !important;
    }
    
    .product-detail-title {
        font-size: 20px !important;
    }
    
    .product-price {
        font-size: 24px !important;
    }
    
    .product-quantity {
        width: 100%;
    }
    
    .product-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .btn-buy,
    .btn-contact {
        width: 100%;
        justify-content: center;
    }
    
    /* Footer mobile */
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 0;
    }
    
    .footer-col {
        text-align: left;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding: 0;
    }
    
    .footer-col:last-child {
        border-bottom: none;
    }
    
    /* Footer accordion style - click to expand */
    .footer-col h4 {
        padding: 16px 20px;
        margin: 0;
        cursor: pointer;
        position: relative;
        font-size: 15px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .footer-col h4::after {
        content: '\f078';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 12px;
        transition: transform 0.3s ease;
    }
    
    .footer-col.active h4::after {
        transform: rotate(180deg);
    }
    
    /* Hide content by default on mobile */
    .footer-col ul,
    .footer-col p,
    .footer-col .footer-contact,
    .footer-col .social-links-footer {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        padding: 0 20px;
    }
    
    .footer-col.active ul,
    .footer-col.active p,
    .footer-col.active .footer-contact,
    .footer-col.active .social-links-footer {
        max-height: 500px;
        padding: 0 20px 16px 20px;
    }
    
    .footer-col ul {
        margin: 0;
    }
    
    .footer-col ul li {
        margin-bottom: 10px;
        font-size: 14px;
    }
    
    /* Logo section - always visible */
    .footer-col:first-child h4::after {
        display: none;
    }
    
    .footer-col:first-child {
        cursor: default;
    }
    
    .footer-logo {
        justify-content: flex-start;
        padding: 16px 20px;
    }
    
    .footer-logo img {
        max-width: 120px;
    }
    
    .footer-col:first-child p {
        max-height: none;
        padding: 0 20px 16px 20px;
        overflow: visible;
        font-size: 13px;
        line-height: 1.6;
    }
    
    .social-links-footer {
        justify-content: flex-start;
        padding: 0 20px 16px 20px !important;
        max-height: none !important;
    }
    
    .social-links-footer a {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    /* Footer bottom */
    .footer-bottom {
        padding: 16px 20px;
        font-size: 12px;
        text-align: center;
    }
    
    .footer-bottom-content {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 6px;
    }
    
    /* Back to top mobile */
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: 20px;
        left: 20px;
        font-size: 18px;
    }
    
    /* Floating social mobile */
    .floating-social-container {
        right: 16px;
        bottom: 16px;
    }
    
    .floating-social-toggle {
        width: 50px;
        height: 50px;
    }
}

/* Mobile - Extra small devices (320px - 479px) */
@media (max-width: 479px) {
    /* Header ultra compact */
    .header-logo {
        margin-bottom: 8px;
    }
    
    .brand-logo {
        max-width: 70px !important;
    }
    
    .mobile-menu-toggle {
        width: 32px;
        height: 32px;
    }
    
    .hotline-number {
        font-size: 13px;
    }
    
    /* Search compact */
    .search-input {
        font-size: 13px;
        padding: 8px 40px 8px 12px;
        height: 36px;
    }
    
    .search-btn {
        padding: 6px 10px;
    }
    
    /* Product grid - KEEP 2 COLUMNS on small mobile like Tiki */
    .products-grid,
    .featured-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
        padding: 0 6px;
    }
    
    .product-card {
        max-width: 100%;
    }
    
    .product-info {
        padding: 6px;
    }
    
    .product-title {
        font-size: 12px !important;
        height: 32px;
    }
    
    .price-current {
        font-size: 14px !important;
    }
    
    .product-actions {
        padding: 6px;
    }
    
    .btn-add-cart,
    .btn-buy-now {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    /* Typography smaller */
    h1 { font-size: 24px !important; }
    h2 { font-size: 20px !important; }
    h3 { font-size: 18px !important; }
    h4 { font-size: 16px !important; }
    
    /* Buttons full width */
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Product detail ultra compact */
    .product-gallery {
        height: 250px !important;
    }
    
    .product-detail-title {
        font-size: 18px !important;
    }
    
    .product-price {
        font-size: 22px !important;
    }
    
    /* Footer compact */
    .footer-col h4 {
        font-size: 16px;
    }
    
    .footer-col ul li {
        font-size: 13px;
    }
    
    /* Back to top smaller */
    .back-to-top {
        width: 40px;
        height: 40px;
        bottom: 16px;
        left: 16px;
        font-size: 16px;
    }
}

/* Landscape orientation optimization */
@media (max-height: 600px) and (orientation: landscape) {
    .header-top {
        padding: 8px 0;
    }
    
    .header-nav {
        padding: 6px 0;
    }
    
    section {
        padding: 30px 0 !important;
    }
    
    .product-gallery {
        height: 60vh !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets */
    .btn,
    button,
    a {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Disable hover effects on touch */
    .product-card:hover {
        transform: none;
    }
    
    /* Better tap feedback */
    .btn:active,
    button:active {
        transform: scale(0.98);
    }
}

/* Safe area insets for notched devices (iPhone X+) */
@supports (padding: max(0px)) {
    .header-top,
    .header-nav,
    .footer-new {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    
    .back-to-top {
        bottom: max(20px, env(safe-area-inset-bottom));
        left: max(20px, env(safe-area-inset-left));
    }
    
    .floating-social-container {
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
    }
}
