:root {
    --primary-color: #ff2bf1; /* SRAGENMART RED */
    --primary-dark: #d117c5;
    --secondary-color: #000000;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #777777;
    --border-color: #e0e0e0;
    --success-color: #28a745;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.15);
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 50px;
    --header-height: 125px; 
}

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

button, a, input, .qty-control, .qty-btn, .product-card, .category-btn, .header-cart-btn {
    touch-action: manipulation;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    padding-top: var(--header-height);
    padding-bottom: 20px;
}

/* Header */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--primary-color);
    color: white;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease;
}

.info-container {
    background: var(--primary-dark);
    padding: 6px 15px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

@keyframes slideDown {
    0% { transform: translateY(-20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 20px;
    transition: height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    overflow: hidden;
}

.brand-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo-img {
    height: 35px;
    transition: height 0.3s ease;
}

.search-row {
    display: flex;
    align-items: center;
    padding: 0 15px 15px 15px;
    gap: 10px;
}

.search-container {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 10px 45px 10px 40px;
    border-radius: var(--radius-pill);
    border: none;
    outline: none;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.scan-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 18px;
    cursor: pointer;
}

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

.header-cart-total {
    font-size: 13px;
    font-weight: 700;
    color: white;
}

.header-cart-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: white;
    text-decoration: none;
    font-size: 18px;
    flex-shrink: 0;
}

.header-cart-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--card-bg);
    color: var(--primary-color);
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--primary-color);
}

/* Scrolled Header */
.header-scrolled .header-top {
    height: 0;
    padding: 0;
    opacity: 0;
}

/* Categories */
.categories-section {
    background: var(--card-bg);
    padding: 12px 0;
    margin-bottom: 0px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 60px; /* fallback */
    z-index: 90;
    transition: top 0.3s ease;
}

.categories-wrapper {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding: 0 15px;
    scrollbar-width: none;
}

.categories-wrapper::-webkit-scrollbar {
    display: none;
}

.category-btn {
    white-space: nowrap;
    padding: 8px 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.category-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Controls */
.controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0px;
}

.filters-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(16px);
}

.slider.round {
    border-radius: 18px;
}
.slider.round:before {
    border-radius: 50%;
}

.view-modes-container {
    display: flex;
    gap: 4px;
}

.view-mode-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.view-mode-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}


/* Main Grid */
.main-content {
    padding: 0 15px;
}

.products-grid {
    display: grid;
    gap: 12px;
}

/* Mode Baris (List) */
.products-grid.grid-1 {
    grid-template-columns: 1fr;
}
.products-grid.grid-1 .product-card {
    display: grid;
    grid-template-columns: 60px 1fr 100px;
    grid-template-rows: auto 1fr;
    gap: 5px 12px;
    padding: 10px;
    align-items: center;
}
.products-grid.grid-1 .product-image-placeholder,
.products-grid.grid-1 .product-img {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    width: 60px;
    height: 60px;
    margin: 0;
}
.products-grid.grid-1 .product-details-wrap {
    display: contents;
}
.products-grid.grid-1 .product-name {
    grid-column: 1 / 3;
    grid-row: 1 / 2;
    height: auto;
    margin: 0;
    font-size: 14px;
}
.products-grid.grid-1 .product-price {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    align-self: start;
    margin-top: 5px;
}
.products-grid.grid-1 .product-meta {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    align-self: end;
    margin-bottom: 5px;
}
.products-grid.grid-1 .product-actions {
    grid-column: 3 / 4;
    grid-row: 1 / 3;
    margin: 0;
    height: 100%;
}
.products-grid.grid-1 .product-actions .add-btn {
    height: 100%;
    width: 100%;
    border-radius: var(--radius-md);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}
.products-grid.grid-1 .product-actions .qty-control {
    height: 100%;
    width: 100%;
    border-radius: var(--radius-md);
}

