/* ============================================================
   eBay Insight Basic v1.0.0 — style.css
   ============================================================ */

/* ── ① Reset / Base ── */

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── ② CSS Variables ── */

:root {
  /* Colors — Light Theme */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface2: #f1f3f8;
  --surface3: #e8ebf3;
  --border: #d8deea;
  --border-light: #c8d0df;
  --text: #1f2430;
  --text-dim: #5b6374;
  --text-muted: #8a91a3;
  --accent: #3b6ef5;
  --accent-glow: rgba(59,110,245,0.08);
  --accent-strong: rgba(59,110,245,0.15);
  --green: #2eb875;
  --green-dim: rgba(46,184,117,0.10);
  --amber: #e2a800;
  --amber-dim: rgba(226,168,0,0.10);
  --red: #d64545;
  --red-dim: rgba(214,69,69,0.08);

  /* Dimensions */
  --radius: 10px;
}

/* Future: Dark Theme
[data-theme="dark"] {
  --bg: #111118;
  --surface: #1a1a24;
  --surface2: #22222e;
  --surface3: #2a2a38;
  --border: #3a3a4a;
  --border-light: #4a4a5a;
  --text: #e8eaf0;
  --text-dim: #a0a4b4;
  --text-muted: #6a7088;
}
*/

/* ── ③ Layout ── */

.container {
  max-width: 1340px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* Header */
.header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 32px;
}

.header h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

/* Results Container */
.results { display: none; }
.results.show { display: block; }

/* Tab Bar */
.tab-bar {
  display: flex;
  gap: 4px;
  margin: 20px 0 24px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
}

/* Tab Panel */
.tab-panel { }

/* Summary Cards Grid */
.summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

@media (max-width: 900px) {
  .summary { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 540px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
}

/* Ad Structure Cards Grid */
.ad-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.ad-cards-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
  .ad-cards { grid-template-columns: repeat(2, 1fr); }
  .ad-cards-3 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 540px) {
  .ad-cards { grid-template-columns: repeat(2, 1fr); }
  .ad-cards-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Table Controls */
.table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

/* SEO Steps Grid */
.seo-content .steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 16px 0;
}

@media (max-width: 600px) {
  .seo-content .steps { grid-template-columns: 1fr; }
}

/* ── ④ Components ── */

/* --- Badge --- */
.badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--green);
  background: var(--green-dim);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.local-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

/* --- Upload Area --- */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 44px 24px;
  text-align: center;
  transition: all 0.25s ease;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.upload-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-glow) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.upload-area.dragover::before { opacity: 1; }
.upload-area.dragover { border-color: var(--accent); }

.upload-area .icon {
  font-size: 36px;
  margin-bottom: 12px;
  position: relative;
}

.upload-area .main-text {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  position: relative;
}

.upload-area .sub-text {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 14px;
  position: relative;
}

.upload-area input { display: none; }

/* --- Buttons --- */
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  box-shadow: 0 2px 10px rgba(91,138,245,0.3);
}

.upload-btn:hover {
  background: #4a7de8;
  box-shadow: 0 4px 16px rgba(91,138,245,0.4);
  transform: translateY(-1px);
}

.upload-btn:active {
  transform: translateY(0);
}

@media (max-width: 540px) {
  .upload-btn { width: 100%; justify-content: center; padding: 14px 20px; }
}

.btn-clear {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-clear:hover { border-color: var(--red); color: var(--red); }

.tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 20px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,110,245,0.25);
}

.tab-wip {
  font-size: 9.5px;
  font-weight: 600;
  background: var(--amber-dim);
  color: var(--amber);
  padding: 1px 7px;
  border-radius: 8px;
  margin-left: 6px;
  letter-spacing: 0.2px;
  vertical-align: middle;
}

