:root {
    --primary: #0f172a;
    --accent: #2563eb;
    --success: #16a34a;
    --background: #f8fafc;
    --card: #ffffff;
    --muted: #64748b;
    --ink: #0f172a;
    --on-primary: #ffffff;
    --on-accent: #ffffff;
    --primary-soft: #f1f5f9;
    --accent-soft: #eff6ff;
    --accent-visible: #2563eb;
    --header-muted: #e2e8f0;
}

* { box-sizing: border-box; font-family: 'Tajawal', sans-serif; }
html, body { width: 100%; margin: 0; padding: 0; overflow-x: hidden; }
body { min-height: 100vh; background: var(--background); color: var(--ink); line-height: 1.4; }

.catalog-header { padding: 18px 12px 16px; border-bottom: 4px solid var(--accent-visible); background: var(--primary); color: var(--on-primary); text-align: center; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12); }
.store-logo { display: block; width: auto; max-width: 120px; height: auto; max-height: 70px; margin: 0 auto 8px; object-fit: contain; }
.catalog-header h1 { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 0 0 5px; font-size: 1.35rem; font-weight: 900; }
.catalog-header h1 i { color: var(--on-primary); opacity: 0.9; }
.catalog-header p { max-width: 680px; margin: 0 auto; color: var(--header-muted); font-size: 0.88rem; }

.catalog-container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px 10px 160px; }
.category-section { margin-bottom: 28px; }
.category-title { display: flex; align-items: center; gap: 8px; margin: 0 4px 12px; color: var(--ink); font-size: 1.15rem; font-weight: 900; }
.category-title i { color: var(--accent-visible); }
.category-title::after { content: ''; flex: 1; height: 2px; margin-right: 8px; background: var(--accent-soft); }

.products-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: center; gap: 10px; }
.product-card { display: flex; flex-direction: column; width: 100%; max-width: 280px; min-width: 0; overflow: hidden; border: 1px solid #e2e8f0; border-radius: 10px; background: var(--card); box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05); transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease; }
.product-card.is-selected { border-color: var(--accent-visible); box-shadow: 0 0 0 2px var(--accent-soft), 0 8px 15px rgba(15, 23, 42, 0.08); transform: translateY(-2px); }
.product-image-wrapper { position: relative; width: 100%; height: 180px; max-height: 180px; overflow: hidden; padding: 10px; border-bottom: 1px solid #f1f5f9; background: #f8fafc; }
.product-image { display: block; position: static; width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; object-position: center; }
.product-details { display: flex; flex: 1; flex-direction: column; width: 100%; padding: 8px 7px; text-align: center; }
.product-name { margin: 0 0 4px; color: var(--ink); font-size: 0.88rem; font-weight: 900; line-height: 1.35; }
.product-category { margin: 0 0 8px; color: var(--muted); font-size: 0.7rem; font-weight: 700; }
.variants-heading { margin: 0 0 5px; color: var(--muted); font-size: 0.7rem; font-weight: 800; }
.product-variants { display: flex; flex-direction: column; gap: 7px; margin-top: auto; }
.product-variant { padding: 6px; border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; }
.variant-size { display: block; margin-bottom: 5px; color: var(--accent-visible); font-size: 0.75rem; font-weight: 900; }

.quantity-control { display: flex; width: 100%; overflow: hidden; border: 1px solid #cbd5e1; border-radius: 7px; background: #ffffff; direction: ltr; }
.quantity-button { width: 38px; min-height: 38px; flex: 0 0 38px; padding: 0; border: 0; background: var(--primary-soft); color: var(--ink); font-size: 1.2rem; font-weight: 900; cursor: pointer; touch-action: manipulation; }
.quantity-button:active { background: var(--accent-soft); }
.quantity-input { width: 100%; min-width: 0; min-height: 38px; padding: 4px; border: 0; border-right: 1px solid #e2e8f0; border-left: 1px solid #e2e8f0; outline: 0; background: #ffffff; color: var(--ink); font: inherit; font-weight: 900; text-align: center; appearance: textfield; }
.quantity-input::-webkit-inner-spin-button,
.quantity-input::-webkit-outer-spin-button { margin: 0; appearance: none; }

.order-bar { position: sticky; bottom: 0; z-index: 100; width: 100%; padding: 8px 10px; border-top: 2px solid var(--accent-visible); background: rgba(255, 255, 255, 0.98); box-shadow: 0 -5px 18px rgba(15, 23, 42, 0.12); backdrop-filter: blur(8px); }
.order-bar-inner { display: grid; grid-template-columns: minmax(170px, 0.8fr) minmax(190px, 1fr) minmax(220px, 1fr) auto; align-items: end; gap: 8px 12px; width: 100%; max-width: 1200px; margin: 0 auto; }
.order-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 0.85rem; }
.order-summary strong { color: var(--accent-visible); }
.order-customer, .order-notes { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 0.72rem; font-weight: 800; }
.order-customer input, .order-notes textarea { width: 100%; min-height: 42px; padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 7px; outline: 0; color: var(--ink); background: #ffffff; font: inherit; }
.order-notes textarea { max-height: 80px; resize: vertical; }
.order-customer input:focus, .order-notes textarea:focus { border-color: var(--accent-visible); box-shadow: 0 0 0 2px var(--accent-soft); }
.whatsapp-button { min-height: 44px; padding: 8px 15px; border: 2px solid var(--accent-visible); border-radius: 8px; background: var(--accent); color: var(--on-accent); box-shadow: 0 3px 9px rgba(15, 23, 42, 0.16); font-family: 'Tajawal', sans-serif; font-size: 0.9rem; font-weight: 900; cursor: pointer; white-space: nowrap; }
.whatsapp-button:hover { box-shadow: 0 5px 13px rgba(15, 23, 42, 0.2); transform: translateY(-1px); }
.whatsapp-button:disabled { cursor: wait; opacity: 0.7; }
.order-feedback { grid-column: 1 / -1; min-height: 0; margin: 0; color: #b91c1c; font-size: 0.78rem; font-weight: 800; }
.order-feedback.is-info { color: var(--muted); }
.empty-catalog { padding: 50px 15px; border: 1px solid #e2e8f0; border-radius: 12px; background: #ffffff; color: var(--muted); text-align: center; }
.empty-catalog i { margin-bottom: 12px; font-size: 3rem; }
.empty-catalog h2 { margin: 0; font-size: 1.05rem; }

@media (min-width: 600px) {
    .products-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 280px)); gap: 16px; }
}

@media (min-width: 1024px) {
    .products-grid { grid-template-columns: repeat(4, minmax(220px, 280px)); gap: 16px; }
}

@media (max-width: 700px) {
    .catalog-container { padding-bottom: 185px; }
    .product-image-wrapper { height: 130px; max-height: 130px; padding: 8px; }
    .order-bar-inner { grid-template-columns: 1fr; gap: 6px; }
    .order-summary { justify-content: space-between; gap: 5px 8px; font-size: 0.8rem; }
    .order-customer input,
    .order-notes textarea { min-height: 38px; }
    .whatsapp-button { width: 100%; }
}

@media (max-width: 329px) {
    .products-grid { grid-template-columns: minmax(0, 280px); gap: 8px; }
    .product-card { margin: 0 auto; }
    .product-image-wrapper { height: 150px; max-height: 150px; }
    .product-details { padding: 7px 6px; }
}