/* Mode Grid Mobile (2 Kolom) */
.products-grid.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* Desktop Grid (5-6 Kolom) */
@media (min-width: 768px) {
    .products-grid.grid-2 {
        grid-template-columns: repeat(5, 1fr);
    }
}
@media (min-width: 1024px) {
    .products-grid.grid-2 {
        grid-template-columns: repeat(6, 1fr);
    }
}


.product-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-details-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-image-placeholder {
    width: 100%;
    aspect-ratio: 1;
    background-color: var(--bg-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    color: #ddd;
    font-size: 40px;
}

.product-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    background-color: var(--bg-color);
}

.product-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    line-height: 1.3;
    height: 34px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-price {
    font-size: 15px;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 5px;
}

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

.stock-badge {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.stock-badge.empty {
    background: #ffebee;
    color: #c62828;
}

.product-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: auto;
    width: 100%;
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-color);
    border-radius: var(--radius-pill);
    padding: 4px 10px;
    width: 100%;
    justify-content: space-between;
}

.qty-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 16px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-val {
    font-size: 14px;
    font-weight: 600;
}

.add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 8px;
    width: 100%;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.add-btn:active {
    background: var(--primary-dark);
}

.add-btn.disabled {
    background: #ccc;
    cursor: not-allowed;
    color: #888;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-color);
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bottom-sheet {
    margin-top: auto;
    height: 90vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
}

.modal-overlay.show .bottom-sheet {
    transform: translateY(0);
}

.center-modal {
    margin: auto;
    border-radius: var(--radius-lg);
    max-height: 90vh;
    transform: scale(0.9);
}

.scanner-modal-content {
    background: var(--card-bg);
}

#reader {
    width: 100%;
    padding: 15px;
    border: none;
}
#reader video {
    border-radius: var(--radius-md);
}

.modal-overlay.show .center-modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    border-radius: inherit;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}

/* Cart Items */
.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-item {
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.cart-item-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 5px;
}

.cart-item-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-color);
}

/* Shipping Options */
.shipping-options {
    background: var(--card-bg);
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

.shipping-options h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--text-main);
}

.shipping-radio {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

/* Cart Footer */
.cart-footer {
    background: var(--card-bg);
    padding: 15px 20px 20px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cart-summary {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-muted);
}

.total-row {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed var(--border-color);
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    width: 100%;
}

.checkout-btn {
    background: #25D366; /* WhatsApp green */
}

/* Banner Modal */
.banner-modal-content {
    background: transparent;
    box-shadow: none;
    position: relative;
    padding: 20px;
}
.popup-banner-img {
    width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.banner-close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: white;
    width: 30px;
    height: 30px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    z-index: 10;
}
.banner-footer {
    margin-top: 15px;
}

/* PWA Prompt */
.pwa-prompt {
    position: fixed;
    bottom: 20px;
    left: 15px;
    right: 15px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 15px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 150;
    transform: translateY(150%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.pwa-prompt.show {
    transform: translateY(0);
}
.pwa-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.pwa-info i {
    font-size: 24px;
    color: var(--primary-color);
}
.pwa-info p {
    font-size: 12px;
    color: var(--text-muted);
}
.pwa-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.pwa-btn-install {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 13px;
}
.pwa-btn-close {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
    padding: 7px 12px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    cursor: pointer;
}

/* Utils */
.loading-state, .empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    z-index: 300;
    transition: transform 0.3s, opacity 0.3s, visibility 0.3s;
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
}

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

/* Grouped View (Homepage Category Grouping) */
.products-grid.grouped-view {
    display: block; /* Override any grid */
}
.category-group {
    margin-bottom: 25px;
}
.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.category-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}
.view-all-link {
    font-size: 13px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
.category-horizontal-list {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 15px;
    scrollbar-width: none; /* Firefox */
}
.category-horizontal-list::-webkit-scrollbar {
    display: none; /* Chrome */
}
.category-horizontal-list .product-card {
    min-width: 150px;
    width: 150px;
    flex-shrink: 0;
}
