:root {
    --primary-bg: #ffffff;
    --secondary-bg: #f2f2f7;
    --accent: #4c47f7;
    --accent-light: #eef2ff;
    --text-main: #1c1c1e;
    --text-muted: #8e8e93;
    --bg-main: #f3f4fb;
    --tab-bg: #1c1c1e;
    --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
    --border-radius-xl: 24px;
    --border-radius-lg: 18px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--secondary-bg);
    color: var(--text-main);
    line-height: 1.4;
    padding-bottom: calc(70px + var(--safe-area-bottom)); /* Space for bottom tab bar */
}

.container {
    max-width: 600px; /* Mobile-first container */
    margin: 0 auto;
    padding: 0 16px;
}

/* --- Header --- */
.app-header {
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 1000;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.header-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid #f2f2f7;
    flex-shrink: 0;
}

.search-bar {
    flex: 1;
    background: #f2f2f7;
    border-radius: 24px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.search-bar i {
    color: #1a4d2e;
    font-size: 18px;
}

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

.search-bar input::placeholder {
    color: #8e8e93;
}

/* --- Search Results --- */
.search-results-overlay {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    padding: 8px;
    animation: slideDown 0.3s ease;
}

.search-results-overlay.active {
    display: block;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--secondary-bg);
}

.search-result-img {
    width: 50px;
    height: 50px;
    background: var(--bg-main);
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.search-result-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.search-result-info {
    flex: 1;
}

.search-result-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
}

.search-result-price {
    font-size: 13px;
    color: var(--accent);
    font-weight: 800;
}

.catalog-btn {
    background: #1a4d2e;
    color: #ffffff;
    border-radius: 14px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.catalog-btn:active {
    transform: scale(0.92);
}

/* --- Hero Banner --- */
.hero-section {
    margin: 16px 0;
}

.hero-banner {
    width: 100%;
    height: 180px;
    background: #2d5a3a;
    border-radius: var(--border-radius-xl);
    display: flex;
    overflow: hidden;
    position: relative;
    box-shadow: var(--card-shadow);
}

.hero-banner-content {
    flex: 1;
    padding: 24px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 1;
}

.hero-banner-img {
    flex: 1;
    background: url('img/kit-godview.webp') center/cover no-repeat;
    position: relative;
}

/* --- Category Grid --- */
.section-title {
    font-size: 20px;
    font-weight: 700;
    margin: 24px 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.category-item {
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    transition: transform 0.2s;
}

.category-icon {
    width: 72px;
    height: 72px;
    background: #ffffff;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

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

.category-item span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-main);
    max-width: 80px;
}

/* --- Horizontal Scroll (Recently Viewed) --- */
.horizontal-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 0 16px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

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

.small-card {
    width: 140px;
    background: white;
    border-radius: 20px;
    padding: 12px;
    box-shadow: var(--card-shadow);
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
    display: block;
}

.small-card-img {
    width: 100%;
    aspect-ratio: 1;
    background: #f8f8f8;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.small-card-img img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.small-card h4 {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.small-card-price {
    font-size: 11px;
    color: var(--accent);
    font-weight: 700;
}

/* --- Main Feed (Product Grid) --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.product-card {
    background: var(--primary-bg);
    border-radius: var(--border-radius);
    padding: 12px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    position: relative;
}

.product-card-img {
    width: 100%;
    aspect-ratio: 1;
    background: #f8f8f8;
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-card-img img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.product-card-info h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-main);
}

.product-card-bottom {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-price {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
}

.add-btn {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
}

.wish-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #ccc;
    font-size: 18px;
    cursor: pointer;
}

.wish-btn.active {
    color: #ff3b30;
}

/* --- Tab Bar --- */
.tab-bar-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 3000; /* Above the cart drawer */
    display: flex;
    justify-content: center;
}

.tab-bar {
    background: var(--tab-bg);
    border-radius: 30px;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 64px;
    gap: 4px;
    color: #999;
    font-size: 10px;
    font-weight: 500;
    position: relative;
    text-decoration: none;
}

.tab-item.active {
    color: #ffffff;
}

.tab-item.active i {
    color: #8e55f9;
}

.tab-item i {
    font-size: 18px;
}

.cart-badge {
    position: absolute;
    top: -2px;
    right: 12px;
    background: #ff3b30;
    color: white;
    font-size: 10px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--tab-bg);
    display: none;
}

