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

:root {
  --primary: #0C4A6E;
  --primary-light: #0369A1;
  --accent: #38BDF8;
  --accent-dark: #0EA5E9;
  --bg: #F0F9FF;
  --surface: #FFFFFF;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  min-height: 100vh; -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== Header ===== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--primary); color: white;
  padding: 12px 16px; box-shadow: var(--shadow-md);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 480px; margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 36px; height: 36px; flex-shrink: 0; }
.logo-text { font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; }
.logo-sub { font-size: 0.65rem; opacity: 0.7; }
.header-badge {
  position: relative; cursor: pointer; padding: 8px;
  border-radius: 50%; background: rgba(255,255,255,0.15); transition: background 0.2s;
}
.header-badge:active { background: rgba(255,255,255,0.3); }
.badge-count {
  position: absolute; top: -2px; right: -2px;
  background: var(--accent); color: var(--primary);
  font-size: 0.65rem; font-weight: 700;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white; padding: 32px 20px 28px; text-align: center;
}
.hero h1 { font-size: 1.6rem; font-weight: 700; line-height: 1.2; margin-bottom: 8px; letter-spacing: -0.02em; }
.hero p { font-size: 0.85rem; opacity: 0.85; margin-bottom: 16px; }
.hero-tags { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.hero-tags span {
  background: rgba(255,255,255,0.15); padding: 4px 12px;
  border-radius: 20px; font-size: 0.72rem; font-weight: 500; backdrop-filter: blur(4px);
}

/* ===== Category Nav ===== */
.category-nav {
  position: sticky; top: 60px; z-index: 90;
  background: var(--surface); display: flex; gap: 6px;
  padding: 10px 16px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.category-nav::-webkit-scrollbar { display: none; }
.cat-tab {
  flex-shrink: 0; padding: 6px 16px;
  border: 1.5px solid var(--border); border-radius: 20px;
  background: transparent; color: var(--text-secondary);
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
}
.cat-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.cat-tab:active { transform: scale(0.95); }

/* ===== Products ===== */
.products { padding: 16px; max-width: 480px; margin: 0 auto; }
.category-header {
  display: flex; align-items: center; gap: 8px;
  margin: 20px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--primary);
}
.category-header:first-child { margin-top: 4px; }
.category-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--primary); }
.category-header .cat-count {
  background: var(--primary); color: white;
  font-size: 0.65rem; font-weight: 600; padding: 2px 8px; border-radius: 10px;
}

