/* =========================================
   EMALL - TEMU Mobile E-Commerce Design System
   ========================================= */

:root {
    /* TEMU Design Tokens */
    --pwa-bg: #F7F7F7;              /* Neutral soft gray page canvas */
    --pwa-surface: #FFFFFF;         /* Pure white cards & containers */
    --pwa-surface-2: #F2F2F4;       /* Pill background, search bar */
    --pwa-primary: #FA5A00;         /* Signature Temu Orange */
    --pwa-primary-hover: #E05000;
    --temu-orange: #FA5A00;
    --pwa-secondary: #FF5000;
    --pwa-accent-green: #00A650;    /* Trust, guarantees, safe payments */
    --pwa-urgency-red: #E02020;     /* Discounts, sale badges, notifications */
    --pwa-text: #111111;            /* High-contrast near-black titles */
    --pwa-text-muted: #777777;      /* Secondary labels, strike-through */
    --pwa-border: #EBEBEB;          /* Hairline divider */
    --pwa-border-light: #F0F0F0;
    --pwa-input-border: #D1D5DB;
    --pwa-white: #FFFFFF;
    --pwa-black: #000000;
    --pwa-success: #00A650;
    --pwa-warning: #D97706;
    --pwa-danger: #E02020;

    /* Header / Nav colors */
    --nav-bg: #FFFFFF;
    --nav-text: #111111;
    --nav-text-muted: #777777;
    --nav-border: #EBEBEB;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-pill: 999px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body.pwa-body {
    margin: 0;
    padding: 0;
    background: var(--pwa-bg);
    color: var(--pwa-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* =========================================
   TOP HEADER (TEMU Style)
   ========================================= */
.pwa-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--nav-bg);
    display: flex;
    align-items: center;
    padding: 0 14px;
    z-index: 1000;
    gap: 10px;
    border-bottom: 1px solid var(--nav-border);
    box-shadow: var(--shadow-sm);
}

.header-logo-img {
    height: 28px;
    flex-shrink: 0;
    color: var(--pwa-primary);
    font-weight: 900;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    letter-spacing: -0.5px;
}

.header-logo-img span {
    color: var(--pwa-primary);
}

.pwa-search-bar {
    flex: 1;
    height: 38px;
    background: var(--pwa-surface-2);
    border: 1px solid var(--pwa-border);
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    padding: 0 4px 0 14px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.pwa-search-bar:hover {
    border-color: #D1D5DB;
}

.pwa-search-bar span.search-icon { 
    font-size: 15px; 
    color: #666666; 
    margin-right: 8px;
}

.pwa-search-bar input {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 13.5px;
    color: var(--pwa-text);
    outline: none;
}

.pwa-search-bar input::placeholder {
    color: #888888;
}

.search-btn {
    height: 30px;
    background: var(--pwa-primary);
    color: white;
    border: none;
    padding: 0 14px;
    font-size: 12.5px;
    font-weight: 700;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn:hover {
    background: var(--pwa-primary-hover);
}

.header-user-icon {
    font-size: 20px;
    color: var(--pwa-text);
    cursor: pointer;
    flex-shrink: 0;
    padding: 6px;
}

/* User Dropdown */
.header-user-wrapper { position: relative; }
.user-dropdown {
    position: absolute; top: 100%; right: 0; min-width: 160px;
    background: #FFFFFF; border: 1px solid var(--pwa-border); border-radius: 12px;
    box-shadow: var(--shadow-lg); display: none; z-index: 2000;
    margin-top: 10px; overflow: hidden;
}
.user-dropdown.active { display: block; animation: fadeIn 0.2s ease; }
.dropdown-item {
    padding: 12px 16px; display: block; color: var(--pwa-text);
    text-decoration: none; font-size: 13px; font-weight: 500; border-bottom: 1px solid var(--pwa-border);
    transition: background 0.15s;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover, .dropdown-item:active { background: var(--pwa-surface-2); }

/* =========================================
   TOP NAV TABS (Under Header)
   ========================================= */
.top-nav-tabs {
    position: fixed;
    top: 56px; left: 0; right: 0;
    height: 44px;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    z-index: 999;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 14px;
    gap: 22px;
    border-bottom: 1px solid var(--pwa-border);
}
.top-nav-tabs::-webkit-scrollbar { display: none; }

.top-nav-tab {
    flex-shrink: 0;
    height: 44px;
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--pwa-text-muted);
    text-decoration: none;
    position: relative;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s;
}

.top-nav-tab.active {
    font-weight: 800;
    color: var(--pwa-text);
}

.top-nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: var(--pwa-text);
    border-radius: 3px 3px 0 0;
}

/* =========================================
   TEMU TRUST BANNER (Safe Payments)
   ========================================= */
.temu-trust-bar {
    background: var(--pwa-accent-green);
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 12px 14px;
    box-shadow: 0 2px 6px rgba(0, 166, 80, 0.2);
    text-decoration: none;
}
.temu-trust-bar i {
    margin-right: 6px;
    font-size: 13px;
}

/* =========================================
   BOTTOM NAVIGATION (TEMU Style)
   ========================================= */
.pwa-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: #FFFFFF;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    border-top: 1px solid #ECECEC;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
    padding-bottom: env(safe-area-inset-bottom);
}