.beta-badge {
    position: absolute;
    bottom: -6px;
    background: #8e55f9;
    color: white;
    font-size: 7px;
    font-weight: 900;
    padding: 1px 4px;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-up {
    animation: fadeInUp 0.5s ease-out forwards;
}

/* --- Product Page Specific --- */
.product-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(243, 244, 251, 0.8);
    backdrop-filter: blur(10px);
}

.back-btn, .share-btn {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    color: var(--text-main);
    text-decoration: none;
}

.product-gallery {
    width: 100%;
    background: white;
    padding-top: 64px;
    border-bottom-left-radius: 32px;
    border-bottom-right-radius: 32px;
    overflow: hidden;
}

.gallery-main {
    width: 100%;
    aspect-ratio: 1/1;
    display: flex;
    overflow-x: auto;
    snap-type: x mandatory;
    scrollbar-width: none;
}

.gallery-main::-webkit-scrollbar { display: none; }

.gallery-item {
    min-width: 100%;
    snap-align: center;
}

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

.product-info-card {
    background: white;
    border-radius: var(--border-radius-xl);
    padding: 24px;
    margin-top: 16px;
    box-shadow: var(--card-shadow);
}

.price-tag {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-main);
}

.old-price {
    text-decoration: line-through;
    color: #8e8e93;
    font-size: 18px;
    margin-left: 8px;
}

.badge-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.app-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-orange { background: #fff3e0; color: #ef6c00; }
.badge-black { background: #1c1c1e; color: white; }

.spec-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.spec-item {
    display: flex;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid #f2f2f7;
}

.spec-label { color: #8e8e93; font-size: 14px; }
.spec-value { font-weight: 600; font-size: 14px; }

.sticky-buy-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 16px);
}

.buy-btn {
    flex: 1;
    background: var(--accent);
    color: white;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    text-decoration: none;
}

/* --- Shopping Cart Drawer (Bazar Style) --- */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

.cart-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 500px;
    height: 100%;
    background: #f2f2f7; /* Light gray background like in Bazar */
    z-index: 2001;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.05);
}

.cart-overlay.active .cart-drawer {
    right: 0;
}

.cart-header {
    padding: 24px 20px;
    background: #f2f2f7;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header h2 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
}

.cart-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
}

.cart-item {
    background: white;
    border-radius: 24px;
    padding: 20px;
    margin-bottom: 12px;
    display: flex;
    gap: 16px;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.cart-item-check {
    display: flex;
    align-items: center;
}

.custom-checkbox {
    width: 24px;
    height: 24px;
    background: #e5e5ea; /* Default gray when unselected */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.custom-checkbox.selected {
    background: #3b82f6; /* Blue when selected */
}

.cart-item-img {
    width: 70px;
    height: 70px;
    background: #f8f8f8;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cart-item-img img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.3;
    margin-bottom: 12px;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-item-price {
    font-weight: 800;
    font-size: 20px;
    color: var(--text-main);
}

.quantity-pill {
    display: flex;
    align-items: center;
    background: #f2f2f7;
    border-radius: 16px;
    padding: 4px;
    gap: 12px;
}

.qty-btn-minus {
    color: #ff3b30;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.qty-btn-plus {
    color: #3b82f6;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.qty-value {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-main);
}

.cart-footer {
    background: white;
    border-top-left-radius: 32px;
    border-top-right-radius: 32px;
    padding: 24px 20px;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.03);
    padding-bottom: 110px; /* Space for the tab-bar */
}

.footer-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.select-all-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.select-all-text {
    font-weight: 700;
    font-size: 16px;
}

.total-sum {
    font-weight: 800;
    font-size: 22px;
}

.bazar-btn {
    width: 100%;
    background: #3b82f6;
    color: white;
    border: none;
    padding: 18px;
    border-radius: 18px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.25);
}

/* --- Checkout Step --- */
.checkout-step {
    display: none;
    flex-direction: column;
    padding: 24px 20px;
    height: 100%;
}

.checkout-step.active {
    display: flex;
}

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

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    margin-left: 4px;
}

.form-input {
    width: 100%;
    background: white;
    border: 2px solid #f2f2f7;
    padding: 18px;
    border-radius: 18px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.05);
}

.success-step {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    padding: 40px 20px;
}

.success-step.active {
    display: flex;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin-bottom: 24px;
}

.success-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 12px;
}

.success-text {
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.5;
}

