/* ─── Variáveis ─────────────────────────────────────────────────────────── */
:root {
  --bg:           #0D0F18;
  --surface:      #141726;
  --surface2:     #1A1E2E;
  --surface3:     #20253A;
  --border:       #252A3D;
  --border2:      #2E3450;

  --amber:        #F59E0B;
  --amber-dim:    #78490A;
  --amber-text:   #FCD34D;

  --green:        #34D399;
  --green-dim:    #052E16;
  --warn:         #FBBF24;
  --red:          #F87171;
  --cyan:         #67E8F9;

  --text:         #E2E8F0;
  --text-2:       #94A3B8;
  --text-3:       #4B5563;

  --font:         'IBM Plex Sans', system-ui, sans-serif;
  --mono:         'IBM Plex Mono', 'Courier New', monospace;

  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 4px 24px rgba(0,0,0,.5);
  --transition:   .18s ease;
}

/* ─── Reset / Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--amber-dim); }

/* ─── Header ────────────────────────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.header-icon { font-size: 28px; }

.header-title h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--amber-text);
  letter-spacing: -.3px;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

/* ─── Toggle de modo ────────────────────────────────────────────────────── */
.mode-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
}

.mode-btn {
  padding: 8px 18px;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  border-right: 1px solid var(--border);
}

.mode-btn:last-child { border-right: none; }

.mode-btn .mode-label { font-weight: 600; }
.mode-btn .mode-desc  { font-size: 11px; color: var(--text-3); }

.mode-btn.active {
  background: var(--amber-dim);
  color: var(--amber-text);
}

.mode-btn.active .mode-desc { color: #c97b0a; }
.mode-btn:hover:not(.active) { background: var(--surface2); color: var(--text); }

/* ─── Barra de filtros ──────────────────────────────────────────────────── */
.filters-bar {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.filters-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-2);
  white-space: nowrap;
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--surface3);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.chip:hover { border-color: var(--amber); color: var(--text); }
.chip.chip-active { font-weight: 600; }

.btn-clear-filters {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

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

.filter-search { position: relative; align-items: center; }

.search-input {
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 5px 28px 5px 10px;
  width: 220px;
  outline: none;
  transition: var(--transition);
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus { border-color: var(--amber); }

.search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  line-height: 1;
}
.search-clear:hover { color: var(--red); }

/* ─── Conteúdo principal / tabela ───────────────────────────────────────── */
.main-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px 80px;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

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

/* ─── Thead ──────────────────────────────────────────────────────────────── */
.cars-table thead {
  background: var(--surface);
}

.cars-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
}

.cars-table th.highlight-col { color: var(--amber); }

.cars-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.cars-table th.sortable:hover { color: var(--text); }
.cars-table th.sort-active { color: var(--amber-text); }

.sort-icon { opacity: .6; font-style: normal; margin-left: 4px; }
.sort-active .sort-icon { opacity: 1; }

/* ─── Tbody ──────────────────────────────────────────────────────────────── */
.cars-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.car-row { background: var(--surface); transition: background var(--transition); }
.car-row.row-odd { background: var(--surface2); }
.car-row:hover { background: var(--surface3); }
.car-row.row-selected { outline: 1px solid var(--amber); outline-offset: -1px; }

.car-row:last-child td { border-bottom: none; }

/* Colunas específicas */
.th-check, .td-check { width: 36px; text-align: center; }
.td-modelo { font-weight: 600; white-space: nowrap; }
.td-versao  { color: var(--text-2); max-width: 200px; }
.td-motor   { color: var(--text-2); white-space: nowrap; font-size: 12px; }
.td-ano     { color: var(--text-2); white-space: nowrap; }

