/* api_fit — design tokens
 * Origen: Claude Design "ai-sport" (api_fit prototipo.html)
 * https://api.anthropic.com/v1/design/h/yfAQix3VtnvsqXie6dNqfg
 */

:root {
  /* Type scales */
  --font-display: "Fraunces", "Times New Roman", serif;
  --font-sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "Geist Mono", ui-monospace, monospace;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Radii */
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 10px;
  --r-4: 14px;

  /* Status (constant across modes) */
  --good: #16a34a;
  --good-soft: rgba(22, 163, 74, 0.12);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --bad: #dc2626;
  --bad-soft: rgba(220, 38, 38, 0.12);
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.12);

  /* Accent (overridable via tweak) */
  --accent: #16a34a;
  --accent-soft: rgba(22, 163, 74, 0.14);
  --accent-fg: #ffffff;
}

/* DARK (default — P3 vive en oscuro) */
[data-theme="dark"] {
  --bg: #0a0b0d;
  --bg-1: #0f1115;
  --bg-2: #14171c;
  --bg-3: #1a1e25;
  --line: #232830;
  --line-soft: #1a1e25;
  --text: #e8eaed;
  --text-2: #a8b0bb;
  --text-3: #6b7380;
  --text-4: #4a5160;

  --hero-bg: linear-gradient(180deg, #0d1014 0%, #0a0b0d 100%);
  --grid: rgba(255, 255, 255, 0.04);
  --shadow-1: 0 1px 2px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-2: 0 12px 40px -8px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
}

/* LIGHT */
[data-theme="light"] {
  --bg: #f7f6f1;
  --bg-1: #fbfaf6;
  --bg-2: #ffffff;
  --bg-3: #f0eee7;
  --line: #e2dfd5;
  --line-soft: #ece9df;
  --text: #1a1a1a;
  --text-2: #4a4a4a;
  --text-3: #7a7a78;
  --text-4: #a8a6a0;

  --hero-bg: linear-gradient(180deg, #ffffff 0%, #faf9f4 100%);
  --grid: rgba(0, 0, 0, 0.04);
  --shadow-1: 0 1px 2px rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-2: 0 16px 40px -16px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.05);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }

/* Mono numerals */
.num, .mono { font-family: var(--font-mono); font-feature-settings: "tnum", "zero"; }
.tabular { font-variant-numeric: tabular-nums; }

/* Display */
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.02em; }

/* Density */
[data-density="compact"] {
  --sp-row: 8px;
  --card-pad: 14px;
}
[data-density="comfortable"] {
  --sp-row: 12px;
  --card-pad: 18px;
}
[data-density="detailed"] {
  --sp-row: 14px;
  --card-pad: 22px;
}

/* ============ RESPONSIVE ============ */
/* Tablet */
@media (max-width: 1024px) {
  body { font-size: 13.5px; }
  .af-grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
  .af-grid-3 { grid-template-columns: repeat(2, 1fr) !important; }
  .af-grid-2 { grid-template-columns: 1fr !important; }
  .af-hero { grid-template-columns: 1fr !important; }
  .af-hero-divider { display: none; }
  .af-padded { padding: var(--sp-5) var(--sp-5) 80px !important; }
  .af-topbar { padding: var(--sp-5) var(--sp-5) var(--sp-4) !important; }
  .af-topbar h1 { font-size: 26px !important; }
  .af-sidebar { width: 64px !important; padding: var(--sp-4) var(--sp-2) !important; }
  .af-sidebar .af-sidebar-label,
  .af-sidebar .af-sidebar-onboarding,
  .af-sidebar .af-sidebar-privacy,
  .af-sidebar .af-sidebar-user-text,
  .af-sidebar .af-sidebar-version { display: none !important; }
  .af-sidebar .af-sidebar-nav-btn { justify-content: center; padding: 10px !important; }
  .af-sidebar .af-sidebar-wordmark { justify-content: center; margin-bottom: var(--sp-6) !important; }
  .af-density-toggle { display: none !important; }
  .af-table-scroll { overflow-x: auto; }
  .af-agents-grid { grid-template-columns: 1fr !important; height: auto !important; }
  .af-agents-side { display: none !important; }
}

