/* =========================================
   EMALL - TikTok Shop Fidelity Redesign
   ========================================= */

:root {
    --pwa-bg: #121212;          /* Black background */
    --pwa-surface: #1e1e1e;
    --pwa-surface-2: #2c2c2c;
    --pwa-primary: #fe2c55;      /* TikTok Red */
    --pwa-text: #ffffff;        /* White text */
    --pwa-text-muted: #8a8b94;
    --pwa-border: #2c2c2c;
    --pwa-white: #ffffff;
    --pwa-black: #000000;
    
    /* Header / Nav colors */
    --nav-bg: #121212;
    --nav-text: #ffffff;
    --nav-text-muted: rgba(255,255,255,0.6);
    --nav-border: #1e1e1e;
    
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 50px;
}

* {
    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 (TikTok Shop Style)
   ========================================= */
.pwa-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--nav-bg);
    display: flex;
    align-items: center;
    padding: 0 12px;
    z-index: 1000;
    gap: 8px;
}

.header-logo-img {
    height: 24px;
    flex-shrink: 0;
    color: white;
    font-weight: 800;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.pwa-search-bar {
    flex: 1;
    height: 36px;
    background: #000000;
    border: 1px solid var(--pwa-primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 0 0 0 10px;
    overflow: hidden;
    cursor: pointer;
}

.pwa-search-bar span.search-icon { 
    font-size: 16px; 
    color: var(--pwa-primary); 
    margin-right: 6px;
}

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

.search-btn {
    height: 100%;
    background: var(--pwa-primary);
    color: white;
    border: none;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.header-user-icon {
    font-size: 24px;
    color: white;
    cursor: pointer;
    flex-shrink: 0;
}

/* =========================================
   TOP NAV TABS (Under Header)
   ========================================= */
.top-nav-tabs {
    position: fixed;
    top: 56px; left: 0; right: 0;
    height: 44px;
    background: var(--nav-bg);
    display: flex;
    align-items: center;
    z-index: 999;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 12px;
    gap: 20px;
}
.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(--nav-text-muted);
    text-decoration: none;
    position: relative;
    cursor: pointer;
    white-space: nowrap;
}

.top-nav-tab.active {
    font-weight: 700;
    color: #ffffff;
}

.top-nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: #ffffff;
}

/* =========================================
   BOTTOM NAVIGATION
   ========================================= */
.pwa-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 54px;
    background: #000000;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    border-top: 1px solid #1e1e1e;
    padding-bottom: env(safe-area-inset-bottom);
}

.pwa-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: rgba(255,255,255,0.6);
    flex: 1;
}