.pwa-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #8E8E93;
    flex: 1;
    transition: color 0.15s;
    position: relative;
}

.pwa-nav-item.active { 
    color: var(--pwa-primary); 
}

.pwa-nav-icon { 
    font-size: 20px; 
    margin-bottom: 2px; 
    position: relative;
}

.pwa-nav-label { 
    font-size: 10.5px; 
    font-weight: 600; 
}

/* Badge on nav */
.pwa-nav-badge {
    position: absolute;
    top: -3px;
    right: -8px;
    background: var(--pwa-urgency-red);
    color: #ffffff;
    font-size: 9px;
    font-weight: 800;
    min-width: 15px;
    height: 15px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #ffffff;
}

/* =========================================
   MAIN CONTENT CONTAINER
   ========================================= */
.pwa-main {
    margin-top: 100px; /* header + tabs */
    margin-bottom: 56px;
    min-height: calc(100vh - 156px);
    background: var(--pwa-bg);
}

.pwa-main.no-top-tabs {
    margin-top: 56px;
}

/* =========================================
   SECTION HEADERS
   ========================================= */
.section-header {
    padding: 14px 14px 10px;
    background: transparent;
}

.section-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--pwa-text);
}

/* =========================================
   CATEGORIES GRID
   ========================================= */
.category-grid {
    display: flex;
    overflow-x: auto;
    padding: 0 14px 14px;
    gap: 14px;
    scrollbar-width: none;
}
.category-grid::-webkit-scrollbar { display: none; }

.category-item {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    width: 76px;
    gap: 6px;
}

.category-icon {
    width: 56px;
    height: 56px;
    background: #FFFFFF;
    border: 1px solid var(--pwa-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s;
}

.category-icon:active {
    transform: scale(0.95);
}

.category-icon img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.category-label {
    font-size: 11px;
    font-weight: 600;
    color: #333333;
    text-align: center;
    line-height: 1.2;
}

/* =========================================
   PRODUCT WATERFALL (TEMU Style)
   ========================================= */
.product-grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 12px 20px;
}

.product-card {
    background: #FFFFFF;
    border: 1px solid #ECECEC;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}

.product-card:active {
    transform: scale(0.98);
}

.product-image-container {
    width: 100%;
    aspect-ratio: 1;
    position: relative;
    background: #F7F7F7;
    overflow: hidden;
}

.product-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-name-row {
    margin-bottom: 6px;
}

.product-name {
    font-size: 13px;
    font-weight: 500;
    color: #222222;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rating-sold-row {
    display: flex;
    align-items: center;
    font-size: 11px;
    color: var(--pwa-text-muted);
    gap: 4px;
    margin-bottom: 8px;
}

.rating-star { color: #f59e0b; font-weight: 600; }
.sold-count { color: #888888; }

.price-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px;
    margin-top: auto;
}

.price-box {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
}

.price-main {
    font-size: 17px;
    font-weight: 900;
    color: var(--pwa-primary);
    letter-spacing: -0.3px;
}

.price-main span {
    font-size: 12px;
    margin-right: 1px;
}

.price-original {
    font-size: 11px;
    color: #999999;
    text-decoration: line-through;
}

.cart-icon-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid #222222;
    background: #FFFFFF;
    color: #222222;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.15s;
}

.cart-icon-circle:active {
    background: #222222;
    color: #FFFFFF;
}

/* =========================================
   SEARCH OVERLAY
   ========================================= */
.search-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #FFFFFF;
    z-index: 2000;
    display: none;
    flex-direction: column;
}

.search-overlay.active { display: flex; }

.search-overlay-header {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 12px;
    border-bottom: 1px solid var(--pwa-border);
}

.search-back-btn {
    font-size: 20px;
    color: #111111;
    cursor: pointer;
}

