/**
 * Fijate Tools - Inspector de Hardware y Navegador
 * Estilos canónicos, interfaz HUD tecnológica y diseño responsive
 */

:root {
  --bg-primary: #0b0f19;
  --bg-surface: #111827;
  --bg-card: #1f2937;
  --bg-card-hover: #283548;
  --border-color: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-purple: #8b5cf6;
  --accent-indigo: #6366f1;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.25);
  --transition-fast: 0.2s ease;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border-color: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.06);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

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

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Tarjeta principal */
.card-main {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.card-header {
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-title {
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.card-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  line-height: 1.5;
}

/* Acciones superiores de exportar */
.header-actions-bar {
  display: flex;
  gap: 0.5rem;
}

.btn-export {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition-fast);
}

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

/* Hero card de Hz en tiempo real */
.hero-hz-box {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(6, 182, 212, 0.08));
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.hz-measure-side {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hz-measure-lbl {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--accent-purple);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.hz-big-number {
  font-family: var(--font-mono);
  font-size: 3.2rem;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1;
}

.hz-frametime {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hz-status-pill {
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(139, 92, 246, 0.2);
  color: var(--accent-purple);
  border: 1px solid var(--accent-purple);
}

/* Secciones HUD */
.hud-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.hud-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.85rem;
}

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

.hud-card-title {
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.spec-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.spec-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.spec-lbl {
  color: var(--text-secondary);
}

.spec-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

/* Badges y status */
.status-pill {
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.status-pass { background: rgba(16, 185, 129, 0.2); color: var(--accent-green); }
.status-warning { background: rgba(245, 158, 11, 0.2); color: var(--accent-yellow); }
.status-fail { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }
.status-muted { background: var(--bg-surface); color: var(--text-muted); }

/* Matriz de códecs */
.codecs-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.codecs-group {
  margin-top: 1rem;
}

.codecs-group-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.codecs-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.codec-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
}

.codec-supported {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.codec-unsupported {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.codec-indicator {
  font-size: 0.8rem;
  font-weight: 800;
}

/* Benchmark de estrés gráfico */
.stress-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.stress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.btn-stress {
  background: var(--accent-purple);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
}

.btn-stress:hover {
  filter: brightness(1.15);
}

.btn-stress:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.stress-canvas {
  width: 100%;
  height: 200px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  display: none;
}

.stress-results-box {
  display: none;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.stress-score-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Toast */
.app-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #111827;
  color: #f9fafb;
  border: 1px solid var(--accent-purple);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.app-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  padding: 1rem;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

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

.modal-title { font-size: 1.2rem; }

.modal-btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.modal-btn-close:hover { color: var(--text-primary); background: var(--bg-card); }

.modal-body {
  padding: 1.5rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.btn-primary {
  background: var(--accent-purple);
  color: #fff;
  font-weight: 700;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Responsive */
@media (max-width: 800px) {
  .hud-grid {
    grid-template-columns: 1fr;
  }
  .hero-hz-box {
    flex-direction: column;
    align-items: flex-start;
  }
}
