/**
 * Responsive Styles for Tuson Web
 * Mobile-first responsive utilities
 * Inspired by WeChat Mini Program design
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --primary: #1a365d;
    --secondary: #c9a227;
    --accent: #2c5282;
    --gold: #d4af37;
    --background: #f7f7f7;
    --textDark: #1a202c;
    --textLight: #718096;
    --textGray: #4a5568;
}

/* ============================================
   MOBILE NAVIGATION
   ============================================ */
.mobile-menu {
    display: none;
}

/* Hide mobile-only elements on desktop by default */
.mobile-menu-overlay,
.mobile-menu-panel {
    display: none;
}

@media (max-width: 1024px) {
    .desktop-nav {
        display: none !important;
    }

    .mobile-menu {
        display: block;
    }

    .mobile-menu-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 100;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .mobile-menu-panel {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        background: white;
        z-index: 101;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
    }

    .mobile-menu-panel.active {
        transform: translateX(0);
    }
}

/* ============================================
   HEADER RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .header-search {
        display: none !important;
    }

    .header-actions .login-btn-text {
        display: none;
    }
}

/* ============================================
   MOBILE APP-LIKE LAYOUT (Mini Program Style)
   ============================================ */
@media (max-width: 768px) {

    /* Max width for mobile app-like experience */
    body.has-bottom-nav {
        max-width: 430px;
        margin: 0 auto;
        padding-bottom: 70px;
        background: var(--background);
    }

    /* Hide PC header on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Show mobile-only elements */
    .show-mobile-only {
        display: block !important;
    }

    /* Mobile fixed search bar - Mini Program style */
    .mobile-search-bar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 50;
        background: rgba(247, 247, 247, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        padding: 12px 16px;
        max-width: 430px;
        margin: 0 auto;
    }

    .mobile-search-wrapper {
        display: flex;
        align-items: center;
        background: white;
        border-radius: 999px;
        padding: 10px 16px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    }

    .mobile-search-wrapper input {
        flex: 1;
        border: none;
        outline: none;
        font-size: 14px;
        background: transparent;
    }

    .mobile-search-wrapper input::placeholder {
        color: var(--textLight);
    }

    /* Fixed search bar space */
    .mobile-main-content {
        padding-top: 60px;
    }

    /* Banner - Mini Program style */
    .mobile-banner {
        margin: 0 16px;
        border-radius: 12px;
        overflow: hidden;
        height: 160px;
        position: relative;
    }

    .mobile-banner img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .mobile-banner-text {
        position: absolute;
        bottom: 24px;
        left: 20px;
        color: white;
        pointer-events: none;
        z-index: 10;
    }

    .mobile-banner-text h2 {
        font-size: 18px;
        font-weight: 300;
        letter-spacing: 2px;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    .mobile-banner-text p {
        font-size: 12px;
        opacity: 0.8;
        margin-top: 2px;
    }

    /* Quick Entry Grid - Mini Program style */
    .mobile-quick-entry {
        display: flex;
        justify-content: space-around;
        padding: 24px 16px;
    }

    .mobile-entry-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
    }

    .mobile-entry-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 8px;
    }

    .mobile-entry-icon svg {
        width: 24px;
        height: 24px;
        color: white;
    }

    .mobile-entry-icon.primary {
        background: linear-gradient(135deg, var(--primary), var(--accent));
    }

    .mobile-entry-icon.secondary {
        background: linear-gradient(135deg, var(--secondary), var(--gold));
    }

    .mobile-entry-icon.gold {
        background: linear-gradient(135deg, var(--gold), #eab308);
    }

    .mobile-entry-icon.accent {
        background: linear-gradient(135deg, var(--accent), #1d4ed8);
    }

    .mobile-entry-icon.pink {
        background: linear-gradient(135deg, #ec4899, #e11d48);
    }

    .mobile-entry-item span {
        font-size: 12px;
        color: var(--textDark);
        font-weight: 500;
    }

    /* Promo Area - Mini Program style (Left large, Right small) */
    .mobile-promo-area {
        display: flex;
        margin: 0 16px 24px;
        height: 160px;
        gap: 12px;
    }

    .mobile-promo-left {
        width: 40%;
        border-radius: 12px;
        overflow: hidden;
    }

    .mobile-promo-left img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .mobile-promo-right {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .mobile-promo-right>div {
        flex: 1;
        border-radius: 12px;
        overflow: hidden;
    }

    .mobile-promo-right img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Section Headers - Mini Program style */
    .mobile-section {
        margin: 0 16px 24px;
    }

    .mobile-section-header {
        display: flex;
        align-items: center;
        margin-bottom: 16px;
    }

    .mobile-section-title {
        font-size: 18px;
        font-weight: 600;
        color: var(--textDark);
    }

    .mobile-section-divider {
        width: 2px;
        height: 16px;
        background: #d1d5db;
        margin: 0 10px;
    }

    .mobile-section-desc {
        font-size: 12px;
        color: var(--textLight);
    }

    /* Proxy Card - Mini Program style */
    .mobile-proxy-card {
        background: linear-gradient(135deg, var(--primary), var(--accent));
        border-radius: 16px;
        padding: 20px;
        color: white;
        margin-bottom: 12px;
        position: relative;
        overflow: hidden;
    }

    .mobile-proxy-card::before {
        content: '';
        position: absolute;
        top: -50%;
        right: -20%;
        width: 120px;
        height: 120px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 50%;
    }

    .mobile-proxy-title {
        font-size: 18px;
        font-weight: bold;
        margin-bottom: 4px;
    }

    .mobile-proxy-subtitle {
        font-size: 12px;
        opacity: 0.8;
    }

    .mobile-proxy-tags {
        display: flex;
        gap: 8px;
        margin: 16px 0;
    }

    .mobile-proxy-tag {
        background: rgba(201, 162, 39, 0.8);
        padding: 4px 12px;
        border-radius: 999px;
        font-size: 11px;
    }

    .mobile-proxy-features {
        display: flex;
        justify-content: space-between;
        font-size: 12px;
    }

    .mobile-proxy-feature {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    /* Proxy Steps */
    .mobile-proxy-steps {
        background: white;
        border-radius: 12px;
        padding: 16px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
    }

    .mobile-step-item {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .mobile-step-circle {
        width: 32px;
        height: 32px;
        background: rgba(26, 54, 93, 0.1);
        color: var(--primary);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        font-size: 14px;
        margin-bottom: 6px;
    }

    .mobile-step-item span {
        font-size: 11px;
        color: var(--textDark);
    }

    .mobile-step-arrow {
        color: var(--textLight);
        font-size: 12px;
    }

    /* Proxy Button */
    .mobile-proxy-btn {
        width: 100%;
        background: var(--secondary);
        color: white;
        border: none;
        border-radius: 12px;
        padding: 14px;
        font-size: 15px;
        font-weight: 500;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .mobile-proxy-btn svg {
        width: 18px;
        height: 18px;
    }

    /* New Goods Card - Mini Program style */
    .mobile-new-goods-card {
        background: white;
        border-radius: 12px;
        overflow: hidden;
    }

    .mobile-clearance-header {
        height: 44px;
        background: linear-gradient(to right, var(--primary), var(--accent));
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 14px;
    }

    .mobile-new-goods-list {
        padding: 16px;
    }

    .mobile-new-goods-item {
        display: flex;
        margin-bottom: 16px;
    }

    .mobile-new-goods-item:last-child {
        margin-bottom: 0;
    }

    .mobile-new-goods-img {
        width: 90px;
        height: 90px;
        border-radius: 12px;
        object-fit: cover;
        margin-right: 12px;
        background: #eee;
    }

    .mobile-new-goods-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .mobile-goods-name {
        font-size: 14px;
        font-weight: 600;
        color: var(--textDark);
        display: -webkit-box;
        -webkit-line-clamp: 1;
        line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .mobile-goods-desc {
        font-size: 12px;
        color: var(--textGray);
        margin-top: 4px;
    }

    .mobile-goods-price-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: auto;
    }

    .mobile-price {
        font-size: 16px;
        font-weight: 600;
        color: var(--textDark);
    }

    .mobile-buy-btn {
        background: var(--primary);
        color: white;
        border: none;
        padding: 6px 16px;
        border-radius: 8px;
        font-size: 12px;
        cursor: pointer;
    }

    /* Tabs Container - Mini Program style */
    .mobile-tabs-container {
        display: flex;
        margin: 0 16px 16px;
    }

    .mobile-tab-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        position: relative;
        opacity: 0.6;
        cursor: pointer;
        padding: 8px 0;
    }

    .mobile-tab-item.active {
        opacity: 1;
    }

    .mobile-tab-item.active::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 30%;
        right: 30%;
        height: 3px;
        background: var(--secondary);
        border-radius: 2px;
    }

    .mobile-tab-title {
        font-size: 15px;
        font-weight: 600;
        color: var(--textDark);
    }

    .mobile-tab-subtitle {
        font-size: 11px;
        color: var(--textLight);
    }

    /* Goods Grid - Mini Program style (2-column) */
    .mobile-goods-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin: 0 16px 40px;
    }

    .mobile-goods-card {
        background: white;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    }

    .mobile-goods-card-img {
        width: 100%;
        aspect-ratio: 1;
        object-fit: cover;
        background: #eee;
    }

    .mobile-goods-card-content {
        padding: 12px;
    }

    .mobile-goods-card-name {
        font-size: 13px;
        color: var(--textDark);
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        height: 36px;
        line-height: 1.4;
    }

    .mobile-price-row {
        margin-top: 8px;
        display: flex;
        align-items: baseline;
    }

    .mobile-current-price {
        font-size: 16px;
        color: var(--secondary);
        font-weight: 600;
    }

    .mobile-original-price {
        font-size: 11px;
        color: var(--textLight);
        text-decoration: line-through;
        margin-left: 6px;
    }

    .mobile-sales-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 8px;
    }

    .mobile-sales-count {
        font-size: 11px;
        color: var(--textLight);
    }

    .mobile-add-cart-btn {
        width: 24px;
        height: 24px;
        background: var(--primary);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-size: 16px;
        border: none;
        cursor: pointer;
    }

    /* Footer Copy */
    .mobile-footer-copy {
        text-align: center;
        padding: 24px 16px;
        font-size: 11px;
        color: var(--textLight);
    }

    /* Hide desktop footer on mobile */
    .desktop-footer {
        display: none !important;
    }
}

/* ============================================
   GRID LAYOUTS RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .lg-sidebar {
        display: none !important;
    }

    .lg-main-content {
        grid-column: span 12 !important;
    }
}

@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .category-scroll {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .category-scroll::-webkit-scrollbar {
        display: none;
    }

    .category-item {
        flex-shrink: 0;
        white-space: nowrap;
    }
}

/* ============================================
   DETAIL PAGE RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .detail-layout {
        flex-direction: column !important;
    }

    .detail-gallery,
    .detail-info {
        width: 100% !important;
    }
}

/* ============================================
   CART & CHECKOUT RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .checkout-grid {
        grid-template-columns: 1fr !important;
    }

    .checkout-summary {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        padding: 16px;
        z-index: 50;
    }

    .checkout-summary h2,
    .checkout-summary .price-details {
        display: none;
    }

    .checkout-summary .total-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .checkout-main {
        padding-bottom: 120px !important;
    }
}

/* ============================================
   USER CENTER RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .user-sidebar {
        display: none !important;
    }

    .user-content {
        grid-column: span 4 !important;
    }

    .user-stats {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

@media (max-width: 640px) {
    .user-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .order-table {
        display: block;
        overflow-x: auto;
    }

    .order-table th,
    .order-table td {
        min-width: 100px;
    }
}

/* ============================================
   BOTTOM NAVIGATION (Mobile)
   ============================================ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 90;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        max-width: 430px;
        margin: 0 auto;
    }

    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 10px;
        color: var(--textLight);
        text-decoration: none;
        transition: color 0.2s;
    }

    .mobile-bottom-nav a.active {
        color: var(--primary);
    }

    .mobile-bottom-nav svg {
        width: 24px;
        height: 24px;
        margin-bottom: 2px;
    }
}

/* ============================================
   FOOTER RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr !important;
        text-align: center;
    }

    .footer-hide-mobile {
        display: none !important;
    }
}

/* ============================================
   TYPOGRAPHY RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .text-responsive-xl {
        font-size: 1.5rem !important;
    }

    .text-responsive-lg {
        font-size: 1.125rem !important;
    }

    .text-responsive-md {
        font-size: 1rem !important;
    }
}

/* ============================================
   SPACING RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .px-responsive {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .py-responsive {
        padding-top: 16px !important;
        padding-bottom: 16px !important;
    }
}

/* ============================================
   MODAL RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
    .modal-content {
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 16px 16px 0 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
}

/* ============================================
   IMAGE ASPECT RATIOS
   ============================================ */
.aspect-product {
    aspect-ratio: 1 / 1;
}

.aspect-banner {
    aspect-ratio: 16 / 9;
}

@media (max-width: 768px) {
    .aspect-banner {
        aspect-ratio: 4 / 3;
    }
}

/* ============================================
   SCROLLBAR HIDDEN FOR MOBILE EXPERIENCE
   ============================================ */
@media (max-width: 768px) {
    .hide-scrollbar::-webkit-scrollbar {
        display: none;
    }

    .hide-scrollbar {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* ============================================
   SWIPER STYLES (For banner)
   ============================================ */
@media (max-width: 768px) {
    .swiper-container {
        position: relative;
        overflow: hidden;
    }

    .swiper-dots {
        position: absolute;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        gap: 6px;
    }

    .swiper-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.5);
        transition: all 0.3s;
    }

    .swiper-dot.active {
        background: #fff;
        width: 16px;
        border-radius: 3px;
    }
}

/* ============================================
   SAFE AREA FOR iOS NOTCH
   ============================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .safe-area-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .safe-area-top {
        padding-top: env(safe-area-inset-top);
    }
}