/* ── Reset & Base ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --green-200: #bbf7d0;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --green-700: #15803d;
    --green-800: #166534;
    --stone-50: #fafaf9;
    --stone-100: #f5f5f4;
    --stone-200: #e7e5e4;
    --stone-700: #44403c;
    --stone-800: #292524;
    --stone-900: #1c1917;
    --white: #ffffff;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 16px;
    --radius-sm: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--green-50);
    color: var(--stone-800);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    padding-bottom: 24px;
}

/* ── Header ───────────────────────────────── */
.header {
    background: linear-gradient(135deg, var(--green-700), var(--green-600));
    color: var(--white);
    padding: 20px 16px 16px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow);
}

.header-top {
    margin-bottom: 12px;
}

.header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.subtitle {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 2px;
}

.search-bar {
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: rgba(255,255,255,0.95);
    color: var(--stone-800);
    outline: none;
    transition: box-shadow 0.2s;
}

.search-bar input:focus {
    box-shadow: 0 0 0 3px rgba(255,255,255,0.4);
}

/* ── Categories ────────────────────────────── */
.categories {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding: 12px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--stone-100);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

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

.cat-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border: 1.5px solid var(--stone-200);
    border-radius: 20px;
    background: var(--white);
    font-size: 13px;
    font-weight: 500;
    color: var(--stone-700);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.cat-tab:hover {
    border-color: var(--green-200);
    background: var(--green-50);
}

.cat-tab.active {
    background: var(--green-600);
    color: var(--white);
    border-color: var(--green-600);
}

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

.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 0;
    color: var(--stone-700);
    font-size: 14px;
}

/* ── Product Card ──────────────────────────── */
.product-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

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

.card-image {
    width: 100%;
    height: 140px;
    background: linear-gradient(135deg, var(--green-100), var(--green-50));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

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

.card-body {
    padding: 10px 12px 12px;
}

.card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--stone-900);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

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

.card-seller {
    font-size: 11px;
    color: var(--stone-700);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.card-stock {
    font-size: 11px;
    color: var(--stone-700);
    margin-top: 2px;
}

/* ── Load More ─────────────────────────────── */
.load-more {
    text-align: center;
    padding: 12px 16px;
}

.load-more button {
    padding: 10px 32px;
    border: 1.5px solid var(--green-500);
    border-radius: 24px;
    background: var(--white);
    color: var(--green-600);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.load-more button:hover {
    background: var(--green-50);
}

/* ── Empty State ───────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--stone-700);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.empty-state p {
    font-size: 15px;
}

/* ── Modal ─────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.5);
    color: var(--white);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.modal-image {
    width: 100%;
    height: 240px;
    background: linear-gradient(135deg, var(--green-100), var(--green-50));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    position: relative;
}

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

.modal-body {
    padding: 20px;
}

.modal-body h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--stone-900);
    margin-bottom: 6px;
}

.modal-category {
    display: inline-block;
    padding: 3px 10px;
    background: var(--green-100);
    color: var(--green-700);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 10px;
}

.modal-price {
    font-size: 24px;
    font-weight: 800;
    color: var(--green-700);
    margin-bottom: 12px;
}

.modal-seller {
    font-size: 14px;
    color: var(--stone-700);
    margin-bottom: 4px;
}

.seller-addr {
    font-size: 12px;
    opacity: 0.7;
    margin-left: 4px;
}

.modal-desc {
    font-size: 14px;
    color: var(--stone-700);
    line-height: 1.6;
    margin: 12px 0;
    padding-top: 12px;
    border-top: 1px solid var(--stone-100);
}

.modal-stock {
    font-size: 13px;
    color: var(--stone-700);
    margin-bottom: 16px;
    padding: 8px 12px;
    background: var(--stone-50);
    border-radius: 8px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.btn-order {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--green-600);
    color: var(--white);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.btn-order:active {
    background: var(--green-700);
}

/* ── Skeleton Loading ──────────────────────── */
.skeleton {
    animation: shimmer 1.5s infinite;
    background: linear-gradient(90deg, var(--stone-100) 25%, var(--stone-50) 50%, var(--stone-100) 75%);
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.skeleton-img {
    height: 140px;
}

.skeleton-text {
    height: 14px;
    margin: 10px 12px;
    border-radius: 4px;
}

.skeleton-text.short {
    width: 60%;
    margin-bottom: 12px;
}
