/* =====================================================
   TEG Bitácora — Estilos mobile-first
   ===================================================== */

:root {
  --bg:       #0f1117;
  --bg2:      #1a1d2e;
  --bg3:      #22263a;
  --border:   #2a2f4a;
  --text:     #e0e6f0;
  --text2:    #8a94b0;
  --accent:   #5b8af0;
  --success:  #3dba6f;
  --danger:   #e05050;
  --warning:  #e0a040;
  --radius:   8px;
  --shadow:   0 2px 8px rgba(0,0,0,.4);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* ── Typography ── */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
small { font-size: .8rem; color: var(--text2); }

/* ── Layout ── */
.container { max-width: 700px; margin: 0 auto; padding: 0 16px; }

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: .95rem;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-warning   { background: var(--warning); color: #000; }
.btn-ghost     { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm        { min-height: 34px; padding: 4px 12px; font-size: .85rem; }
.btn-full      { width: 100%; }

/* ── Forms ── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; color: var(--text2); margin-bottom: 5px; }
.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); }
.field select option { background: var(--bg3); }

/* ── Number stepper ── */
.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.stepper button {
  width: 40px; height: 40px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.stepper input {
  width: 56px; text-align: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  color: var(--text);
}

/* ── Chips ── */
.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
}
.chip-green  { background: rgba(61,186,111,.2);  color: #3dba6f; }
.chip-gray   { background: rgba(138,148,176,.15); color: #8a94b0; }
.chip-blue   { background: rgba(91,138,240,.2);  color: #5b8af0; }
.chip-orange { background: rgba(224,160,64,.2);  color: #e0a040; }
.chip-red    { background: rgba(224,80,80,.2);   color: #e05050; }

/* ── Color dot ── */
.color-dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25);
  flex-shrink: 0;
}

/* ── Header sticky ── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,17,23,.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-header .logo { font-weight: 800; font-size: 1.1rem; letter-spacing: 1px; }
.app-header .breadcrumb { color: var(--text2); font-size: .85rem; }

/* ── Toast ── */
#toast-container {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: .9rem;
  box-shadow: var(--shadow);
  animation: slide-up .25s ease;
  pointer-events: auto;
  max-width: 320px;
  text-align: center;
}
.toast.toast-success { border-color: var(--success); color: var(--success); }
.toast.toast-error   { border-color: var(--danger);  color: var(--danger);  }
@keyframes slide-up { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: none; } }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-close {
  background: none; border: none;
  color: var(--text2); font-size: 1.4rem; cursor: pointer; line-height: 1;
}

/* ── Accordion ── */
.accordion summary {
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  font-weight: 600;
  list-style: none;
  user-select: none;
}
.accordion summary::after { content: '▾'; transition: transform .2s; }
.accordion[open] summary::after { transform: rotate(180deg); }
.accordion-content { padding-bottom: 8px; }

/* ── Mapa: lista de países ── */
.continente-section { margin-bottom: 8px; }
.pais-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  padding: 8px 0;
}
.pais-card {
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--bg3);
  cursor: pointer;
  transition: border-color .15s;
}
.pais-card:hover { border-color: var(--accent); }
.pais-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(91,138,240,.3); }
.pais-card .pais-nombre { font-size: .8rem; font-weight: 600; }
.pais-card .pais-info { display: flex; align-items: center; gap: 5px; font-size: .75rem; color: var(--text2); }
.pais-card .ejercitos-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; border-radius: 99px;
  background: rgba(255,255,255,.12);
  font-size: .75rem; font-weight: 700; padding: 0 5px;
}

/* ── Turno: panel de fase ── */
.fase-nav {
  display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none;
}
.fase-nav::-webkit-scrollbar { display: none; }
.fase-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  font-size: .82rem; font-weight: 600;
  cursor: default;
}
.fase-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.fase-btn.done   { background: rgba(61,186,111,.15); border-color: var(--success); color: var(--success); }

/* ── Historial ── */
.historial-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.historial-item {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: .82rem; padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.historial-item:last-child { border-bottom: none; }
.historial-icon { font-size: 1rem; flex-shrink: 0; }

/* ── Setup wizard ── */
.wizard-steps {
  display: flex; gap: 4px; margin-bottom: 20px;
  align-items: center;
}
.wizard-step {
  flex: 1; height: 4px; border-radius: 2px;
  background: var(--border);
  transition: background .3s;
}
.wizard-step.done    { background: var(--success); }
.wizard-step.active  { background: var(--accent); }

.jugador-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.jugador-row:last-child { border-bottom: none; }

.color-picker {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0;
}
.color-option {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer; transition: border-color .15s;
}
.color-option.selected { border-color: #fff; }
.color-option.used { opacity: .3; cursor: not-allowed; }

/* ── Home: lista partidas ── */
.partida-card {
  display: block;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  transition: border-color .15s;
  text-decoration: none; color: inherit;
}
.partida-card:hover { border-color: var(--accent); }
.partida-card .meta { color: var(--text2); font-size: .82rem; margin-top: 4px; }
.partida-card .jugadores-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.jugador-tag {
  display: flex; align-items: center; gap: 5px;
  background: var(--bg3); padding: 3px 8px; border-radius: 99px;
  font-size: .8rem;
}

/* ── Tarjeta de situación ── */
.situacion-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.situacion-option {
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 10px; cursor: pointer;
  text-align: center; transition: border-color .15s;
}
.situacion-option:hover, .situacion-option.selected { border-color: var(--accent); }
.situacion-option .icon { font-size: 1.5rem; }
.situacion-option .label { font-size: .8rem; font-weight: 600; margin-top: 4px; }

/* ── Responsive > 600px ── */
@media (min-width: 600px) {
  .pais-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .situacion-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Loading spinner ── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Divider ── */
.divider {
  border: none; border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── Inline alerts ── */
.alert {
  padding: 10px 14px; border-radius: 6px; font-size: .88rem;
  margin-bottom: 12px;
}
.alert-info    { background: rgba(91,138,240,.15); border: 1px solid rgba(91,138,240,.3); }
.alert-warning { background: rgba(224,160,64,.15); border: 1px solid rgba(224,160,64,.3); }
.alert-success { background: rgba(61,186,111,.15); border: 1px solid rgba(61,186,111,.3); }

/* ── Distribution table ── */
.dist-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.dist-table th, .dist-table td {
  padding: 8px 10px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.dist-table th { color: var(--text2); font-weight: 600; }
.dist-table select {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 8px; color: var(--text);
  width: 100%;
}

/* ── Pactos ── */
.pacto-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.pacto-row .vs { color: var(--text2); font-size: .75rem; }
.pacto-row.inactivo { opacity: .45; }
