/**
 * Fijate Tools - Simulador de la falacia del jugador y loterías
 * Archivo: css/style.css
 * 
 * Estilos canónicos fijate.com con tipografías Outfit, Inter y JetBrains Mono,
 * terminal de balance financiero, diseño responsivo y temas claro/oscuro.
 */

:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: #131d33;
  --bg-card-hover: #192644;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-danger: #ef4444;
  --accent-danger-bg: rgba(239, 68, 68, 0.12);
  --accent-success: #10b981;
  --accent-success-bg: rgba(16, 185, 129, 0.12);
  --accent-warning: #f59e0b;
  --accent-gold: #fbbf24;

  --font-sans: '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;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-active: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent-danger-bg: rgba(239, 68, 68, 0.08);
  --accent-success-bg: rgba(16, 185, 129, 0.08);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Reset de contención canónica */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

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

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

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

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

/* Tarjetas y contenedores */
.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.card-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Selector de juegos de lotería */
.lottery-grid-selector {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

.lottery-card-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  min-height: 48px;
}

.lottery-card-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-2px);
}

.lottery-card-btn.active {
  background: rgba(59, 130, 246, 0.08);
  border-color: var(--border-active);
  box-shadow: 0 0 0 1px var(--border-active);
}

.lottery-btn-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.lottery-btn-price {
  font-family: var(--font-mono);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--accent-gold);
}

.lottery-btn-odds {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Modos de simulación */
.simulation-modes-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.625rem;
  margin-bottom: 1.25rem;
}

.btn-mode {
  min-height: 42px;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

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

.btn-mode.btn-mode-active {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-sm);
}

/* Panel de configuración personalizada */
.custom-panel {
  background: var(--bg-secondary);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.25rem;
  display: none;
}

.custom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) auto;
  gap: 1rem;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  height: 42px;
  min-height: 42px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--border-active);
}

/* Barra de acciones de simulación */
.actions-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-action {
  min-height: 44px;
  padding: 0 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.925rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent-blue);
  color: #ffffff;
}

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

.btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
}

.btn-danger-outline {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--accent-danger);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--accent-danger-bg);
}

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

/* Badges de telemetría y estado */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-idle {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

.status-live {
  background: var(--accent-danger-bg);
  color: var(--accent-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-completed {
  background: var(--accent-success-bg);
  color: var(--accent-success);
}

.status-paused {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
}

.pulse {
  animation: pulse-glow 1.6s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Terminal de balance de caja */
.terminal-card {
  background: linear-gradient(180deg, var(--bg-card) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.metrics-grid-top {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Colores financieros */
.text-danger {
  color: var(--accent-danger) !important;
}

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

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

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

/* Contenedor del gráfico Canvas */
.chart-container-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1rem;
  position: relative;
  overflow: hidden;
}

.canvas-wrapper {
  width: 100%;
  height: 320px;
  position: relative;
}

#balance-chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Tabla de desglose de premios */
.table-responsive-box {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-top: 1rem;
  -webkit-overflow-scrolling: touch;
}

.prize-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.prize-table th {
  background: var(--bg-secondary);
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.prize-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

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

.text-right {
  text-align: right;
}

.badge-hit {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--accent-success-bg);
  color: var(--accent-success);
  font-weight: 700;
}

.badge-zero {
  color: var(--text-muted);
}

.badge-danger {
  color: var(--accent-danger);
  font-weight: 700;
}

.badge-jackpot {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  background: rgba(251, 191, 36, 0.2);
  color: var(--accent-gold);
  border-radius: 4px;
  margin-left: 0.5rem;
}

.tr-jackpot {
  background: rgba(251, 191, 36, 0.05);
}

.tr-loss {
  background: rgba(239, 68, 68, 0.04);
}

/* Panel pedagógico de choque */
.shock-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.shock-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.shock-card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.shock-stat-hero {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--accent-danger);
}

.shock-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Lista de comparativa de probabilidades */
.comparison-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.comparison-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  gap: 0.75rem;
}

.comparison-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.comparison-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.comparison-source {
  font-size: 0.725rem;
  color: var(--text-muted);
}

.comparison-multiplier {
  font-size: 0.825rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Desmontando la falacia del jugador (Guía didáctica) */
.fallacy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.fallacy-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.fallacy-box-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fallacy-box-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Modales nativos fijate.com */
.fijate-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.fijate-modal-backdrop.modal-visible {
  opacity: 1;
  pointer-events: auto;
}

.fijate-modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
}

.fijate-modal-backdrop.modal-visible .fijate-modal-dialog {
  transform: translateY(0) scale(1);
}

.fijate-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fijate-modal-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.fijate-modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.fijate-modal-close-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.fijate-modal-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.fijate-modal-body strong {
  color: var(--text-primary);
}

.fijate-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ==========================================================================
   ADAPTACIÓN RESPONSIVA Y MÓVIL CANÓNICA
   ========================================================================== */
@media (max-width: 1024px) {
  .lottery-grid-selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .simulation-modes-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metrics-grid-top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .tool-layout {
    margin: 1rem auto 2rem;
    padding: 0 0.75rem;
  }

  .card-main,
  .terminal-card {
    padding: 1rem;
  }

  .lottery-grid-selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .lottery-card-btn {
    padding: 0.75rem 0.5rem;
  }

  .simulation-modes-bar {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .btn-mode {
    width: 100%;
    min-height: 42px;
  }

  .metrics-grid-top {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .metric-value {
    font-size: 1.25rem;
  }

  .actions-bar {
    flex-direction: column;
    width: 100%;
  }

  .btn-action {
    width: 100%;
    min-height: 44px;
  }

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

  .canvas-wrapper {
    height: 250px;
  }

  .shock-panel {
    grid-template-columns: 1fr;
  }

  .comparison-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
}