.search-input-wrapper {
    flex: 1;
    height: 38px;
    background: #F2F2F4;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 8px;
}

.search-input-wrapper input {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 14px;
    color: #111111;
    outline: none;
}

.search-overlay-btn {
    font-size: 14px;
    font-weight: 700;
    color: var(--pwa-primary);
    cursor: pointer;
}

.search-overlay-content {
    padding: 16px;
    overflow-y: auto;
}

.search-section-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #222222;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.tag-cloud { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    margin-bottom: 24px; 
}

.search-tag { 
    background: #F2F2F4; 
    color: #333333; 
    padding: 6px 14px; 
    border-radius: var(--radius-pill); 
    font-size: 12.5px; 
    text-decoration: none; 
    border: 1px solid transparent;
}

.search-tag:active {
    border-color: #D1D5DB;
}

/* =========================================
   ORDERS PAGE (TEMU Style)
   ========================================= */
.order-tabs {
    display: flex;
    background: #FFFFFF;
    border-bottom: 1px solid var(--pwa-border);
    position: sticky;
    top: 56px;
    z-index: 100;
    overflow-x: auto;
    scrollbar-width: none;
}
.order-tabs::-webkit-scrollbar { display: none; }

.order-tab { 
    flex: 1; 
    text-align: center; 
    padding: 14px 10px; 
    font-size: 13px; 
    color: #777777; 
    text-decoration: none; 
    position: relative; 
    white-space: nowrap; 
    font-weight: 500;
    transition: color 0.15s;
}

.order-tab.active { 
    color: var(--pwa-primary); 
    font-weight: 800; 
}

.order-tab.active::after { 
    content: ''; 
    position: absolute; 
    bottom: 0; left: 16%; right: 16%; 
    height: 3px; 
    background: var(--pwa-primary); 
    border-radius: 3px 3px 0 0;
}

