/* style.css - Linear.app-inspired Theme */

:root {
  --bg: #F8F9FA;
  --surface: #FFFFFF;
  --surface-2: #F1F3F5;
  --border: #E9ECEF;
  --text: #111827;
  --text-muted: #6B7280;
  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --positive: #059669;
  --warn: #D97706;
  --negative: #DC2626;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: -0.5px; }
a { text-decoration: none; color: inherit; }

/* Global Utilities */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-positive { color: var(--positive); }
.text-warn { color: var(--warn); }
.font-bold { font-weight: 700; }
.tabular { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

/* Labels & Badges */
.label-small {
  font-size: 12px; font-weight: 600; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--text-muted);
}
.badge {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 4px; font-size: 12px; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.badge--active { border-color: var(--text); color: var(--text); }
.badge--primary { border-color: var(--accent); color: var(--accent); }
button.badge { cursor: pointer; background: var(--surface-2); transition: border-color 0.15s, color 0.15s; }
button.badge:hover { border-color: var(--text-muted); color: var(--text); }
.subcat-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* Catalog controls bar */
.catalog-controls { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.catalog-toolbar { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Sort dropdown */
.sort-wrap { position: relative; }
.sort-btn { font-size: 12px; padding: 4px 10px; white-space: nowrap; }
.sort-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 100;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  min-width: 180px; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.sort-option {
  display: block; width: 100%; text-align: left; padding: 8px 14px;
  font-size: 13px; color: var(--text-muted); background: none; border: none;
  cursor: pointer; transition: background 0.1s, color 0.1s;
}
.sort-option:hover { background: var(--surface-2); color: var(--text); }
.sort-option.active { color: var(--text); font-weight: 600; }

/* Layout toggle */
.layout-toggle { display: flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.layout-btn {
  padding: 4px 9px; font-size: 14px; background: none; border: none;
  color: var(--text-muted); cursor: pointer; transition: background 0.1s, color 0.1s;
}
.layout-btn.active { background: var(--surface-2); color: var(--text); }
.layout-btn:hover:not(.active) { background: var(--surface-2); }

/* Grid layout */
.grocery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.grocery-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; display: flex; flex-direction: column; transition: border-color 0.15s;
}
.grocery-card:hover { border-color: var(--text-muted); }
.grocery-card-img { width: 100%; height: 140px; object-fit: contain; background: var(--surface-2); padding: 12px; box-sizing: border-box; }
.grocery-card-img--empty { background: var(--surface-2); height: 140px; }
.grocery-card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.grocery-card-name { font-size: 13px; font-weight: 600; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.grocery-card-meta { font-size: 11px; color: var(--text-muted); }
.grocery-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; }
.grocery-card-price { font-size: 15px; font-weight: 700; }
.grocery-card-store { font-size: 11px; font-weight: 600; text-transform: uppercase; }
.grocery-card-ppu { font-size: 11px; color: var(--text-muted); }

/* Inputs & Buttons */
.input-base {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 0 16px; font-family: 'Inter', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s; outline: none; width: 100%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.input-base:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2); }
.input-lg { height: 48px; font-size: 16px; }

.btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 0 16px; height: 36px;
  font-weight: 500; cursor: pointer; transition: 0.2s; display: inline-flex;
  align-items: center; justify-content: center; font-family: 'Inter', sans-serif;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-lg { height: 48px; font-size: 15px; font-weight: 600; padding: 0 24px; }

/* Layout Components */
.site-header {
  background: var(--bg); border-bottom: 1px solid var(--border);
  height: 48px; position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1100px; margin: 0 auto; height: 100%; padding: 0 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.logo { font-size: 16px; font-weight: 700; color: var(--accent); letter-spacing: -0.5px; }
.main-nav { display: flex; gap: 24px; height: 100%; }
.nav-link {
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  display: flex; align-items: center; position: relative; transition: color 0.15s;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); }
.nav-link.active::after {
  content: ""; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 2px; background: var(--accent);
}

.page-content { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }
.page-title { font-size: 28px; margin-bottom: 6px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }

/* Table Reset */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600;
  letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--surface-2); }

/* Loader */
.spinner {
  width: 24px; height: 24px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 0; gap: 16px; }
.empty-box { text-align: center; padding: 64px 0; color: var(--text-muted); font-size: 15px; border: 1px dashed var(--border); border-radius: 6px; }

/* Groceries Specific */
.search-hero { display: flex; gap: 12px; margin-bottom: 16px; }
.search-input-wrap { flex: 1; }
.baskets-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 32px; }

