/* ================================================================
   calculator.css — JDM Profit Calculator UI
   Extends theme.css design tokens. No overrides to core tokens.
   ================================================================ */

/* NAV */
.calc-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.calc-nav-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.calc-nav-logo em {
  font-style: normal;
  color: var(--accent);
}

.calc-nav-tag {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  padding: 0.3rem 0.8rem;
}

/* HERO STRIP */
.calc-hero {
  padding: 4rem 2rem 3rem;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.calc-hero::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.calc-hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.calc-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 1rem 0 0.75rem;
  line-height: 1.05;
}

.calc-hero-sub {
  color: var(--fg-muted);
  font-size: 1rem;
  max-width: 560px;
  line-height: 1.7;
  font-weight: 300;
}

/* MAIN LAYOUT */
.calc-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 160px);
}

/* SIDEBAR */
.calc-sidebar {
  border-right: 1px solid var(--border);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  background: var(--bg-surface);
}

.filter-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filter-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-field label {
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-weight: 500;
}

.filter-field label .opt {
  font-weight: 400;
  opacity: 0.6;
  font-size: 0.72rem;
}

.filter-field input,
.filter-field select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.6rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.filter-field input:focus,
.filter-field select:focus {
  border-color: var(--accent);
}

.filter-field input::placeholder {
  color: rgba(138, 134, 144, 0.5);
}

.filter-hint {
  font-size: 0.82rem;
  color: var(--fg-muted);
  line-height: 1.6;
}

.btn-search {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.75rem 1rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-search:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

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

.btn-reset {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  padding: 0.55rem 1rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-reset:hover {
  color: var(--fg);
  border-color: rgba(255,255,255,0.15);
}

/* Custom calc result */
.custom-calc-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 1.25rem;
}

.custom-result {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.cr-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--fg-muted);
}

.cr-row:last-child { border-bottom: none; }
.cr-row strong { color: var(--fg); }

.cr-profit {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  padding: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-display);
}

.cr-profit em { font-style: normal; font-size: 0.8rem; opacity: 0.8; }
.cr-profit.profitable { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.cr-profit.break-even { background: rgba(234, 179, 8, 0.1); color: #eab308; }
.cr-profit.loss { background: rgba(230, 57, 70, 0.12); color: var(--accent); }

/* MAIN RESULTS */
.calc-main {
  padding: 2rem;
  background: var(--bg);
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.results-count {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.results-legend {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.legend-dot.profitable { background: #22c55e; }
.legend-dot.break-even { background: #eab308; }
.legend-dot.loss       { background: var(--accent); }

/* VEHICLE CARDS */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.vehicle-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: border-color 0.2s, transform 0.15s;
  cursor: default;
  position: relative;
}

.vehicle-card:hover {
  transform: translateY(-2px);
}

.vehicle-card.profitable { border-left: 3px solid #22c55e; }
.vehicle-card.break-even { border-left: 3px solid #eab308; }
.vehicle-card.loss       { border-left: 3px solid var(--accent); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.card-year {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.1em;
}

.card-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
}

.profit-badge {
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-display);
  padding: 0.25rem 0.6rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.profit-badge.profitable { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.profit-badge.break-even { background: rgba(234, 179, 8, 0.12); color: #eab308; }
.profit-badge.loss       { background: rgba(230, 57, 70, 0.12); color: var(--accent); }

.card-grade {
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.card-auction-house {
  font-size: 0.75rem;
  color: rgba(138, 134, 144, 0.6);
}

.card-prices {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.83rem;
}

.price-label { color: var(--fg-muted); }

.price-val { font-family: var(--font-display); font-weight: 600; }
.price-val.jpy  { color: rgba(212, 168, 67, 0.8); font-size: 0.8rem; }
.price-val.landed { color: var(--fg); }
.price-val.market { color: var(--gold); }

.card-profit {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  font-size: 0.9rem;
}

.card-profit.profitable { background: rgba(34, 197, 94, 0.08); }
.card-profit.break-even { background: rgba(234, 179, 8, 0.08); }
.card-profit.loss       { background: rgba(230, 57, 70, 0.08); }

.profit-label-sm {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.profit-amount {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.profit-amount em {
  font-style: normal;
  font-size: 0.78rem;
  opacity: 0.8;
}

.card-profit.profitable .profit-amount { color: #22c55e; }
.card-profit.break-even .profit-amount { color: #eab308; }
.card-profit.loss       .profit-amount { color: var(--accent); }

.btn-breakdown {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  font-family: var(--font-body);
  margin-top: auto;
}

.btn-breakdown:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* EMPTY / LOADING STATES */
.empty-state,
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem;
  color: var(--fg-muted);
  gap: 1rem;
  grid-column: 1 / -1;
}

.empty-icon {
  font-size: 3rem;
  font-weight: 700;
  font-family: var(--font-display);
  opacity: 0.15;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 2rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--fg); }

.modal-vehicle-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}

.modal-year {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.1em;
}

.modal-vehicle-title strong {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--fg);
}

.modal-grade {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.modal-meta {
  font-size: 0.8rem;
  color: rgba(138, 134, 144, 0.7);
  margin-bottom: 1.5rem;
}

.breakdown-table {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.brow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  gap: 1rem;
}

.brow:last-child { border-bottom: none; }

.brow-head {
  background: var(--bg-elevated);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.brow span:first-child { color: var(--fg-muted); }
.brow span:last-child  { text-align: right; }

.bval-jpy     { font-size: 0.75rem; color: rgba(212, 168, 67, 0.7); display: block; }
.bval-eur     { font-family: var(--font-display); font-weight: 600; color: var(--fg); }
.bval-zero    { color: #22c55e; }
.bval-range   { color: var(--fg); }

.brow-total {
  background: var(--bg-elevated);
  font-weight: 600;
}

.bval-total {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--fg);
}

.brow-market { }
.bval-market { font-family: var(--font-display); font-weight: 700; color: var(--gold); }

.brow-profit {
  font-weight: 700;
  font-family: var(--font-display);
}

.brow-profit.profitable { background: rgba(34, 197, 94, 0.08); }
.brow-profit.break-even { background: rgba(234, 179, 8, 0.08); }
.brow-profit.loss       { background: rgba(230, 57, 70, 0.08); }

.bval-profit {
  font-size: 1.1rem;
}

.brow-profit.profitable .bval-profit { color: #22c55e; }
.brow-profit.break-even .bval-profit { color: #eab308; }
.brow-profit.loss       .bval-profit { color: var(--accent); }

.brow-profit em {
  font-style: normal;
  font-size: 0.8rem;
  opacity: 0.8;
  margin-left: 0.4rem;
}

.breakdown-note {
  font-size: 0.75rem;
  color: rgba(138, 134, 144, 0.55);
  line-height: 1.6;
  padding-top: 0.5rem;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .calc-layout {
    grid-template-columns: 1fr;
  }

  .calc-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1.5rem;
  }

  .filter-block {
    flex: 1;
    min-width: 250px;
  }

  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

@media (max-width: 600px) {
  .calc-sidebar {
    flex-direction: column;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .results-legend {
    gap: 0.8rem;
    font-size: 0.72rem;
  }
}
