:root {
    --primary: #1b4332;
    --secondary: #2d6a4f;
    --accent: #ffd700;
    --light-bg: #f4f7f6;
    --white: #ffffff;
    --text-dark: #333;
    --border-radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--light-bg);
    overflow-x: hidden;
}

/* NAVBAR */
nav.top-bar {
    background: var(--white);
    padding: 15px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--primary);
    font-size: 1.2rem;
    text-decoration: none;
    cursor: pointer;
}

.logo img {
    display: block;
    height: 40px;
    width: auto;
    object-fit: contain;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

#search-input {
    width: 0;
    opacity: 0;
    padding: 8px 0;
    border: none;
    border-bottom: 2px solid var(--primary);
    transition: all 0.4s ease;
    outline: none;
    font-size: 0.85rem;
}

#search-input.active {
    width: 130px;
    opacity: 1;
    padding: 8px 5px;
    margin-right: 10px;
}

.search-btn {
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.cart-icon-btn {
    position: relative;
    cursor: pointer;
    font-size: 1.2rem;
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -10px;
    background: #e74c3c;
    color: white;
    font-size: 9px;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* SLIDER */
.slider-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 12px 0;
    overflow: hidden;
    position: relative;
}

.slider-container {
    width: 100%;
    overflow: hidden;
    border-radius: var(--border-radius);
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.slider-wrapper {
    display: flex;
    transition: transform 0.5s ease-in-out;
}

.slide {
    min-width: 100%;
    position: relative;
}

.slide img {
    width: 100%;
    height: 180px;
    display: block;
    object-fit: cover;
}

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

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

.dot.active {
    background: var(--white);
    width: 20px;
    border-radius: 10px;
}

/* CONTAINER */
.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 12px;
}

.main-title {
    font-size: 1.3rem;
    color: var(--primary);
    margin-bottom: 15px;
    font-weight: 700;
}

.breadcrumb {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 20px;
}

.breadcrumb span {
    cursor: pointer;
}

.breadcrumb span:hover {
    color: var(--primary);
}

/* FILTERS */
.category-filters {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 15px;
    scrollbar-width: none;
}

.filter-btn {
    background: var(--white);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

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

/* KATALOG GRID - PERBAIKAN DI SINI */
#produk-list,
#category-produk-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.card {
    background: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%; /* Memastikan kartu memenuhi grid */
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.card-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    cursor: pointer;
}

.card-body {
    padding: 12px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Membatasi teks judul agar tidak merusak layout */
.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    height: 2.8em; /* Mengunci tinggi untuk persis 2 baris */
    color: var(--primary);
    cursor: pointer;
    margin-bottom: 8px;
    
    /* Teknik Line-clamp untuk memotong teks dengan titik-titik (...) */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
}

.price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--secondary);
    margin-top: auto; /* Mendorong harga dan tombol ke paling bawah kartu */
}

.stock-info {
    font-size: 0.75rem;
    color: #666;
    margin: 5px 0 10px 0;
}

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

.btn-add:hover {
    background: var(--secondary);
}

.btn-add.disabled {
    background: #b0b0b0;
    cursor: not-allowed;
}

.badge-habis {
    position: absolute;
    top: 10px;
    left: -30px;
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    padding: 4px 30px;
    transform: rotate(-45deg);
    z-index: 10;
}

/* DETAIL PAGE */
#detail-page {
    display: none;
    padding-top: 10px;
}

#detail-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
    background: var(--white);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.detail-img-wrapper {
    position: relative;
    text-align: center;
}

.detail-img-wrapper img {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    object-fit: contain;
    background: #f9f9f9;
}

.detail-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.detail-info h1 {
    font-size: 1.3rem;
    color: var(--primary);
    line-height: 1.3;
}

.detail-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--secondary);
}

.detail-desc {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.6;
}

.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.btn-cart-detail {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    font-size: 0.85rem;
}

.btn-cart-detail:hover {
    background: var(--secondary);
}

.btn-cart-detail.disabled {
    background: #b0b0b0;
    cursor: not-allowed;
}