.product-row-inner { display: flex; align-items: center; gap: 12px; }
.product-thumb { width: 32px; height: 32px; flex-shrink: 0; border-radius: 4px; object-fit: contain; background: var(--surface); border: 1px solid var(--border); }
.product-labels { display: flex; flex-direction: column; }
.product-name-found { font-size: 12px; color: var(--text-muted); margin-top: 2px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.price-item { display: inline-flex; align-items: center; gap: 6px; }
.price-link { color: var(--text); font-weight: 500; }
.price-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.price-best { color: var(--positive); font-weight: 700; }
.alt-toggle { color: var(--text-muted); font-size: 11px; cursor: pointer; user-select: none; }
.alt-toggle:hover { color: var(--text); }
.alt-dropdown { margin-top: 8px; font-size: 12px; display: flex; flex-direction: column; gap: 6px; }

/* Tech Specific */
.tech-tabs { border-bottom: 1px solid var(--border); display: flex; gap: 24px; margin-bottom: 24px; }
.tech-tab { padding: 10px 0; color: var(--text-muted); font-weight: 500; font-size: 14px; position: relative; cursor: pointer; }
.tech-tab:hover { color: var(--text); }
.tech-tab.active { color: var(--text); }
.tech-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--text); }

.tech-filters-bar { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin: 16px 0; }
.range-slider { accent-color: var(--accent); }

.tech-list { display: flex; flex-direction: column; }
.tech-row { display: flex; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); gap: 16px; }
.tech-row:hover { background: var(--surface-2); margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-radius: 6px; border-bottom-color: transparent; }
.tech-row-img { width: 48px; height: 48px; object-fit: contain; border-radius: 4px; background: white; border: 1px solid var(--border); padding: 2px; }
.tech-row-info { flex: 1; min-width: 0; }
.tech-row-name { font-weight: 600; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tech-row-prices { display: flex; gap: 16px; margin-left: auto; align-items: center; }
.tech-store-col { font-size: 13px; color: var(--text-muted); display: flex; flex-direction: column; align-items: flex-end; }
.tech-store-name { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.tech-row-action { margin-left: 24px; font-weight: 500; font-size: 13px; color: var(--accent); white-space: nowrap; }
.tech-row-action:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 4px; }

/* AI Assist */
.ai-drawer { margin-top: 12px; margin-bottom: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); overflow: hidden; }
.ai-trigger { width: 100%; padding: 12px 16px; background: none; border: none; color: var(--text-muted); font-family: 'Inter'; font-size: 13px; font-weight: 500; text-align: left; cursor: pointer; display: flex; justify-content: space-between; }
.ai-trigger:hover { background: var(--surface-2); color: var(--text); }
.ai-content { border-top: 1px solid var(--border); padding: 16px; }
.ai-input-wrap { display: flex; gap: 8px; margin-bottom: 12px; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ai-chip { cursor: pointer; transition: 0.2s; background: var(--surface-2); border: 1px solid var(--border); }
.ai-chip-name { font-weight: 600; color: var(--text); }
.ai-chip-price { color: var(--text-muted); }
.ai-chip:hover { border-color: var(--accent); }

/* Catalog View */
.catalog-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.catalog-grid { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }

/* Warning Tooltips */
.warning-ico { color: var(--warn); font-size: 12px; margin-left: 4px; cursor: help; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  width: 100%; max-width: 560px; max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; font-size: 15px; }
.modal-close {
  background: none; border: none; color: var(--text-muted); font-size: 16px;
  cursor: pointer; padding: 4px 6px; border-radius: 4px; transition: color 0.1s;
}
.modal-close:hover { color: var(--text); }
.modal-body { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }

/* Basket edit rows */
.basket-edit-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.basket-edit-row:last-of-type { border-bottom: none; padding-bottom: 0; }
.basket-edit-fields { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.basket-edit-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.basket-new-form { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 0; }

/* Recipe modal */
.recipe-cat-header {
  padding: 8px 14px 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--text-muted); user-select: none;
}
.recipe-item {
  display: block; width: 100%; text-align: left; padding: 7px 14px; background: none;
  border: none; color: var(--text); font-size: 13px; cursor: pointer;
  transition: background 0.1s; border-left: 2px solid transparent;
}
.recipe-item:hover { background: var(--surface-2); }
.recipe-item.active { background: var(--surface-2); border-left-color: var(--accent); color: var(--accent); }

/* Ingredient chips */
.ingredient-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px;
  font-size: 12px; color: var(--text);
}
.chip-remove {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 14px; padding: 0 2px; line-height: 1; transition: color 0.1s;
}
.chip-remove:hover { color: var(--negative); }
