/* style.css — PokéInventory */

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

:root {
  --red: #E3350D;
  --red-light: #fff1ee;
  --red-dark: #c42d0d;
  --yellow: #FFCB05;
  --blue: #1A6BB5;
  --blue-light: #e8f1fb;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --orange: #e65100;
  --orange-light: #fff3e0;
  --gray-50:  #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #e8e8e8;
  --gray-300: #d0d0d0;
  --gray-400: #aaa;
  --gray-600: #666;
  --gray-800: #222;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: var(--gray-800);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── HEADER ───────────────────────────────────────────────── */
header {
  background: var(--red);
  color: white;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-left { display: flex; align-items: center; gap: 12px; }

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pokeball {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  position: relative;
  border: 2px solid rgba(255,255,255,0.6);
  flex-shrink: 0;
  overflow: hidden;
}

.pokeball::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50%;
  background: var(--gray-200);
}

.pokeball::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--gray-300);
  z-index: 1;
}

.nav-tabs {
  display: flex;
  gap: 2px;
  background: rgba(0,0,0,0.15);
  border-radius: 8px;
  padding: 3px;
}

.nav-tab {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: rgba(255,255,255,0.75);
  border: none;
  background: none;
  transition: all 0.15s;
}

.nav-tab.active { background: white; color: var(--red); }
.nav-tab:hover:not(.active) { color: white; background: rgba(255,255,255,0.1); }

.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── LAYOUT ───────────────────────────────────────────────── */
main { padding: 24px; max-width: 1140px; margin: 0 auto; }

.page { display: none; }
.page.active { display: block; }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── STATS ────────────────────────────────────────────────── */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 11px;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-card .value { font-size: 22px; font-weight: 600; }
.stat-card.profit .value { color: var(--green); }
.stat-card.loss   .value { color: var(--red); }

/* ── LOTS GRID ────────────────────────────────────────────── */
.lots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.lot-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.lot-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.lot-card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.lot-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  background: var(--gray-100);
}

.lot-thumb-placeholder {
  width: 100%;
  height: 80px;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: 28px;
}

.lot-name { font-weight: 600; font-size: 15px; }
.lot-date { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

.lot-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.lot-badge.profit  { background: var(--green-light); color: var(--green); }
.lot-badge.loss    { background: var(--red-light);   color: var(--red); }
.lot-badge.pending { background: var(--gray-100);    color: var(--gray-600); }

.lot-card-body { padding: 14px 16px; }

.lot-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.lot-stat .lbl { font-size: 11px; color: var(--gray-600); }
.lot-stat .val { font-size: 15px; font-weight: 600; }

.lot-footer {
  font-size: 12px;
  color: var(--gray-600);
}

.progress-bar { height: 4px; background: var(--gray-200); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--red); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--red-dark); }

.btn-ghost { background: white; color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); }

.btn-blue  { background: var(--blue); color: white; }
.btn-blue:hover:not(:disabled) { background: #155a9c; }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-icon { padding: 7px; }

/* ── FORM ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-600); margin-bottom: 6px; }

input[type=text],
input[type=number],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  color: var(--gray-800);
  background: white;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,107,181,0.1); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── SEARCH ───────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 280px;
}

.search-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 15px;
  pointer-events: none;
}

.search-wrap input { padding-left: 34px; }

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 700px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-sm { max-width: 460px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 { font-size: 17px; font-weight: 600; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  line-height: 1;
}

.modal-close:hover { background: var(--gray-200); }
.modal-body { padding: 20px 24px 24px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── UPLOAD ───────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--red);
  background: var(--red-light);
}

.upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-icon { font-size: 36px; margin-bottom: 8px; }
.upload-zone p { color: var(--gray-600); }
.upload-zone strong { color: var(--red); }
.upload-zone .hint { font-size: 12px; margin-top: 4px; }

.upload-preview {
  margin-top: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.upload-preview img { width: 100%; max-height: 260px; object-fit: cover; display: block; }

.preview-change {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.55);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

/* ── AI LOADING ───────────────────────────────────────────── */
.ai-status {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--blue-light);
  border-radius: var(--radius);
  margin-top: 14px;
  font-size: 13px;
  color: var(--blue);
}

.ai-status.visible { display: flex; }

.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(26,107,181,0.25);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── IDENTIFIED CARDS ─────────────────────────────────────── */
.identified-section { margin-top: 16px; }
.identified-section h4 { font-size: 13px; font-weight: 600; color: var(--gray-600); margin-bottom: 10px; }

.id-card {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

.id-num {
  width: 24px; height: 24px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.id-info .name { font-weight: 500; }
.id-info .meta { color: var(--gray-600); font-size: 11px; margin-top: 1px; }

.id-price { font-weight: 600; min-width: 60px; text-align: right; }
.id-price.live { color: var(--green); }
.id-price.est  { color: var(--gray-400); font-style: italic; }
.id-price.loading { color: var(--blue); }

.id-remove {
  background: none; border: none;
  color: var(--gray-300); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0;
}

.id-remove:hover { color: var(--red); }

/* ── TABLES ───────────────────────────────────────────────── */
.table-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-card-header h3 { font-size: 15px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  padding: 9px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-600);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

td { padding: 10px 16px; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

.profit-cell { color: var(--green); font-weight: 600; }
.loss-cell   { color: var(--red);   font-weight: 600; }
.muted-cell  { color: var(--gray-400); }

.table-footer {
  padding: 10px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}

.badge-nm  { background: var(--green-light);  color: var(--green); }
.badge-lp  { background: var(--blue-light);   color: var(--blue); }
.badge-mp  { background: var(--orange-light); color: var(--orange); }
.badge-hp  { background: var(--red-light);    color: var(--red); }

.badge-tcg {
  background: #e3f0ff;
  color: #1a56db;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
}

.badge-live { background: var(--green-light); color: var(--green); font-size: 10px; padding: 1px 5px; border-radius: 4px; }
.badge-est  { background: var(--gray-100);    color: var(--gray-600); font-size: 10px; padding: 1px 5px; border-radius: 4px; }

/* ── LOT DETAIL ───────────────────────────────────────────── */
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.detail-header h2 { font-size: 18px; font-weight: 600; flex: 1; }

.lot-hero {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  max-height: 220px;
}

.lot-hero img { width: 100%; height: 220px; object-fit: cover; display: block; }

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-600);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* ── TOAST ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-800);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: toast-in 0.2s ease;
  max-width: 320px;
}

.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 700px) {
  main { padding: 16px; }
  .summary-strip { grid-template-columns: repeat(3, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .detail-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 440px) {
  .summary-strip { grid-template-columns: 1fr 1fr; }
  header { padding: 0 14px; }
  .logo span { display: none; }
}

/* Stacking: secondary modals appear above the watchlist/lot detail modal */
#modal-add-card,
#modal-correct-card,
#modal-sold,
#modal-card-preview,
#modal-image { z-index: 300; }