.tab-btn.active .tab-wip {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* --- File Info Bar --- */
.file-info {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 26px;
  font-size: 13px;
  gap: 12px;
}

.file-info.show { display: flex; }

.file-info .left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-info .file-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.file-info .file-name {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-info .file-meta {
  color: var(--text-dim);
  white-space: nowrap;
}

/* --- Status Indicator --- */
.status {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 0 14px;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.status.show { display: flex; }
.status-processing { color: var(--accent); }
.status-success { color: var(--green); }
.status-error { color: var(--red); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

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

/* --- Spinner (Loading) --- */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* --- Error Message --- */
.error-msg {
  background: var(--red-dim);
  border: 1px solid rgba(239,107,107,0.25);
  color: var(--red);
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 500;
  display: none;
  line-height: 1.7;
}

.error-msg.show { display: block; }

.error-msg .error-title {
  font-weight: 700; font-size: 14px; margin-bottom: 4px;
  display: flex; align-items: center; gap: 6px;
}

.error-msg .error-detail {
  color: rgba(239,107,107,0.75); font-size: 12.5px; margin-top: 6px;
  font-family: 'JetBrains Mono', monospace; letter-spacing: -0.2px;
}

.error-msg .error-hint {
  color: var(--text-dim); font-size: 12px; margin-top: 8px;
}

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color 0.2s;
}

.card:hover { border-color: var(--border-light); }

.card .label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card .value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.5px;
}

.card .unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 1px;
}

/* --- Card: Ad Highlight --- */
.card.ad-highlight {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.card.ad-highlight .label {
  color: var(--accent);
}

.card.ad-highlight .value {
  color: var(--accent);
}

/* --- Ad Structure Section --- */
.ad-section {
  margin-bottom: 24px;
}

.ad-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-left: 2px;
}

/* --- WIP Message --- */
.wip-message {
  text-align: center;
  padding: 60px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.wip-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.wip-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.wip-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
}

/* --- Table --- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  table-layout: fixed;
}

/* Column widths */
col.col-title  { width: auto; }
col.col-itemid { width: 140px; }
col.col-num    { width: 90px; }

thead th {
  background: var(--surface2);
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
  position: relative;
}

thead th:hover { color: var(--accent); }

thead th .sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 9px;
  opacity: 0.35;
  transition: opacity 0.15s;
}

thead th.sorted { color: var(--accent); }
thead th.sorted .sort-icon { opacity: 1; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--accent-glow); }

tbody td {
  padding: 9px 14px;
  white-space: nowrap;
  font-weight: 400;
}

td.num {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: -0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
}

th.num-header {
  text-align: right;
}

td.title-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.row-count {
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 500;
}

.page-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-select-wrap label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.page-select-wrap select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}

/* --- Copyable Cell --- */
td.copyable {
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
  border-radius: 4px;
}

td.copyable:hover {
  background: var(--accent-glow);
}

td.copyable::after {
  content: '\1F4CB';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.15s;
}

td.copyable:hover::after {
  opacity: 0.5;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.pagination button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination button:disabled { opacity: 0.25; cursor: default; }

.page-info {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  min-width: 80px;
  text-align: center;
}

/* --- SEO Content --- */
.seo-content {
  margin-top: 48px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
}

.seo-content h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 32px 0 14px 0;
  letter-spacing: -0.3px;
}

.seo-content h2:first-child { margin-top: 0; }

.seo-content p {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.75;
  margin-bottom: 10px;
}

.seo-content .step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.seo-content .step-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.seo-content .step-text {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.6;
}

.seo-content .formula {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 3px 10px;
  border-radius: 5px;
  display: inline-block;
  margin: 4px 0;
}

.seo-content .faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
}

.seo-content .faq-q {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.seo-content .faq-a {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ── ⑤ State Classes ── */

.negative { color: var(--red); }

/* ── ⑥ Traffic Source Tab ── */

.ad-cards-1 {
  grid-template-columns: 1fr;
  max-width: 280px;
}

@media (max-width: 540px) {
  .ad-cards-1 { max-width: 100%; }
}

.ts-ratio {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -0.2px;
}

/* Promoted = amber accent */
.card.ts-promoted {
  border-left: 3px solid var(--amber);
}

/* Organic = green accent */
.card.ts-organic {
  border-left: 3px solid var(--green);
}