.pwa-nav-item.active { color: #ffffff; }

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

.pwa-nav-label { font-size: 10px; font-weight: 500; }

/* =========================================
   MAIN CONTENT
   ========================================= */
.pwa-main {
    margin-top: 100px; /* header + tabs */
    margin-bottom: 54px;
    min-height: calc(100vh - 154px);
}

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

/* =========================================
   SECTION HEADERS
   ========================================= */
.section-header {
    padding: 16px 12px 12px;
    background: var(--pwa-bg);
}

.section-title {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
}

/* =========================================
   CATEGORIES GRID
   ========================================= */
.category-grid {
    display: flex;
    overflow-x: auto;
    padding: 0 12px 16px;
    gap: 12px;
    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: 80px;
    gap: 8px;
}

.category-icon {
    width: 60px;
    height: 60px;
    background: #1e1e1e;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.category-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

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

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

.product-column {
    flex: 1;
    padding: 0 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-card {
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.product-image-container {
    width: 100%;
    aspect-ratio: 1;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #1e1e1e;
}

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

.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-overlay svg {
    margin-left: 4px;
    fill: white;
}

.product-info {
    padding: 8px 4px 12px;
}

.product-name-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 4px;
}

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

.shop-icon-small {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
    background: #fe2c55 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zM1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H5.21l-.94-2H1zm16 16c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z'%3E%3C/path%3E%3C/svg%3E") no-repeat center;
    background-size: 10px;
}

.rating-sold-row {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #ffffff;
    gap: 4px;
    margin-bottom: 4px;
}

.rating-star { color: #ffffff; }

.sold-count {
    color: #ffffff;
    margin-left: 4px;
}

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

.price-main {
    font-size: 16px;
    font-weight: 800;
    color: #ffffff;
}

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

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

.jom-lokal-badge {
    background: #3e3e3e;
    color: #ffffff;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 2px;
    font-weight: 700;
    margin-right: 4px;
}

/* =========================================
   SEARCH OVERLAY
   ========================================= */
.search-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000000;
    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 12px;
    gap: 12px;
}

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

.search-input-wrapper {
    flex: 1;
    height: 36px;
    background: #1e1e1e;
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 8px;
}

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

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

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

/* =========================================
   DISCOVER PAGE
   ========================================= */
.discover-container {
    display: flex;
    height: calc(100vh - 110px);
    background: var(--pwa-bg);
}

.discover-sidebar {
    width: 90px;
    background: #000000;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-item {
    display: block;
    padding: 16px 8px;
    font-size: 12px;
    color: var(--nav-text-muted);
    text-align: center;
    text-decoration: none;
    border-left: 3px solid transparent;
}

.sidebar-item.active {
    background: var(--pwa-surface);
    color: #ffffff;
    font-weight: 700;
    border-left-color: var(--pwa-primary);
}

.discover-content {
    flex: 1;
    overflow-y: auto;
    background: var(--pwa-bg);
}

.cat-hero-banner {
    margin: 12px;
    height: 100px;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 16px;
}

.cat-product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 0 12px;
}

.cat-product-item {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: #ffffff;
}

.cat-product-item img {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    object-fit: cover;
    background: #1e1e1e;
}

.cat-product-name {
    font-size: 11px;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
    height: 2.4em;
}

.cat-product-price {
    font-size: 11px;
    font-weight: 700;
    color: var(--pwa-primary);
    margin-top: 2px;
}

/* =========================================
   CART PAGE
   ========================================= */
.cart-group { background: #1e1e1e; margin-bottom: 8px; border-radius: 8px; overflow: hidden; }

.cart-group-header {
    padding: 12px;
    border-bottom: 1px solid #2c2c2c;
    display: flex;
    align-items: center;
}

.cart-item {
    padding: 12px;
    display: flex;
    align-items: flex-start;
    border-bottom: 1px solid #2c2c2c;
    position: relative;
    gap: 10px;
}
.cart-item:last-child { border-bottom: none; }

.cart-item-img {
    width: 80px; height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: #000;
    flex-shrink: 0;
}
.cart-item-img img { width: 100%; height: 100%; object-fit: cover; }

.cart-item-info { flex: 1; }
.cart-item-name { font-size: 13px; color: #fff; line-height: 1.3; margin-bottom: 4px; }
.cart-item-sku { font-size: 11px; color: #8a8b94; background: #000; padding: 2px 6px; border-radius: 4px; display: inline-block; }
.cart-item-price { font-size: 14px; font-weight: 700; color: var(--pwa-primary); }

.qty-stepper { display: flex; border: 1px solid #2c2c2c; border-radius: 4px; overflow: hidden; background: #000; }
.qty-stepper button { width: 28px; height: 28px; border: none; background: transparent; color: #fff; font-size: 18px; }
.qty-stepper input { width: 40px; border: none; border-left: 1px solid #2c2c2c; border-right: 1px solid #2c2c2c; background: transparent; color: #fff; text-align: center; }

.cart-item-remove { position: absolute; top: 12px; right: 12px; color: #666; cursor: pointer; }

.checkout-bar {
    position: fixed;
    bottom: 54px; left: 0; right: 0;
    height: 60px;
    background: #000000;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-top: 1px solid #1e1e1e;
    z-index: 1001;
}

.checkout-btn {
    background: var(--pwa-primary);
    color: white;
    border: none;
    padding: 0 24px;
    height: 40px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
}

/* =========================================
   ORDERS PAGE
   ========================================= */
.order-tabs {
    display: flex;
    background: #000000;
    border-bottom: 1px solid #1e1e1e;
    position: sticky;
    top: 56px;
    z-index: 100;
    overflow-x: auto;
    scrollbar-width: none;
}
.order-tab { flex: 1; text-align: center; padding: 14px 0; font-size: 13px; color: #8a8b94; text-decoration: none; position: relative; white-space: nowrap; }
.order-tab.active { color: #fff; font-weight: 700; }
.order-tab.active::after { content: ''; position: absolute; bottom: 0; left: 20%; right: 20%; height: 2px; background: var(--pwa-primary); }

.order-card { background: #1e1e1e; border-radius: 8px; margin-bottom: 12px; overflow: hidden; padding: 12px; }
.order-card-header { display: flex; justify-content: space-between; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #2c2c2c; }
.order-status-tag { font-size: 11px; font-weight: 700; }

.order-card-item { display: flex; gap: 12px; margin-bottom: 12px; }
.order-item-img { width: 62px; height: 62px; background: #000; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.order-item-img img { width: 100%; height: 100%; object-fit: cover; }
.order-item-info { flex: 1; }
.order-item-name { font-size: 13px; color: #fff; line-height: 1.3; }
.order-item-sku { font-size: 11px; color: #8a8b94; margin-top: 4px; }
.order-item-price { font-size: 14px; font-weight: 700; color: #fff; }

.order-card-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #2c2c2c; padding-top: 8px; }

/* =========================================
   PROFILE / ME PAGE
   ========================================= */
.profile-header {
    background: #1e1e1e;
    padding: 24px 16px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.profile-avatar {
    width: 60px; height: 60px;
    border-radius: 50%;
    border: 2px solid #2c2c2c;
    background: #000;
    overflow: hidden;
}

.profile-wallet-card {
    background: #1e1e1e;
    margin: -15px 12px 12px;
    padding: 16px 0;
    border-radius: 8px;
    display: flex;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.wallet-item { flex: 1; text-align: center; border-right: 1px solid #2c2c2c; }
.wallet-item:last-child { border-right: none; }
.wallet-val { font-size: 15px; font-weight: 800; color: #fff; }
.wallet-label { font-size: 11px; color: #8a8b94; margin-top: 4px; }

.order-actions-grid { display: flex; padding: 16px 0; }
.order-action-item { flex: 1; text-align: center; text-decoration: none; color: #fff; font-size: 11px; position: relative; }
.order-action-icon { font-size: 24px; margin-bottom: 8px; }
.order-action-item .badge { position: absolute; top: -5px; right: 20%; background: var(--pwa-primary); color: white; font-size: 9px; min-width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 1px solid #1e1e1e; }

.menu-item {
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2c2c2c;
    font-size: 14px;
    color: #fff;
    background: #1e1e1e;
}
.menu-item:last-child { border-bottom: none; }
.menu-item .chevron { color: #555; }

/* =========================================
   UTILITIES
   ========================================= */
.pwa-btn-primary { background: var(--pwa-primary); color: white; border-radius: 4px; font-weight: 700; border: none; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.search-tag { background: #1e1e1e; color: white; padding: 6px 12px; border-radius: 4px; font-size: 13px; text-decoration: none; }

.animate-fade { animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.divider-card { height: 8px; background: #000; margin: 4px 0; }

/* =========================================
   AUTHENTICATION (LOGIN / REGISTER)
   ========================================= */
.auth-page {
    background: #000000;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 60px; /* footer space */
}

.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 30px;
    max-width: 450px;
    margin: 0 auto;
    width: 100%;
}

.auth-title {
    font-size: 24px;
    font-weight: 800;
    color: #ffffff;
    margin-top: 20px;
    margin-bottom: 30px;
    text-align: center;
}

.auth-form { width: 100%; }

.auth-input-group { margin-bottom: 20px; }
.auth-input-group label { display: block; font-size: 13px; font-weight: 600; color: #8a8b94; margin-bottom: 8px; }
.auth-input-group input {
    width: 100%;
    padding: 14px;
    background: #1e1e1e;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    font-size: 15px;
    color: #fff;
    outline: none;
    transition: border-color 0.2s;
}
.auth-input-group input:focus { border-color: var(--pwa-primary); }

.auth-btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--pwa-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
}

.auth-social-btn {
    width: 100%;
    padding: 12px;
    background: #1e1e1e;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
    cursor: pointer;
}
.auth-social-btn img { width: 20px; height: 20px; }

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

.auth-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    border-top: 1px solid #1e1e1e;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    font-size: 14px;
    color:rgba(255,255,255,0.7);
}
.auth-footer a { color: var(--pwa-primary); font-weight: 700; text-decoration: none; margin-left: 5px; }

/* Overrides for auth layouts */
.no-nav-main { margin-top: 0 !important; margin-bottom: 0 !important; }

/* =========================================
   PWA UI COMPONENTS & FORMS
   ========================================= */
.pwa-card {
    background: var(--pwa-surface);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--pwa-border);
}

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

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

.form-input {
    width: 100%;
    background: #000000;
    border: 1px solid var(--pwa-border);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--pwa-text);
    font-size: 16px;
    transition: all 0.2s;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--pwa-primary);
    box-shadow: 0 0 0 1px var(--pwa-primary);
}

.btn-pwa {
    width: 100%;
    background: var(--pwa-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-pwa:active {
    opacity: 0.8;
}