/* Mobile */
@media (max-width: 640px) {
  body { font-size: 13px; }
  .af-padded { padding: var(--sp-4) var(--sp-3) 80px !important; gap: 12px !important; }
  .af-topbar { padding: var(--sp-3) var(--sp-3) var(--sp-3) !important; flex-wrap: wrap; gap: 10px !important; }
  .af-topbar h1 { font-size: 22px !important; }
  .af-topbar-actions { width: 100%; justify-content: flex-end; }
  .af-grid-4 { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .af-grid-3 { grid-template-columns: 1fr !important; }
  .af-grid-6 { grid-template-columns: repeat(3, 1fr) !important; gap: 10px !important; }
  .af-hero-content { padding: 18px !important; }
  .af-hero-content h2 { font-size: 26px !important; }
  .af-sidebar { display: none !important; }
  .af-mobile-bar { display: flex !important; }
  .af-drawer-root { display: block !important; }
  .af-card { padding: 14px !important; }
  .af-sync-row { flex-wrap: wrap; gap: 6px !important; font-size: 10.5px !important; }
  .af-table { font-size: 11px !important; }
  .af-table th, .af-table td { padding: 8px 6px !important; }
  .af-hide-mobile { display: none !important; }
  .af-stack-mobile { grid-template-columns: 1fr !important; }
  .af-plan-cal { grid-template-columns: 50px repeat(7, minmax(72px, 1fr)) !important; overflow-x: auto; }
  .af-plan-cal-wrap { overflow-x: auto; }
}
.af-mobile-bar { display: none; }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* Focus */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Selection */
::selection { background: var(--accent); color: var(--accent-fg); }

/* Utility */
.row { display: flex; align-items: center; gap: var(--sp-3); }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); width: 100%; }
.vdivider { width: 1px; background: var(--line); align-self: stretch; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}

.muted { color: var(--text-3); }
.muted-2 { color: var(--text-4); }

a { color: inherit; text-decoration: none; }

/* Animations */
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes skel-pulse {
  0%, 100% { background-position: 200% 0; }
  50% { background-position: 0 0; }
}
@keyframes af-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}
@keyframes af-spin { to { transform: rotate(360deg); } }

/* Leaflet override: attribution legible en ambos themes y zoom controls
 * con borde discreto. No reescribimos la lib, sólo ajustamos colores. */
.leaflet-container {
  background: var(--bg-2) !important;
  font-family: var(--font-system, system-ui), sans-serif;
  border-radius: inherit;
}
.leaflet-control-attribution {
  background: rgba(0, 0, 0, 0.55) !important;
  color: rgba(255, 255, 255, 0.85) !important;
  font-size: 9.5px !important;
  padding: 1px 6px !important;
}
.leaflet-control-attribution a {
  color: rgba(255, 255, 255, 0.95) !important;
}
.leaflet-bar a {
  background: var(--bg) !important;
  color: var(--text) !important;
  border-bottom-color: var(--line) !important;
}
.leaflet-bar a:hover {
  background: var(--bg-2) !important;
}

.fade-in { animation: fade-in 0.3s ease-out; }

/* Login gate */
.af-login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}
.af-login-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 32px;
}
.af-login-input {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  color: var(--text);
  outline: none;
}
.af-login-input:focus { border-color: var(--accent); }

/* Toast */
.af-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  font-size: 12.5px;
  color: var(--text);
  box-shadow: var(--shadow-2);
  z-index: 1000;
  max-width: 360px;
}
.af-toast.bad { border-color: var(--bad); color: var(--bad); }
.af-toast.good { border-color: var(--good); color: var(--good); }
