/* ==========================================================================
   Pizarra táctica deportiva animada
   Estilos canónicos para fijate.com/tools/pizarra-tactica-deportiva/
   ========================================================================== */

: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-surface: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-text: #ffffff;

  --pitch-grass: #15803d;
  --pitch-lines: #ffffff;
  --home-color: #2563eb;
  --away-color: #dc2626;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #131b2a;
  --bg-surface: #1e293b;
  --bg-surface-hover: #334155;
  --border-color: #1e293b;
  --border-focus: #60a5fa;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-text: #ffffff;

  --pitch-grass: #14532d;
  --pitch-lines: #f8fafc;
  --home-color: #3b82f6;
  --away-color: #ef4444;
}

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

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

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

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

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

.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.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

/* ================= BARRA SUPERIOR DE HERRAMIENTAS ================= */
.tactic-top-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.sport-select-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 240px;
}

.bar-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 40px;
  padding: 0 2.25rem 0 0.85rem;
  font-family: var(--font-main);
  font-size: 0.88rem;
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
}

.select-compact {
  max-width: 280px;
}

.select-inline {
  width: 130px;
}

.tactic-mode-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-group-toggle {
  display: flex;
  background: var(--bg-surface);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 2px;
}

.btn-tool-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 34px;
}

.btn-tool-mode:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

.btn-tool-mode.active {
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: var(--shadow-sm);
}

.tactic-quick-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-secondary, .btn-primary, .btn-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 1rem;
  height: 40px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}

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

.btn-secondary:hover {
  background: var(--bg-surface-hover);
}

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

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-export {
  background: #0284c7;
  color: #ffffff;
}

.btn-export:hover {
  background: #0369a1;
}

.btn-export-video {
  background: #059669;
}

.btn-export-video:hover {
  background: #047857;
}

/* ================= ÁREA DE LA PIZARRA ================= */
.tactic-board-wrapper {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 1.25rem;
  align-items: start;
}

.pitch-container {
  position: relative;
  background: #0f172a;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  touch-action: none;
  user-select: none;
}

#tactic-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 580;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ================= PANEL LATERAL DE BANQUILLO ================= */
.bench-side-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bench-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.bench-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bench-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-main);
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-home { background: var(--home-color); }
.dot-away { background: var(--away-color); }

.bench-tokens-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}

.bench-token {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffffff;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
  user-select: none;
}

.bench-token:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.token-home { background: var(--home-color); }
.token-away { background: var(--away-color); }

.bench-props-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.prop-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.prop-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--primary);
}

.prop-icon {
  font-size: 1.25rem;
}

/* ================= LÍNEA DE TIEMPO (TIMELINE) ================= */
.timeline-container {
  margin-top: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

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

.playback-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-play-anim {
  background: #16a34a;
}

.btn-play-anim:hover {
  background: #15803d;
}

.speed-control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.export-buttons-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.keyframes-track {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  scrollbar-width: thin;
}

.keyframe-card {
  flex: 0 0 110px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  position: relative;
}

.keyframe-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.keyframe-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.keyframe-thumb {
  width: 100%;
  aspect-ratio: 900 / 580;
  background: #064e3b;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.keyframe-label {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ================= PREGUNTAS FRECUENTES ================= */
.tool-faq-section {
  margin-top: 2.5rem;
  margin-bottom: 2rem;
}

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

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

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

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

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

.faq-chevron {
  transition: transform 0.2s ease;
  flex-shrink: 0;
  color: var(--text-muted);
}

.faq-item[open] .faq-chevron {
  transform: rotate(180deg);
}

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

.faq-answer p {
  margin: 0;
}

/* ================= MODAL ================= */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.app-modal-backdrop.active {
  display: flex;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

.app-modal-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}

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

.app-modal-body {
  padding: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-muted);
}

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

.bench-hint {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-main);
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

/* ================= RESPONSIVE ================= */
@media (max-width: 950px) {
  .tactic-board-wrapper {
    grid-template-columns: 1fr;
  }

  .bench-tokens-grid {
    grid-template-columns: repeat(8, 1fr);
  }

  .bench-props-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

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

  .card-main {
    padding: 0.85rem;
  }

  .tactic-top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .sport-select-group {
    flex-direction: column;
    align-items: stretch;
  }

  .select-compact {
    max-width: 100%;
  }

  .btn-group-toggle {
    width: 100%;
    overflow-x: auto;
  }

  .btn-tool-mode {
    flex: 1 1 0%;
    justify-content: center;
  }

  .tactic-quick-actions {
    width: 100%;
  }

  .tactic-quick-actions .btn-secondary {
    flex: 1 1 0%;
  }

  .timeline-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .playback-buttons, .export-buttons-group {
    width: 100%;
    flex-direction: column;
  }

  .btn-play-anim, .btn-export, .btn-secondary {
    width: 100%;
    min-height: 44px;
  }

  .bench-tokens-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}