.order-card { 
    background: #FFFFFF; 
    border-radius: 14px; 
    margin-bottom: 12px; 
    overflow: hidden; 
    padding: 16px; 
    border: 1px solid var(--pwa-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.order-card-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-bottom: 12px; 
    padding-bottom: 10px; 
    border-bottom: 1px solid var(--pwa-border); 
}

.order-status-tag { 
    font-size: 11px; 
    font-weight: 700; 
    padding: 3px 8px;
    border-radius: 4px;
}

.order-status-tag.status-pending { background: #FFF4E8; color: #D97706; }
.order-status-tag.status-paid { background: #EBF5FF; color: #2563EB; }
.order-status-tag.status-shipped { background: #E6FFFA; color: #0D9488; }
.order-status-tag.status-completed { background: #E6F4EA; color: #00A650; }
.order-status-tag.status-cancelled { background: #FEE2E2; color: #DC2626; }

.order-card-item { 
    display: flex; 
    gap: 12px; 
    margin-bottom: 12px; 
}

.order-item-img { 
    width: 68px; 
    height: 68px; 
    background: #F7F7F7; 
    border-radius: 8px; 
    overflow: hidden; 
    flex-shrink: 0; 
    border: 1px solid var(--pwa-border);
}

.order-item-img img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
}

.order-item-info { 
    flex: 1; 
    min-width: 0;
}

.order-item-name { 
    font-size: 13px; 
    color: #222222; 
    line-height: 1.35; 
    font-weight: 500;
}

.order-item-sku { 
    font-size: 11.5px; 
    color: #777777; 
    margin-top: 4px; 
}

.order-item-price { 
    font-size: 14px; 
    font-weight: 800; 
    color: var(--pwa-primary); 
}

.order-card-footer { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-top: 1px solid var(--pwa-border); 
    padding-top: 10px; 
}

/* =========================================
   SHOPPING CART & CHECKOUT BAR
   ========================================= */
.checkout-bar {
    position: fixed;
    bottom: 56px; left: 0; right: 0;
    height: 60px;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-top: 1px solid #ECECEC;
    z-index: 1001;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.checkout-btn {
    background: var(--pwa-primary);
    color: white;
    border: none;
    padding: 0 24px;
    height: 42px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(250,90,0,0.3);
}

.qty-stepper { 
    display: flex; 
    border: 1px solid #D1D5DB; 
    border-radius: 6px; 
    overflow: hidden; 
    background: #FFFFFF; 
}
.qty-stepper button { 
    width: 28px; 
    height: 28px; 
    border: none; 
    background: #F2F2F4; 
    color: #222222; 
    font-size: 16px; 
    cursor: pointer;
}
.qty-stepper input { 
    width: 36px; 
    border: none; 
    border-left: 1px solid #D1D5DB; 
    border-right: 1px solid #D1D5DB; 
    background: #FFFFFF; 
    color: #111111; 
    text-align: center; 
    font-size: 13px;
    font-weight: 600;
}

/* =========================================
   BUTTONS & CTAs (TEMU Orange Style)
   ========================================= */
.pwa-btn-primary, .btn-pwa { 
    background: var(--pwa-primary); 
    color: #FFFFFF; 
    border-radius: var(--radius-pill); 
    font-weight: 700; 
    border: none; 
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(250, 90, 0, 0.3);
    transition: all 0.2s;
}

.pwa-btn-primary:active, .btn-pwa:active { 
    background: var(--pwa-primary-hover);
    transform: scale(0.98); 
}

/* =========================================
   FORMS & INPUTS (Light Theme)
   ========================================= */
.pwa-card {
    background: #FFFFFF;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--pwa-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--pwa-text);
}

.form-input {
    width: 100%;
    background: #FFFFFF;
    border: 1px solid var(--pwa-input-border);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--pwa-text);
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--pwa-primary);
    box-shadow: 0 0 0 2px rgba(250, 90, 0, 0.15);
}

/* =========================================
   AUTHENTICATION (TEMU Style)
   ========================================= */
.auth-page {
    background: #FFFFFF;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 60px;
}

.auth-header {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.auth-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 24px;
    max-width: 440px;
    margin: 0 auto;
    width: 100%;
}

.auth-title {
    font-size: 22px;
    font-weight: 800;
    color: #111111;
    margin-top: 14px;
    margin-bottom: 24px;
    text-align: center;
}

.auth-form { width: 100%; }

.auth-btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--pwa-primary);
    color: white;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    margin-top: 12px;
    box-shadow: 0 4px 14px rgba(250, 90, 0, 0.35);
    transition: transform 0.15s;
}

.auth-btn-primary:active {
    transform: scale(0.98);
}

.auth-social-btn {
    width: 100%;
    padding: 13px;
    background: #FFFFFF;
    border: 1px solid #D1D5DB;
    border-radius: var(--radius-pill);
    color: #222222;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.auth-social-btn:hover, .auth-social-btn:active {
    background: #F7F7F7;
}

.auth-divider {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 22px 0;
    color: #888888;
    font-size: 12px;
}
.auth-divider::before, .auth-divider::after { 
    content: ""; 
    flex: 1; 
    height: 1px; 
    background: #E5E7EB; 
    margin: 0 10px; 
}

/* =========================================
   ANIMATIONS & UTILITIES
   ========================================= */
.animate-fade { animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.divider-card { height: 8px; background: #F7F7F7; margin: 4px 0; }
.no-nav-main { margin-top: 0 !important; margin-bottom: 0 !important; }

/* =========================================
   TEMU UNIVERSAL OVERRIDES FOR INLINE DARK ELEMENTS
   ========================================= */
.pwa-page {
    background: var(--pwa-bg);
    color: var(--pwa-text);
}

/* Force dark inline backgrounds to clean Temu white */
[style*="background: #1e1e1e"],
[style*="background: #1c1c1e"],
[style*="background: #141416"],
[style*="background: #18181b"],
[style*="background: #27272a"] {
    background: #FFFFFF !important;
    border-color: #EBEBEB !important;
    color: #111111 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important;
}

/* Force dark input containers to clean white/light gray */
input[style*="background: #121212"],
input[style*="background: #000"],
textarea[style*="background: #121212"],
textarea[style*="background: #000"] {
    background: #FFFFFF !important;
    border-color: #D1D5DB !important;
    color: #111111 !important;
}

/* Overwrite white text inside light containers to dark text */
.pwa-card h2, .pwa-card h3, .pwa-card div[style*="color: #fff"], 
.pwa-card span[style*="color: #fff"], .pwa-card div[style*="color: #ffffff"],
.order-card span[style*="color: #fff"], .order-card div[style*="color: #fff"] {
    color: #111111 !important;
}

/* Keep white text on primary orange buttons */
.pwa-btn-primary, .btn-pwa, .auth-btn-primary, button[style*="background: #fe2c55"], button[style*="background: var(--pwa-primary)"], a[style*="background: #fe2c55"], a[style*="background: var(--pwa-primary)"] {
    color: #FFFFFF !important;
    background: var(--pwa-primary) !important;
}
