@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&family=Noto+Sans+Lao:wght@400;700&display=swap');

/* Temu-Style Design System */
:root {
    /* Brand Colors (Synced with Logo) */
    --primary-red: #E53935;
    --primary-red-hover: #C62828;
    --secondary-gold: #FFD700;
    --secondary-gold-hover: #FFC107;
    
    --primary-orange: var(--primary-red); /* Aliasing for backward compatibility */
    --primary-orange-hover: var(--primary-red-hover);

    --text-primary: #191919;
    --text-secondary: #777777;
    --price-red: #E53935;

    /* Backgrounds */
    --bg-page: #f6f6f6;
    --bg-white: #ffffff;
    --border-color: #e6e6e6;
    --bg-card-contrast: #f7f7f7;

    /* Typography */
    --font-main: 'Roboto', 'Noto Sans Lao', sans-serif;

    /* Spacing & Layout */
    --container-width: 1200px;
    --header-height: 70px;

    /* Shadows */
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-premium: 0 4px 15px rgba(229, 57, 53, 0.15);
}

body {
    font-family: var(--font-main);
    background-color: #f7f7f7;
    /* Light gray for card contrast */
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.4;
}

/* Reset & Utilities */
* {
    box-sizing: border-box;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

img {
    max-width: 100%;
    display: block;
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-orange);
    color: white;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 999px;
    /* Pill shape */
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
    width: auto;
    /* Allow auto width by default */
}

.btn:hover {
    background-color: var(--primary-orange-hover);
    transform: none;
    /* Remove legacy transform */
}

.btn-block {
    width: 100%;
}

/* Form Elements */
input[type="text"],
input[type="tel"],
input[type="password"] {
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

input:focus {
    border-color: var(--primary-orange);
}

/* Typography Helpers */
.text-center {
    text-align: center;
}

.text-orange {
    color: var(--primary-orange);
}

.font-bold {
    font-weight: 700;
}

.text-sm {
    font-size: 12px;
}

/* 
   Legacy Compatibility 
   Keeping some classes to prevent breaking existing functionality before complete refactor 
*/
.alert {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.alert-error {
    background: #ffebee;
    color: #c62828;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Dashboard / Grid (Quick Access) */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 10px 0;
}

.dash-btn {
    background: white;
    padding: 12px 5px;
    border-radius: 8px;
    text-align: center;
    font-size: 11px;
    color: var(--text-primary);
    border: 1px solid transparent;
    /* No border by default for cleaner look */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dash-btn:hover {
    color: var(--primary-orange);
}

.dash-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

/* Product Grid (Temu Style) */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding-bottom: 20px;
}

.product-card {
    background: var(--bg-white);
    border-radius: 8px;
    /* Slightly more rounded */
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid transparent;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.product-img-wrapper {
    width: 100%;
    aspect-ratio: 1/1;
    background: #f0f0f0;
    position: relative;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    padding: 10px;
}

.product-title {
    font-size: 13px;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    height: 34px;
    /* Fixed height for 2 lines */
}

.product-price-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 4px;
}

.price-current {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary-orange);
}

.price-symbol {
    font-size: 12px;
}

.price-original {
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: line-through;
}

.product-meta {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sales-count {
    background: #ffe6e6;
    /* Light red bg */
    color: #cc0000;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px 16px;
    font-size: 12px;
    color: var(--text-secondary);
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-color);
    margin-top: 30px;
}

.legal {
    color: var(--text-primary);
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 13px;
}

.add-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f0f0;
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.add-btn:hover {
    background: var(--primary-orange);
    color: white;
}

/* Main Header */
.main-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 12px 0;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.header-logo img {
    height: 44px;
    width: auto;
    object-fit: contain;
}

/* Search Bar */
.header-search {
    flex: 1;
    display: flex;
    max-width: 600px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 2px solid var(--text-primary);
    /* Temu uses black border often */
    border-radius: 999px;
    font-size: 14px;
}

.search-input:focus {
    border-color: var(--primary-orange);
}

.search-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-orange);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Header Icons */
.header-icons {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-icon-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
    color: var(--text-primary);
    position: relative;
}

.header-icon-link svg {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
}

.header-icon-link:hover {
    color: var(--primary-orange);
}

.badge-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--primary-orange);
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: bold;
}

/* Mobile Search Adjustment */
@media (max-width: 768px) {
    .main-header {
        padding: 8px 0;
    }

    .header-content {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 12px;
    }

    .header-logo {
        grid-column: 1;
        display: flex;
        align-items: center;
    }

    .header-logo img {
        height: 48px; /* Bigger logo on mobile */
    }

    .header-icons {
        grid-column: 2;
        gap: 15px;
    }

    .header-search {
        grid-column: 1 / span 2;
        width: 100%;
        max-width: none;
        margin-top: 5px;
    }

    .search-input {
        padding: 8px 35px 8px 15px;
        font-size: 13px;
    }

    .search-btn {
        width: 28px;
        height: 28px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
}

/* Cart Styles */
.cart-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 10px;
    padding-bottom: 80px;
    /* Space for sticky footer */
}

.cart-item-card {
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1px solid transparent;
}

.cart-item-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    background: #f0f0f0;
    border-radius: 4px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-meta {
    font-size: 12px;
    color: var(--text-secondary);
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 6px;
}

.cart-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.cart-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-orange);
}

/* Quantity Control */
.qty-control {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    height: 28px;
}

.qty-btn {
    width: 28px;
    height: 100%;
    background: white;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.qty-input {
    width: 30px;
    height: 100%;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 13px;
    outline: none;
}

.cart-remove-btn {
    border: none;
    background: none;
    color: #999;
    font-size: 18px;
    padding: 5px;
    cursor: pointer;
}

/* Cart Footer */
.cart-sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    padding: 10px 16px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.cart-total-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.cart-total-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-orange);
}

.btn-checkout {
    background: var(--primary-orange);
    color: white;
    font-weight: bold;
    padding: 10px 30px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 14px;
}

/* Checkout Styles */
.checkout-section {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group {
    margin-bottom: 12px;
}

.form-label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary-orange);
}

/* Payment Options */
.payment-option {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.payment-option.selected {
    border-color: var(--primary-orange);
    background: #fff8f0;
}

.payment-radio {
    accent-color: var(--primary-orange);
}