/* ============================================================
   Stitchr - Main Stylesheet
   Font: Inter (Google Fonts)
   Palette: soft, craft-store warm tones
   ============================================================ */

:root {
  --bg:           #faf8f5;
  --surface:      #ffffff;
  --border:       #e8e3da;
  --border-light: #f0ece4;
  --text:         #2d2926;
  --text-secondary: #7a726a;
  --text-muted:   #b0a89e;
  --accent:       #c47c5a;
  --accent-light: #f5e8de;
  --accent-dark:  #a35f3f;
  --green:        #5a8a6a;
  --green-light:  #e8f4ec;
  --red-soft:     #e05a5a;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.07);
  --shadow-md:    0 4px 12px rgba(0,0,0,.10);
  --radius:       12px;
  --radius-sm:    8px;
  --radius-pill:  999px;
  --font:         'Inter', system-ui, -apple-system, sans-serif;
}

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

html {
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.logo-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.logo-text {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--accent);
}

.app-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: .9rem;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  transition: background .15s, color .15s;
}

.nav-link:hover {
  background: var(--accent-light);
  color: var(--accent-dark);
}

.nav-link.active {
  background: var(--accent-light);
  color: var(--accent-dark);
}

/* ── Main ────────────────────────────────────── */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ── Page header ─────────────────────────────── */
.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}

.page-subtitle {
  font-size: .9rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Search bar ──────────────────────────────── */
.search-bar-wrap {
  margin-bottom: 16px;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 16px;
  transition: border-color .2s;
}

.search-bar:focus-within {
  border-color: var(--accent);
}

.search-icon {
  font-size: 1rem;
  margin-right: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text);
  padding: 13px 0;
  line-height: 1;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .95rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 50%;
  line-height: 1;
  display: none;
  transition: color .15s;
}

.search-clear:hover {
  color: var(--text);
}

/* ── Filter bar ──────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  flex: 1;
  text-align: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
  transition: all .15s;
}

.tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Color grid ──────────────────────────────── */
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

/* ── Color card ──────────────────────────────── */
.color-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .1s;
  display: flex;
  flex-direction: column;
}

.color-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.color-card.out-of-stock {
  opacity: .65;
}

.color-card.out-of-stock .swatch {
  opacity: .55;
}

.swatch {
  height: 80px;
  width: 100%;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0,0,0,.07);
}

.swatch-lg {
  height: 60px;
  width: 60px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

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

.card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dmc-number {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.color-name {
  font-size: .95rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.hex-code {
  font-size: .75rem;
  color: var(--text-muted);
  font-family: monospace;
}

/* ── Stock controls ──────────────────────────── */
.stock-controls {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
  align-self: flex-start;
}

.stock-btn {
  background: none;
  border: none;
  color: var(--accent-dark);
  font-size: 1.2rem;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  line-height: 1;
  transition: background .15s;
  min-width: 40px;
  min-height: 40px;
}

.stock-btn:hover {
  background: var(--accent-light);
}

.stock-btn:active {
  background: var(--border);
}

.stock-count {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  min-width: 36px;
  text-align: center;
  padding: 0 4px;
}

/* ── Action buttons ──────────────────────────── */
.action-btn {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
  min-height: 40px;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-light);
}

.action-btn.on-list {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
}

.action-btn.purchased-btn {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
}

.action-btn.purchased-btn:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.action-btn.remove-btn {
  color: var(--red-soft);
  border-color: transparent;
  background: none;
}

.action-btn.remove-btn:hover {
  background: #fef2f2;
  border-color: var(--red-soft);
}

/* ── Shopping list ───────────────────────────── */
.shopping-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shopping-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}

.shopping-item:hover {
  box-shadow: var(--shadow-md);
}

.item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.item-actions .action-btn {
  width: auto;
  white-space: nowrap;
}

/* ── Empty state ─────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: .5;
}

.empty-text {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.empty-sub {
  font-size: .9rem;
}

.empty-sub a {
  color: var(--accent);
  text-decoration: none;
}

.empty-sub a:hover {
  text-decoration: underline;
}

/* ── No results ──────────────────────────────── */
.no-results {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .header-inner {
    padding: 0 16px;
  }

  .main-content {
    padding: 20px 16px 48px;
  }

  .color-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .swatch {
    height: 64px;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .shopping-item {
    flex-wrap: wrap;
  }

  .item-actions {
    width: 100%;
    flex-direction: column;
  }

  .item-actions .action-btn {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .color-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Sticky search + tabs ──────────────────── */
.search-bar-wrap {
  position: sticky;
  top: 60px; /* below header */
  z-index: 90;
  background: var(--bg);
  padding-top: 12px;
  padding-bottom: 4px;
}

.tab-bar {
  position: sticky;
  top: 124px; /* below header + search */
  z-index: 89;
  background: var(--bg);
  padding-bottom: 12px;
}

/* ── Print button ──────────────────────────── */
.print-bar {
  text-align: right;
  margin-bottom: 12px;
}

.print-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 500;
  padding: 10px 20px;
  cursor: pointer;
  transition: background .15s;
}

.print-btn:hover {
  background: var(--accent-dark);
}

/* ── Print styles ──────────────────────────── */


/* ── Mobile tab fixes ──────────────────────── */
@media (max-width: 600px) {
  .tab-bar {
    gap: 6px;
  }

  .tab-btn {
    font-size: .82rem;
    padding: 8px 10px;
    white-space: nowrap;
  }
}

@media (max-width: 380px) {
  .tab-btn {
    font-size: .75rem;
    padding: 8px 6px;
  }
}

/* ── Print styles ──────────────────────────── */
@media print {
  .app-header,
  .search-bar-wrap,
  .tab-bar,
  .print-bar,
  .stock-controls,
  .card-actions,
  .no-results {
    display: none !important;
  }

  body {
    background: #fff;
    font-size: 11pt;
  }

  .main-content {
    padding: 0 12px;
    max-width: 100%;
  }

  .color-grid {
    display: block !important;
  }

  .color-grid::before {
    content: "Stitchr Shopping List";
    display: block;
    font-size: 16pt;
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid #333;
  }

  .color-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    border: none !important;
    border-bottom: 1px solid #ddd !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 5px 0 !important;
    margin: 0 !important;
    page-break-inside: avoid;
    background: #fff !important;
  }

  .color-card[style*="display: none"] {
    display: none !important;
  }

  .swatch {
    width: 20px !important;
    height: 20px !important;
    min-height: 20px !important;
    border-radius: 3px !important;
    margin-right: 10px !important;
    flex-shrink: 0;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .card-body {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: 0 !important;
    gap: 8px !important;
  }

  .card-info {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
  }

  .dmc-number {
    font-weight: 600;
    min-width: 65px;
    font-size: 10pt;
  }

  .color-name {
    font-size: 10pt;
  }

  .hex-code {
    display: none !important;
  }
}