/* Product Card */
.product-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden;
  transition: box-shadow 0.2s; border: 1px solid var(--border);
}
.product-card.has-items { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.product-main { display: flex; padding: 14px; gap: 14px; }
.product-img-placeholder {
  width: 72px; height: 72px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #E0F2FE, #BAE6FD);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-tags { display: flex; gap: 4px; margin-bottom: 4px; flex-wrap: wrap; }
.tag {
  font-size: 0.58rem; font-weight: 600; padding: 1px 6px;
  border-radius: 4px; text-transform: uppercase; letter-spacing: 0.03em;
}
.tag-popular { background: #FEF3C7; color: #92400E; }
.tag-premium { background: #EDE9FE; color: #5B21B6; }
.tag-new { background: #D1FAE5; color: #065F46; }
.tag-seasonal { background: #FFE4E6; color: #9F1239; }
.tag-weighable { background: #DBEAFE; color: #1E40AF; }
.tag-standard { background: #F1F5F9; color: #475569; }

.product-name { font-size: 0.88rem; font-weight: 600; line-height: 1.3; margin-bottom: 2px; }
.product-origin { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; }
.product-desc { font-size: 0.7rem; color: var(--text-secondary); margin-bottom: 6px; line-height: 1.4; }
.product-price { font-size: 0.95rem; font-weight: 700; color: var(--primary); }
.product-price .unit { font-size: 0.7rem; font-weight: 400; color: var(--text-muted); }
.product-market-price { font-size: 0.75rem; color: var(--warning); font-weight: 500; }
.weighable-hint {
  font-size: 0.65rem; color: var(--primary-light); margin-top: 2px;
  display: flex; align-items: center; gap: 3px;
}

/* Quantity Controls */
.product-actions { display: flex; align-items: center; justify-content: space-between; padding: 0 14px 14px; }
.qty-control {
  display: flex; align-items: center;
  background: var(--bg); border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--border);
}
.qty-btn {
  width: 40px; height: 40px; border: none; background: transparent;
  font-size: 1.2rem; font-weight: 600; color: var(--primary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; font-family: inherit;
}
.qty-btn:active { background: var(--accent); color: white; }
.qty-btn:disabled { color: var(--text-muted); cursor: not-allowed; }
.qty-input {
  width: 56px; text-align: center; border: none; background: white;
  font-size: 0.9rem; font-weight: 600; color: var(--text);
  font-family: inherit; padding: 8px 0;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}
.qty-input:focus { outline: none; background: #F0F9FF; }
.qty-unit { font-size: 0.7rem; color: var(--text-muted); padding: 0 8px; font-weight: 500; }

.add-btn {
  padding: 10px 20px; background: var(--primary); color: white;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
}
.add-btn:active { transform: scale(0.95); background: var(--primary-light); }
.remove-btn {
  padding: 10px 16px; background: transparent; color: var(--danger);
  border: 1px solid var(--danger); border-radius: var(--radius-sm);
  font-size: 0.75rem; font-weight: 600; cursor: pointer; font-family: inherit;
}

/* ===== Floating Cart ===== */
.cart-float {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 80; width: calc(100% - 32px); max-width: 448px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(100%); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
.cart-float-inner {
  background: var(--primary); color: white;
  padding: 14px 18px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); display: flex;
  align-items: center; justify-content: space-between; cursor: pointer;
}
.cart-float-inner:active { opacity: 0.9; }
#cartFloatItems { font-size: 0.8rem; opacity: 0.85; }
#cartFloatTotal { font-size: 1.05rem; font-weight: 700; }
.cart-float-btn {
  background: var(--accent); color: var(--primary);
  padding: 6px 14px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}

/* ===== Checkout Section ===== */
.checkout-section { padding: 24px 16px; max-width: 480px; margin: 0 auto; }
.section-title {
  font-size: 1.1rem; font-weight: 700; color: var(--text);
  margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--primary);
}
.empty-cart { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-cart svg { margin-bottom: 12px; }
.empty-cart p { font-size: 0.85rem; }

/* Order Items */
.order-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.order-item-info { flex: 1; }
.order-item-name { font-size: 0.85rem; font-weight: 600; }
.order-item-detail { font-size: 0.72rem; color: var(--text-muted); }
.order-item-weighable {
  font-size: 0.62rem; color: var(--primary-light);
  display: inline-flex; align-items: center; gap: 2px; margin-top: 2px;
}
.order-item-total {
  font-size: 0.9rem; font-weight: 700; color: var(--primary);
  white-space: nowrap; margin-left: 12px;
}
.order-item-remove {
  background: none; border: none; color: var(--danger);
  font-size: 0.7rem; cursor: pointer; padding: 4px 8px; margin-left: 8px; font-family: inherit;
}

/* Order Total */
.order-total {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; margin-top: 16px; border: 1px solid var(--border);
}
.total-row {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: 0.85rem; color: var(--text-secondary);
}
.total-row.delivery-note { font-size: 0.75rem; color: var(--success); }
.total-row.total-final {
  border-top: 2px solid var(--primary); margin-top: 8px; padding-top: 12px;
  font-size: 1.05rem; font-weight: 700; color: var(--text);
}
.total-hint {
  font-size: 0.68rem; color: var(--text-muted); margin-top: 10px;
  font-style: italic; line-height: 1.4;
}

/* ===== Customer Form ===== */
.customer-form { margin-top: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group input,
.form-group textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.9rem; font-family: inherit; color: var(--text);
  background: var(--surface); transition: border-color 0.2s; -webkit-appearance: none;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }
.form-group textarea { resize: vertical; }

/* Submit Button */
.submit-btn {
  width: 100%; padding: 16px; background: var(--primary); color: white;
  border: none; border-radius: var(--radius); font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: all 0.2s; font-family: inherit; margin-top: 8px;
}
.submit-btn:active { transform: scale(0.98); background: var(--primary-light); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.spinner {
  width: 20px; height: 20px; display: inline-block;
  vertical-align: middle; margin-right: 8px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--surface); border-radius: 16px; padding: 32px 24px;
  text-align: center; max-width: 360px; width: 100%; animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-icon { font-size: 3rem; margin-bottom: 12px; }
.modal-content h2 { font-size: 1.3rem; margin-bottom: 8px; }
.modal-content p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 6px; }
.modal-sub { font-size: 0.78rem !important; color: var(--text-muted) !important; margin-top: 8px !important; }
.modal-sub a { color: var(--primary); }
.modal-note {
  font-size: 0.72rem !important; color: var(--primary-light) !important;
  background: #F0F9FF; padding: 10px; border-radius: 8px; margin-top: 12px !important;
  line-height: 1.4;
}
.modal-btn {
  margin-top: 20px; padding: 14px 32px; background: var(--primary); color: white;
  border: none; border-radius: var(--radius); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}

/* ===== Footer ===== */
.footer {
  background: var(--primary); color: white; padding: 24px 16px;
  text-align: center; margin-top: 20px;
}
.footer-info p { font-size: 0.75rem; opacity: 0.85; margin-bottom: 4px; }
.footer-info a { color: var(--accent); text-decoration: none; }
.footer-copy { font-size: 0.65rem; opacity: 0.5; margin-top: 16px; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white; padding: 10px 20px;
  border-radius: 20px; font-size: 0.8rem; font-weight: 500;
  z-index: 150; animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
  box-shadow: var(--shadow-lg);
}
@keyframes toastIn {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.shake { animation: shake 0.3s ease; }

@media (min-width: 481px) {
  .products, .checkout-section { max-width: 480px; }
}
