/* ============================================================
   frontend/css/main.css
   全站共用樣式 - 二手好物平台
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700;900&family=Playfair+Display:wght@700;900&display=swap');

/* ── CSS 變數 ─────────────────────────────── */
:root {
  --primary:    #e85d04;
  --primary-d:  #c44f00;
  --primary-l:  #fff3ed;
  --accent:     #2d6a4f;
  --accent-l:   #e8f5ef;
  --gold:       #f4a261;
  --gold-l:     #fff8f0;

  --bg:         #fafaf8;
  --bg2:        #f4f2ef;
  --surface:    #ffffff;
  --border:     #e8e4df;
  --border2:    #d4cfc9;

  --text:       #1a1714;
  --text2:      #4a4540;
  --text3:      #8a857f;
  --text-inv:   #ffffff;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:     0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);

  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --nav-h:      64px;
  --font:       'Noto Sans TC', sans-serif;
  --font-serif: 'Playfair Display', serif;

  --ease:       cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Reset ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: inherit; outline: none; }

/* ── Navigation ──────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.nav-logo {
  font-size: 20px; font-weight: 900;
  color: var(--primary);
  letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.nav-logo-dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%,100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.7; }
}
.nav-search {
  flex: 1; max-width: 480px;
  display: flex; align-items: center;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0 16px; gap: 8px;
  transition: border-color .2s, box-shadow .2s;
}
.nav-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,93,4,0.1);
}
.nav-search input {
  flex: 1; border: none; background: transparent;
  font-size: 14px; padding: 10px 0;
  color: var(--text);
}
.nav-search input::placeholder { color: var(--text3); }
.nav-search-icon { color: var(--text3); font-size: 16px; flex-shrink: 0; }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-btn {
  height: 38px; padding: 0 16px;
  border-radius: 999px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  transition: all .2s var(--ease);
}
.nav-btn-ghost {
  background: transparent; color: var(--text2);
}
.nav-btn-ghost:hover { background: var(--bg2); }
.nav-btn-primary {
  background: var(--primary); color: white;
}
.nav-btn-primary:hover {
  background: var(--primary-d);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(232,93,4,0.3);
}
.nav-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gold); display: flex;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: white;
  cursor: pointer; flex-shrink: 0;
  transition: transform .2s;
}
.nav-avatar:hover { transform: scale(1.08); }

/* ── Category Tabs ────────────────────────── */
.cat-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cat-bar::-webkit-scrollbar { display: none; }
.cat-tab {
  flex-shrink: 0; padding: 12px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text3); border: none; background: transparent;
  border-bottom: 2.5px solid transparent;
  cursor: pointer; transition: all .2s;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.cat-tab:hover { color: var(--text); }
.cat-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}
.cat-tab-icon { font-size: 16px; }

/* ── Product Cards ────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 24px;
}
.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
  position: relative;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.product-card-img {
  aspect-ratio: 1;
  background: var(--bg2);
  position: relative; overflow: hidden;
}
.product-card-img img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .4s var(--ease);
}
.product-card:hover .product-card-img img {
  transform: scale(1.05);
}
.product-card-img-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; color: var(--border2);
}
.product-badge {
  position: absolute; top: 10px; left: 10px;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  letter-spacing: 0.5px; text-transform: uppercase;
}
.badge-new    { background: #dcfce7; color: #166534; }
.badge-good   { background: #dbeafe; color: #1e40af; }
.badge-trade  { background: var(--gold-l); color: #92400e; }
.badge-urgent { background: #fee2e2; color: #991b1b; }
.product-fav {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer;
  transition: transform .2s;
  border: none;
}
.product-fav:hover { transform: scale(1.2); }
.product-card-body { padding: 12px 14px 14px; }
.product-title {
  font-size: 13px; font-weight: 600;
  color: var(--text); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 8px;
}
.product-price {
  font-size: 18px; font-weight: 800;
  color: var(--primary);
}
.product-price-original {
  font-size: 11px; color: var(--text3);
  text-decoration: line-through; margin-left: 4px;
}
.product-price-negotiate {
  font-size: 13px; font-weight: 600;
  color: var(--accent); margin-top: 2px;
}
.product-meta {
  display: flex; align-items: center;
  gap: 8px; margin-top: 8px;
  font-size: 11px; color: var(--text3);
}
.product-seller {
  display: flex; align-items: center; gap: 4px;
}
.product-seller-avatar {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--gold); display: flex;
  align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: white;
}
.product-location { margin-left: auto; }

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 0 20px; height: 44px;
  border-radius: 999px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all .2s var(--ease);
}
.btn-primary {
  background: var(--primary); color: white;
}
.btn-primary:hover {
  background: var(--primary-d);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(232,93,4,0.3);
}
.btn-secondary {
  background: var(--bg2); color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { border-color: var(--text3); }
.btn-accent {
  background: var(--accent); color: white;
}
.btn-accent:hover {
  background: #235a42;
  box-shadow: 0 6px 20px rgba(45,106,79,0.3);
}
.btn-outline {
  background: transparent; color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-l); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 12px; }
.btn-lg { height: 52px; padding: 0 28px; font-size: 16px; }
.btn-full { width: 100%; }
.btn-icon { width: 44px; padding: 0; }

/* ── Form Elements ────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text2); margin-bottom: 6px;
}
.form-label .required { color: var(--primary); margin-left: 2px; }
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 12px 16px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,93,4,0.1);
}
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-hint { font-size: 11px; color: var(--text3); margin-top: 4px; }
.form-error { font-size: 11px; color: #dc2626; margin-top: 4px; }

/* ── Condition Selector ───────────────────── */
.condition-group {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.condition-opt {
  flex: 1; min-width: 100px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface); cursor: pointer;
  text-align: center; transition: all .2s;
}
.condition-opt input { display: none; }
.condition-opt-label { font-size: 12px; font-weight: 600; display: block; }
.condition-opt-desc { font-size: 10px; color: var(--text3); margin-top: 2px; }
.condition-opt.selected {
  border-color: var(--primary); background: var(--primary-l);
}
.condition-opt.selected .condition-opt-label { color: var(--primary); }

/* ── Tags ─────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.tag-orange { background: var(--primary-l); color: var(--primary); }
.tag-green  { background: var(--accent-l);  color: var(--accent); }
.tag-gold   { background: var(--gold-l);    color: #92400e; }
.tag-gray   { background: var(--bg2);       color: var(--text3); }

/* ── Modal ────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slide-up .3s var(--ease);
}
@keyframes slide-up {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  padding: 24px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg2); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text3);
  transition: background .2s;
}
.modal-close:hover { background: var(--border); }
.modal-body { padding: 20px 24px 24px; }

/* ── Toast ─────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 300; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-radius: var(--radius);
  background: var(--text); color: white;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .3s var(--ease);
  max-width: 320px;
}
@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast-success { background: #166534; }
.toast-error   { background: #991b1b; }
.toast-info    { background: var(--primary-d); }

/* ── Loading ──────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg2) 25%, var(--border) 50%, var(--bg2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────── */
@media (max-width: 768px) {
  .nav { padding: 0 16px; }
  .nav-search { display: none; }
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; padding: 12px;
  }
  .product-card-body { padding: 10px 12px 12px; }
  .product-price { font-size: 16px; }
}
@media (max-width: 480px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 8px; }
}
