/* === Brand Badge === */
.card-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--accent, #3b82f6);
  color: #fff;
}

.brand-badge:empty { display: none; }

.btn-refresh {
  margin-left: auto;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

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

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

.brand-pokemon    { background: #f59e0b; }
.brand-yugioh     { background: #8b5cf6; }
.brand-onepiece   { background: #ef4444; }
.brand-weiss      { background: #ec4899; }
.brand-mtg        { background: #6366f1; }
.brand-dragonball { background: #f97316; }
.brand-duelmasters { background: #14b8a6; }
.brand-digimon    { background: #06b6d4; }
.brand-hololive   { background: #a855f7; }
.brand-unionarena { background: #10b981; }
.brand-disney     { background: #3b82f6; }
.brand-vanguard   { background: #0ea5e9; }
.brand-fab        { background: #dc2626; }
.brand-other      { background: #6b7280; }

/* === Card Detail Page === */

.card-detail {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 28px;
  padding: 28px;
  max-width: 1440px;
  margin: 0 auto;
}

/* Left: Card Image */
.card-image-section {
  position: sticky;
  top: calc(var(--navbar-h, 60px) + 24px);
  align-self: start;
}

.card-image-section img {
  width: 100%;
  border-radius: var(--card-radius, 14px);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--surface) 100%);
  padding: 16px;
  transition: transform 0.3s ease;
  cursor: zoom-in;
}

.card-image-section img:hover {
  transform: scale(1.02);
}

/* === Card Name Header === */
.card-name-header {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.4;
  color: var(--text);
}

/* Right: Chart Section */
.card-chart-section {
  min-width: 0;
}

/* Price Stats */
.price-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-box:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px var(--shadow);
}

.stat-box .label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stat-box .value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

.stat-box .value.up { color: var(--green); }
.stat-box .value.down { color: var(--red); }

/* Chart Toolbar */
.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.toolbar-section {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border-right: 1px solid var(--border);
  gap: 6px;
}

.toolbar-section:last-child {
  border-right: none;
}

.toolbar-group {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.toolbar-btn {
  padding: 6px 12px;
  border: none;
  background: var(--bg-secondary, var(--surface));
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.toolbar-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

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

.toolbar-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Chart Container */
.chart-container {
  width: 100%;
  height: 600px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.chart-container:hover {
  border-color: var(--accent);
}

/* OHLC Legend Overlay */
.chart-legend {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-secondary);
  background: rgba(19, 23, 34, 0.75);
  border-radius: 6px;
  pointer-events: none;
  backdrop-filter: blur(4px);
  flex-wrap: wrap;
  max-width: calc(100% - 80px);
  line-height: 1.6;
}

[data-theme="light"] .chart-legend {
  background: rgba(255, 255, 255, 0.85);
}

.chart-legend .legend-label {
  color: var(--text-secondary, #9ca3af);
  font-size: 11px;
  margin-left: 6px;
}

.chart-legend .legend-label:first-child {
  margin-left: 0;
}

.chart-legend .legend-val {
  color: var(--text, #d1d4dc);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
}

.chart-legend .legend-change {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: 8px;
}

/* === Sales Section === */
.sales-section {
  margin-top: 28px;
}

.sales-section h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 14px;
}

.sales-filter {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}

.sales-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.sales-table th {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  background: var(--bg-secondary);
}

.sales-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.sales-table tr:last-child td {
  border-bottom: none;
}

.sales-table tbody tr {
  transition: background 0.15s;
}

.sales-table tbody tr:hover {
  background: var(--surface-hover);
}

/* === Portfolio Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

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

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h3 {
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 600;
}

.modal-field {
  margin-bottom: 14px;
}

.modal-field label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.modal-field input,
.modal-field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.modal-field input:focus,
.modal-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 143, 247, 0.15);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-actions button {
  padding: 10px 22px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent) !important;
}

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

.btn-cancel {
  background: var(--surface);
  color: var(--text);
}

.btn-cancel:hover {
  background: var(--surface-hover);
}

/* === Responsive === */
@media (max-width: 900px) {
  .card-detail {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 20px;
  }

  .card-image-section {
    position: static;
    max-width: 360px;
    margin: 0 auto;
  }

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

  .chart-container { height: 420px; }

  .toolbar-section {
    flex: none;
    width: 50%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-sizing: border-box;
  }
  .toolbar-section:nth-child(even) { border-left: 1px solid var(--border); }
  .toolbar-section:nth-last-child(-n+2) { border-bottom: none; }

  .toolbar-btn { padding: 5px 10px; font-size: 11px; }
  .toolbar-label { font-size: 9px; }
}

@media (max-width: 480px) {
  .price-stats { grid-template-columns: 1fr 1fr; }
  .stat-box .value { font-size: 18px; }
  .chart-container { height: 350px; }
  .sales-table { font-size: 12px; }
  .sales-table th, .sales-table td { padding: 8px 10px; }
}