.btn-wa-detail {
    background: #25d366;
    color: white;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-wa-detail.disabled {
    background: #b0b0b0;
    cursor: not-allowed;
    text-decoration: none;
}

.meta-info {
    border-top: 1px solid #eee;
    padding-top: 15px;
    font-size: 0.8rem;
    color: #777;
}

.meta-info .meta-item {
    margin-bottom: 5px;
}

.meta-info .meta-item span[onclick] {
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
}

/* CHECKOUT */
#checkout-page {
    display: none;
    padding-top: 10px;
}

.checkout-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
    margin-top: 20px;
}

.checkout-form-container,
.checkout-summary-container {
    background: var(--white);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.05);
}

.checkout-summary-container {
    background: #f9fdf9;
    border: 1px solid #d4e8d4;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2f0e2;
    padding-bottom: 12px;
}

.section-header i {
    background: #e2f0e2;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--primary);
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: #3a5e4a;
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid #e0ebe0;
    border-radius: 14px;
    font-family: inherit;
    font-size: 0.9rem;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(27,67,50,0.08);
    outline: none;
}

.checkout-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid #e2f0e2;
}

.checkout-item-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 12px;
    background: #f0f8f0;
}

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

.checkout-item-info h4 {
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: var(--primary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.checkout-item-price {
    font-weight: 600;
    color: var(--secondary);
    font-size: 0.85rem;
}

.checkout-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkout-qty-btn {
    background: #f0f8f0;
    border: 1px solid #c8dcc0;
    color: var(--primary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

.checkout-qty-btn:hover {
    background: var(--primary);
    color: white;
}

.checkout-qty-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.checkout-remove-btn {
    color: #e74c3c;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
}

.checkout-totals {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px dashed #c8dcc0;
}

.total-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.total-line.grand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #d4e8d4;
}

.shipping-options {
    background: #fff;
    padding: 15px;
    border-radius: 16px;
    border: 1px solid #d4e8d4;
}

.btn-pay {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 40px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.btn-pay:hover {
    background: var(--secondary);
}

/* AUTOCOMPLETE */
.autocomplete-wrapper {
    position: relative;
}

#kota-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #fff;
    color: #333;
    border-radius: 14px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border: 1px solid #d4e8d4;
    margin-top: 5px;
}

.dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #e2f0e2;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: #f0f8f0;
}

/* CART MODAL */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    z-index: 998;
    backdrop-filter: blur(4px);
}

#cart-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 500px;
    background: var(--white);
    border-radius: 20px;
    z-index: 999;
    display: none;
    flex-direction: column;
    padding: 25px;
    transition: 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

#cart-modal.active {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
}

.cart-items-container {
    max-height: 300px;
    overflow-y: auto;
    margin: 15px 0;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.cart-item-img {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border-radius: 8px;
}

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

.cart-item-info h4 {
    font-size: 0.85rem;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-info p {
    font-size: 0.75rem;
    color: #666;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.qty-btn {
    background: #eee;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
}

.qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* FOOTER */
.footer-centered {
    background: #edf5e9;
    border-top: 1px solid #c8dcc0;
    padding: 40px 20px 30px;
    text-align: center;
    margin-top: 50px;
}

.footer-centered h3 {
    color: var(--primary);
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.footer-tagline-main {
    font-size: 1rem;
    color: var(--secondary);
    margin-bottom: 5px;
    letter-spacing: 2px;
}

.footer-tagline-second {
    font-size: 0.9rem;
    color: #4a6b5a;
    font-style: italic;
    margin-bottom: 20px;
}

.footer-desc {
    color: #2d4a3a;
    max-width: 550px;
    margin: 0 auto 20px;
    font-size: 0.9rem;
}

.footer-hours {
    background: rgba(255,255,255,0.5);
    display: inline-block;
    padding: 6px 18px;
    border-radius: 40px;
    font-size: 0.85rem;
}

.copyright-simple {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #c8dcc0;
    color: #3b5e4a;
    font-size: 0.8rem;
}

/* TOAST */
#toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
}

.toast {
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.8rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* RESPONSIVE */
@media (min-width: 600px) {
    .slide img {
        height: 300px;
    }
    
    #produk-list,
    #category-produk-list {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .card-img {
        height: 220px;
    }
    
    #detail-content {
        grid-template-columns: 1fr 1fr;
        gap: 30px;
        padding: 30px;
    }
    
    .detail-img-wrapper img {
        max-height: 400px;
    }
}

@media (min-width: 768px) {
    .checkout-layout {
        grid-template-columns: 1fr 400px;
    }
}