/* ===== Supplement Manager — Frost Theme ===== */

[data-theme="frost"] {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface2: #f0f2f5;
  --surface3: #e8eaed;
  --border: #d1d5db;
  --border-light: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --accent: #3b82f6;
  --accent-glow: #60a5fa;
  --green: #22c55e;
  --yellow: #eab308;
  --gray: #6b7280;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --red: #ef4444;
  --font-display: 'Inter', -apple-system, sans-serif;
  --font-body: 'Noto Sans SC', -apple-system, sans-serif;
}

/* ===== Reset ===== */
:root { --radius: 12px; --radius-sm: 8px; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ===== TopBar ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  background: rgba(245, 247, 250, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 24px; }
.topbar h1 {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.count { font-size: 13px; color: var(--text-dim); }
.icon-btn {
  background: none; border: none; font-size: 20px;
  color: var(--text-muted); cursor: pointer; padding: 4px 8px;
  border-radius: 8px; transition: background .2s;
}
.icon-btn:hover { background: var(--surface2); }

/* ===== Menu ===== */
.menu-dropdown {
  display: none;
  position: fixed; top: 52px; right: 16px; z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.1);
  padding: 6px;
  min-width: 160px;
}
.menu-dropdown.open { display: block; }
.menu-dropdown button,
.menu-dropdown .menu-item {
  display: block; width: 100%;
  padding: 10px 14px;
  background: none; border: none;
  text-align: left; font-size: 14px;
  color: var(--text); cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
}
.menu-dropdown button:hover,
.menu-dropdown .menu-item:hover {
  background: var(--surface2);
}

/* ===== Filters ===== */
.filters {
  position: sticky; top: 53px; z-index: 9;
  padding: 10px 16px 12px;
  background: var(--bg);
  display: flex; flex-direction: column; gap: 8px;
}
.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); pointer-events: none;
}
.filters input[type="text"],
.filters input[type="search"],
.filters #search {
  width: 100%;
  padding: 10px 12px 10px 36px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  color: var(--text); font-size: 14px;
  font-family: var(--font-body);
  transition: border-color .2s, box-shadow .2s;
}
.filters input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.filters input::placeholder { color: var(--text-dim); }

.chips {
  display: flex; gap: 6px; overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
  padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 13px; font-family: var(--font-body); font-weight: 400;
  cursor: pointer; transition: all .2s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--border); color: var(--text); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

/* ===== Sort Bar ===== */
.sort-bar {
  display: flex; gap: 6px;
  padding: 2px 16px 8px;
}
.sort-btn {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.sort-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* ===== Group Headers ===== */
.group-header {
  padding: 16px 16px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.group-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* ===== Cards ===== */
.cards {
  padding: 4px 16px 120px;
  display: flex; flex-direction: column; gap: 8px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all .2s ease;
  position: relative;
}
.card:active { transform: scale(.985); }
@media (hover: hover) {
  .card:hover {
    border-color: var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,.04);
  }
}

/* Card layout */
.card-row-1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.card-name {
  font-size: 16px; font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.card-status {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.s-在用 { background: var(--green); }
.status-dot.s-备用 { background: var(--yellow); }
.status-dot.s-已停 { background: var(--gray); }

.card-row-2 {
  margin-top: 5px;
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: 13px; color: var(--text-muted);
}
.card-row-2 .meta-item { display: flex; align-items: center; gap: 3px; }
.card-row-2 .meta-icon { font-size: 12px; opacity: .7; }

.card-feeling {
  margin-top: 8px;
  font-size: 13px; line-height: 1.5;
  color: var(--text-muted);
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Empty State ===== */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-hint { font-size: 13px; margin-top: 6px; color: var(--text-dim); }

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  z-index: 20;
  display: grid; place-items: center;
  width: 56px; height: 56px;
  background: var(--accent);
  border: none; border-radius: 50%;
  color: #fff; cursor: pointer;
  box-shadow: 0 4px 16px rgba(59,130,246,.3);
  transition: all .2s;
}
.fab:hover { background: var(--accent-glow); transform: scale(1.05); }
.fab:active { transform: scale(.95); }

/* ===== Editor Dialog ===== */
dialog {
  border: none; border-radius: 16px;
  max-width: 520px; width: 94vw;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0,0,0,.15);
  padding: 0;
  margin: auto;
  inset: 0;
  max-height: 90vh;
  overflow-y: auto;
}
dialog::backdrop { background: rgba(0,0,0,.3); }

.editor-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px 0;
}
.editor-header h3 {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700; color: var(--text);
}
.close-btn {
  background: none; border: none;
  color: var(--text-dim); font-size: 18px; cursor: pointer;
  padding: 4px 8px; border-radius: 8px;
}
.close-btn:hover { background: var(--surface2); }

.editor-body {
  padding: 16px 20px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  max-height: 60vh; overflow-y: auto;
}
.editor-body label {
  display: flex; flex-direction: column; gap: 5px;
}
.editor-body label.full { grid-column: 1 / -1; }
.editor-body span {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
}
.editor-body input,
.editor-body select,
.editor-body textarea {
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px;
  font-family: var(--font-body);
  transition: border-color .2s, box-shadow .2s;
}
.editor-body input:focus,
.editor-body select:focus,
.editor-body textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.editor-body textarea { resize: vertical; }

.editor-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border-light);
}
.spacer { flex: 1; }

.ghost-btn {
  padding: 8px 18px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 14px;
  cursor: pointer; transition: all .2s;
  font-family: var(--font-body);
}
.ghost-btn:hover { border-color: var(--text-muted); color: var(--text); }

.primary-btn {
  padding: 8px 22px;
  background: var(--accent);
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .2s;
  font-family: var(--font-body);
}
.primary-btn:hover { background: var(--accent-glow); }

.danger-btn {
  padding: 8px 16px;
  background: none; border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  color: var(--red); font-size: 13px;
  cursor: pointer; transition: all .2s;
  font-family: var(--font-body);
}
.danger-btn:hover { background: rgba(239,68,68,.06); }

/* Smart select custom input */
.smart-input {
  margin-top: 4px;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px;
  font-family: var(--font-body);
  width: 100%;
}

/* ===== Animations ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card { animation: fadeUp .3s ease both; }
.cards .card:nth-child(1) { animation-delay: 0s; }
.cards .card:nth-child(2) { animation-delay: .03s; }
.cards .card:nth-child(3) { animation-delay: .06s; }
.cards .card:nth-child(4) { animation-delay: .09s; }
.cards .card:nth-child(5) { animation-delay: .12s; }
.cards .card:nth-child(6) { animation-delay: .15s; }

/* ===== Responsive ===== */
@media (max-width: 520px) {
  .editor-body { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .filters { padding: 8px 16px 10px; }
  .topbar h1 { font-size: 20px; }
}
@media (display-mode: standalone) {
  .topbar { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
}
