/* ============================================================================
   File: assets/css/style.css
   Description: Global CSS, Variables, Mobile First Design & Animations
   ============================================================================ */

/* --- CSS Variables --- */
:root {
    --primary-color: #2563EB;
    --secondary-color: #F97316;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --text-main: #111827;
    --text-muted: #6B7280;
    --bg-main: #FFFFFF;
    --bg-light: #F3F4F6;
    --border-color: #E5E7EB;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    /* Safe Area for Mobile Apps */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    
    --header-height: 115px;
    --bottom-nav-height: 65px;
}

/* --- Base & Reset --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Make it look like an App on Desktop, Full width on Mobile */
@media (min-width: 600px) {
    body {
        max-width: 480px;
        margin: 0 auto;
        background-color: var(--bg-main);
        box-shadow: 0 0 20px rgba(0,0,0,0.1);
        min-height: 100vh;
        position: relative;
    }
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
}

/* --- Fixed Header --- */
.main-header {
    position: sticky;
    top: 0;
    background: var(--bg-main);
    z-index: 1000;
    padding: calc(12px + var(--safe-top)) 16px 12px;
    box-shadow: var(--shadow-sm);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.brand-name {
    font-size: 20px;
    color: var(--primary-color);
    font-weight: 700;
}

.site-logo {
    max-height: 32px;
    width: auto;
}

.header-actions {
    display: flex;
    gap: 16px;
}

.icon-btn {
    position: relative;
    font-size: 22px;
    color: var(--text-main);
}

.badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background: var(--danger-color);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 20px;
    border: 2px solid var(--bg-main);
}

.badge.bg-secondary {
    background: var(--secondary-color);
}

/* --- Search Bar --- */
.header-search .search-box {
    display: flex;
    align-items: center;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    border: 1px solid var(--border-color);
}

.header-search .search-box i {
    color: var(--text-muted);
    font-size: 16px;
    margin-right: 10px;
}

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

/* --- Main Content --- */
.main-content {
    background: var(--bg-main);
    min-height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
}

.bottom-nav-spacer {
    height: calc(var(--bottom-nav-height) + var(--safe-bottom) + 20px);
}

/* --- Banner Slider --- */
.banner-section {
    position: relative;
    padding: 16px;
}

.slider-container {
    position: relative;
    height: 160px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-light);
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.slide.active {
    opacity: 1;
}

.banner-link {
    display: block;
    width: 100%;
    height: 100%;
}

.slider-dots {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.dot {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    cursor: pointer;
    transition: 0.3s;
}

.dot.active {
    background: var(--primary-color);
    width: 16px;
    border-radius: 4px;
}

/* --- Sections Common --- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 12px;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.see-all {
    font-size: 13px;
    color: var(--primary-color);
    font-weight: 500;
}

.bg-light {
    background: #FAFAFA;
}

/* --- Categories --- */
.horizontal-scroll {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding: 0 16px 16px;
    scrollbar-width: none; /* Firefox */
}

.horizontal-scroll::-webkit-scrollbar {
    display: none; /* Chrome */
}

.category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 72px;
    gap: 8px;
    cursor: pointer;
}

.category-img {
    width: 56px;
    height: 56px;
    background: var(--bg-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

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

.category-name {
    font-size: 12px;
    text-align: center;
    color: var(--text-main);
    font-weight: 500;
}

/* --- Flash Sale --- */
.flash-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.countdown-timer {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--danger-color);
}

.time-box {
    background: var(--danger-color);
    color: #fff;
    padding: 3px 6px;
    border-radius: 4px;
}

/* --- Product Grid & Cards --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 16px 16px;
}

.product-card {
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

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

.product-image {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    background: var(--bg-light);
    cursor: pointer;
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.discount-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--secondary-color);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

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

.product-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
}

.product-price {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.current-price {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 15px;
}

.old-price {
    color: var(--text-muted);
    font-size: 12px;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
    margin-top: auto;
}

.rating i {
    color: #FBBF24;
}

.add-to-cart-btn {
    width: 100%;
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
}

.add-to-cart-btn:active {
    background: #1D4ED8;
}

/* --- Fixed Bottom Navigation --- */
.bottom-navigation {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--bg-main);
    display: flex;
    justify-content: space-around;
    padding: 10px 0 calc(10px + var(--safe-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
}

/* Constrain Bottom Nav for Desktop wrapper */
@media (min-width: 600px) {
    .bottom-navigation {
        max-width: 480px;
        left: 50%;
        transform: translateX(-50%);
    }
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    flex: 1;
}

.nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

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

.relative {
    position: relative;
}

.badge-mini {
    position: absolute;
    top: -4px;
    right: 18px;
    background: var(--secondary-color);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--bg-main);
}

/* --- Toast Notification --- */
.custom-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(17, 24, 39, 0.9);
    color: #fff;
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    backdrop-filter: blur(4px);
}

.custom-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.custom-toast i {
    color: var(--success-color);
    font-size: 18px;
}

/* --- Skeleton Loading Animation --- */
@keyframes shimmer {
    0% { background-position: -468px 0; }
    100% { background-position: 468px 0; }
}

.skeleton {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 800px 100%; 
    animation: shimmer 1.5s infinite linear forwards;
}

.skeleton-banner {
    width: 100%;
    height: 100%;
}

.skeleton-category {
    min-width: 56px;
    height: 56px;
    border-radius: 50%;
}

.skeleton-product-card {
    height: 240px;
    border-radius: var(--radius-md);
}

.no-data, .no-products {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 14px;
    grid-column: 1 / -1;
}