/* ==========================================================================
   Fijate Tools - Decodificador de averías OBD2 y Guía de Testigos
   ========================================================================== */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;

  --sev-red: #ef4444;
  --sev-red-bg: #fef2f2;
  --sev-red-border: #fecaca;
  --sev-red-text: #991b1b;

  --sev-amber: #f59e0b;
  --sev-amber-bg: #fffbeb;
  --sev-amber-border: #fde68a;
  --sev-amber-text: #92400e;

  --sev-green: #10b981;
  --sev-green-bg: #ecfdf5;
  --sev-green-border: #a7f3d0;
  --sev-green-text: #065f46;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #131b2a;
  --bg-card-subtle: #1c2638;
  --bg-input: #1a2334;
  --border-color: #27354a;
  --border-focus: #60a5fa;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;
  --primary-border: #2563eb;

  --sev-red: #f87171;
  --sev-red-bg: #450a0a;
  --sev-red-border: #7f1d1d;
  --sev-red-text: #fecaca;

  --sev-amber: #fbbf24;
  --sev-amber-bg: #291e0a;
  --sev-amber-border: #78350f;
  --sev-amber-text: #fde68a;

  --sev-green: #34d399;
  --sev-green-bg: #064e3b;
  --sev-green-border: #047857;
  --sev-green-text: #a7f3d0;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.detail-title-box h3,
.faq-section-title {
  font-family: var(--font-heading);
}

.font-mono {
  font-family: var(--font-mono);
}

.text-danger {
  color: var(--sev-red) !important;
}

.text-primary {
  color: var(--primary) !important;
}

.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
}

/* Barra rápida */
.tool-quick-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.5rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-color);
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
}

.badge-success {
  background: var(--sev-green-bg);
  color: var(--sev-green-text);
  border: 1px solid var(--sev-green-border);
}

.quick-bar-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.nav-switch-tabs {
  display: flex;
  background: var(--bg-card-subtle);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.tab-btn {
  padding: 0.45rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Buscador OBD2 */
.obd-search-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.75rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-input-wrapper svg {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  height: 48px;
  padding: 0 40px 0 46px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input-wrapper input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-clear-search {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.prefix-pills-row,
.popular-codes-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.pills-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.pill-btn {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn:hover,
.pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.code-chip {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--primary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.code-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* Ficha de detalle de código */
.dtc-detail-card {
  background: var(--bg-card);
  border: 2px solid var(--primary-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.detail-code-badge {
  font-size: 1.7rem;
  font-weight: 800;
  padding: 0.25rem 0.75rem;
  background: #1e293b;
  color: #38bdf8;
  border-radius: 8px;
  letter-spacing: 0.05em;
}

.detail-title-box {
  flex: 1 1 0%;
  min-width: 220px;
}

.detail-title-box h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.detail-system {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.severity-badge-box {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.sev-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.severity-leve {
  background: var(--sev-green-bg);
  color: var(--sev-green-text);
  border: 1px solid var(--sev-green-border);
}

.severity-moderado {
  background: var(--sev-amber-bg);
  color: var(--sev-amber-text);
  border: 1px solid var(--sev-amber-border);
}

.severity-critico {
  background: var(--sev-red-bg);
  color: var(--sev-red-text);
  border: 1px solid var(--sev-red-border);
}

.detail-verdict-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--bg-card-subtle);
  border-radius: 8px;
  padding: 0.85rem 1.25rem;
  margin-top: 1rem;
  margin-bottom: 1.25rem;
}

.verdict-item {
  display: flex;
  flex-direction: column;
}

.verdict-item strong {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.verdict-item span {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.detail-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.col-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.detail-list {
  list-style: disc;
  padding-left: 1.25rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  line-height: 1.45;
}

/* Lista de resultados de búsqueda */
.results-container {
  margin-top: 1.5rem;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.results-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.results-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dtc-results-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  max-height: 480px;
  overflow-y: auto;
}

.dtc-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  transition: background 0.15s ease;
  gap: 1rem;
}

.dtc-result-row:hover {
  background: var(--primary-light);
}

.row-code-pill {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  flex-shrink: 0;
}

.row-desc-box {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.row-desc {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.row-sev-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Guía de Testigos del Salpicadero */
.lights-filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.light-pill-red:hover, .light-pill-red.active {
  background: var(--sev-red) !important;
  border-color: var(--sev-red) !important;
}

.light-pill-amber:hover, .light-pill-amber.active {
  background: var(--sev-amber) !important;
  border-color: var(--sev-amber) !important;
}

.light-pill-green:hover, .light-pill-green.active {
  background: var(--sev-green) !important;
  border-color: var(--sev-green) !important;
}

.dashboard-lights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.dash-light-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dash-light-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
}

.light-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
}

.light-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.light-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.light-urgency {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn-open-light {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: auto;
}

/* FAQs */
.tool-faq-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.faq-section-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text-main);
}

.faq-accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.faq-accordion-item[open] {
  border-color: var(--primary-border);
}

.faq-question {
  padding: 1rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: "+";
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text-muted);
}

.faq-accordion-item[open] .faq-question::after {
  content: "−";
  color: var(--primary);
}

.faq-answer {
  padding: 0 1.25rem 1.1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Modales */
.fijate-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 99999;
}

.fijate-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.fijate-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.fijate-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.fijate-modal-body {
  padding: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-height: 70vh;
  overflow-y: auto;
}

.fijate-modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  height: 40px;
  padding: 0 1.25rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* Móvil */
@media (max-width: 900px) {
  .tool-with-sidebar {
    flex-direction: column;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-verdict-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-lights-grid {
    grid-template-columns: 1fr;
  }

  .card-main {
    padding: 1.25rem;
  }
}