.td-mono { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.td-final { font-weight: 600; }
.td-info  { color: var(--text-2); font-size: 12px; cursor: help; }

.empty-row {
  text-align: center;
  padding: 40px;
  color: var(--text-2);
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge-brand,
.badge-type {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  border: 1px solid;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ─── Valor best (mais barato da marca) ─────────────────────────────────── */
.td-best {
  color: var(--amber-text) !important;
  background: rgba(245, 158, 11, .08);
  border-radius: 4px;
}

/* ─── Cores de texto ─────────────────────────────────────────────────────── */
.green  { color: var(--green);  }
.amber  { color: var(--amber-text); }
.warn   { color: var(--warn);   }
.muted  { color: var(--text-2); }
.strike { text-decoration: line-through; color: var(--text-2); }
.mono   { font-family: var(--mono); }

/* ─── Checkbox ───────────────────────────────────────────────────────────── */
.car-checkbox {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--amber);
}

/* ─── Botão detalhes ─────────────────────────────────────────────────────── */
.btn-details {
  padding: 4px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface3);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-details:hover {
  border-color: var(--amber);
  color: var(--amber-text);
  background: var(--amber-dim);
}

/* ─── Ícone info ─────────────────────────────────────────────────────────── */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border2);
  font-size: 10px;
  font-style: normal;
  color: var(--cyan);
  cursor: help;
  vertical-align: middle;
  margin-right: 4px;
}

/* ─── Botão flutuante Comparar ───────────────────────────────────────────── */
.compare-float {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

.btn-compare {
  padding: 12px 28px;
  border-radius: 30px;
  border: none;
  background: var(--amber);
  color: #000;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245,158,11,.5);
  transition: var(--transition);
}

.btn-compare:hover {
  background: var(--amber-text);
  box-shadow: 0 6px 28px rgba(245,158,11,.7);
  transform: scale(1.03);
}

/* ─── Overlay ────────────────────────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 300;
  backdrop-filter: blur(2px);
}

.overlay.active { display: block; }

/* ─── Drawer lateral (detalhes) ─────────────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(480px, 96vw);
  background: var(--surface);
  border-left: 1px solid var(--border2);
  z-index: 400;
  overflow-y: auto;
  padding: 24px;
  transform: translateX(105%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  box-shadow: -8px 0 40px rgba(0,0,0,.6);
}

.drawer.open { transform: translateX(0); }

.drawer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  color: var(--text-2);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-close:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ─── Conteúdo do drawer ─────────────────────────────────────────────────── */
.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-right: 36px;
}

.drawer-badges { display: flex; gap: 6px; margin-bottom: 6px; }
.drawer-title  { font-size: 20px; font-weight: 700; line-height: 1.2; }
.drawer-versao { font-size: 13px; color: var(--text-2); margin-top: 4px; }

.stars { display: flex; gap: 2px; }
.star  { font-size: 20px; color: var(--text-3); }
.star.filled { color: var(--amber); }
.stars-label { font-size: 11px; color: var(--text-2); text-align: center; margin-top: 2px; display: block; }

.drawer-justificativa {
  font-size: 13px;
  color: var(--text-2);
  border-left: 2px solid var(--amber);
  padding-left: 10px;
  margin-bottom: 20px;
  line-height: 1.6;
}

/* ─── Seções do drawer ───────────────────────────────────────────────────── */
.detail-section { margin-bottom: 20px; }

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-2);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Preços */
.price-block {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-2);
}

.price-row.sub-total {
  font-weight: 600;
  border-top: 1px dashed var(--border2);
  padding-top: 4px;
  margin-top: 2px;
  color: var(--text);
}

.price-row.final {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border2);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* Preços por cor (Toyota) */
.color-prices { display: flex; flex-direction: column; gap: 8px; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  flex-shrink: 0;
}
.color-dot.solid     { background: #f5f5f5; border-color: #ccc; }
.color-dot.metalica  { background: #1a1a1a; border-color: #555; }
.color-dot.perolizada{ background: #e8e8e0; border-color: #aaa; box-shadow: inset 0 0 4px rgba(200,200,255,.4); }
.color-name  { font-size: 13px; color: var(--text-2); flex: 1; }
.color-price { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }
.color-note  { font-size: 11px; color: var(--text-3); margin-top: 8px; font-style: italic; }

/* Specs grid */
.specs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.spec-item  { background: var(--surface2); border-radius: var(--radius); padding: 10px 12px; }
.spec-label { display: block; font-size: 11px; color: var(--text-2); margin-bottom: 3px; }
.spec-val   { display: block; font-size: 14px; font-weight: 600; }
.spec-val small { font-size: 11px; font-weight: 400; color: var(--text-2); }

/* Bullets */
.bullets-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.bullet-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 6px;
}

.bullet-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bullet-list li {
  font-size: 12px;
  color: var(--text-2);
  padding-left: 14px;
  position: relative;
  line-height: 1.5;
}

.bullet-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--border2);
}

/* ─── Breakeven ──────────────────────────────────────────────────────────── */
.breakeven-section { background: var(--surface2); border-radius: var(--radius-lg); padding: 16px; }

.breakeven-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.breakeven-card {
  background: var(--surface3);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  border: 1px solid var(--border2);
}

.bk-val {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--amber-text);
  margin-bottom: 3px;
}

.bk-label {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.3;
}

.bk-note {
  font-size: 11px;
  color: var(--text-3);
  font-style: italic;
  line-height: 1.5;
}

/* ─── Modal comparador ────────────────────────────────────────────────────── */
.comp-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  z-index: 500;
  overflow-y: auto;
  padding: 40px 20px;
}

.comp-modal.open { display: block; }

.comp-modal-inner {
  max-width: 1100px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border2);
  padding: 28px;
  box-shadow: var(--shadow);
  position: relative;
}

.comp-close {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface3);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.comp-close:hover { background: var(--red); color: #fff; border-color: var(--red); }

.comp-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--amber-text);
  margin-bottom: 20px;
}

.comp-table-wrap { overflow-x: auto; }

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

.comp-table th {
  background: var(--surface2);
  padding: 10px 14px;
  text-align: center;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 2px solid var(--amber-dim);
  vertical-align: top;
}

.comp-car-head { font-size: 13px; line-height: 1.4; }
.comp-car-head strong { color: var(--text); }
.comp-car-head small  { color: var(--text-2); font-size: 11px; }

.comp-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: center;
}

.comp-th-label { text-align: left; }
.comp-row-label {
  text-align: left;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  padding-right: 16px;
}

.comp-cell { color: var(--text); }

.comp-section-row td {
  background: var(--surface2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--amber);
  padding: 6px 14px;
}

.comp-highlight-row td {
  background: rgba(245,158,11,.06);
  font-weight: 600;
}

tr:nth-child(even) .comp-cell { background: rgba(255,255,255,.015); }

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 16px 24px 24px;
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
}

/* ─── Responsivo ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 10px; }

  .mode-toggle  { width: 100%; }
  .mode-btn     { flex: 1; align-items: center; padding: 8px 10px; }

  .filters-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .btn-clear-filters { margin-left: 0; }

  .main-content { padding: 12px 10px 80px; }

  .cars-table { font-size: 12px; }
  .cars-table th, .cars-table td { padding: 7px 8px; }

  /* Esconde colunas secundárias em telas pequenas */
  .cars-table th:nth-child(5),
  .cars-table td:nth-child(5),
  .cars-table th:nth-child(7),
  .cars-table td:nth-child(7) { display: none; }

  .drawer { width: 100%; border-left: none; border-top: 1px solid var(--border2); }

  .specs-grid { grid-template-columns: 1fr; }
  .bullets-cols { grid-template-columns: 1fr; }
  .breakeven-grid { grid-template-columns: 1fr 1fr; }

  .comp-modal-inner { padding: 16px; }
}

@media (max-width: 480px) {
  .header-title h1 { font-size: 17px; }
  .td-versao  { display: none; }
  .breakeven-grid { grid-template-columns: 1fr; }
}
