/* ============================================================
   COMPONENTS.CSS — Todos los componentes de la UI
   ============================================================ */

/* ─── Splash ────────────────────────────────────────────────── */
#splash {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  animation: splashIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.splash-icon {
  font-size: 56px;
  filter: drop-shadow(0 0 30px rgba(99,102,241,0.5));
}

.splash-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Search box ────────────────────────────────────────────── */
.search-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.search-box {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.search-box input,
.search-box textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
}

.search-box input::placeholder { color: var(--text-tertiary); }

.search-results {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.search-result-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface-hover); }

.result-photo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--surface);
  flex-shrink: 0;
}

.result-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.result-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.result-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.result-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.result-add {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-2);
  background: var(--accent-glow);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.search-empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.search-empty.error { color: var(--red); }

/* ─── Spinner ───────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ─── Player Profile ────────────────────────────────────────── */
.profile-hero {
  position: relative;
  overflow: hidden;
  padding: var(--space-6);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: 200px;
  background-position: right -20px center;
  background-repeat: no-repeat;
  opacity: 0.04;
  filter: blur(2px);
}

.hero-content {
  position: relative;
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
}

.player-photo {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  background: var(--surface);
  flex-shrink: 0;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-md);
}

.hero-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.hero-badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 0.3px;
}

.badge-position {
  background: rgba(99,102,241,0.18);
  color: var(--accent-2);
  border: 1px solid rgba(99,102,241,0.3);
}

.badge-rating {
  background: rgba(245,158,11,0.15);
  color: var(--amber);
  border: 1px solid rgba(245,158,11,0.25);
}

.player-name {
  font-family: var(--font-display);
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-club {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--text-secondary);
}

.club-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.player-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.meta-tag {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px 10px;
}

/* ─── Quick stats ───────────────────────────────────────────── */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}

.quick-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-4) var(--space-3);
  text-align: center;
}

.qs-value {
  font-family: var(--font-display);
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.qs-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@media (max-width: 400px) {
  .quick-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Radar ─────────────────────────────────────────────────── */
.radar-panel {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
}

.radar-canvas {
  width: 100%;
  aspect-ratio: 1;
  max-height: 260px;
}

.radar-canvas--large {
  max-height: 320px;
}

/* ─── Stat bars ─────────────────────────────────────────────── */
.stats-panel {
  padding: var(--space-5);
}

.stat-bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stat-bar-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

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

.stat-bar-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-bar-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.bar-track {
  height: 5px;
  background: var(--surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  width: 0;
}

/* ─── AI Panel ──────────────────────────────────────────────── */
.ai-panel {
  padding: var(--space-5);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.panel-header .panel-title { margin-bottom: 0; }

.ai-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-2);
  background: var(--accent-glow);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: var(--radius-full);
  padding: 3px 10px;
}

.ai-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.ai-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.ai-text strong { color: var(--text-primary); }

.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) 0;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-6);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  box-shadow: 0 4px 20px rgba(99,102,241,0.35);
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.97); }

/* ─── Injuries ──────────────────────────────────────────────── */
.injuries-panel {
  padding: var(--space-5);
}

.injury-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.injury-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.12);
  border-radius: var(--radius-md);
}

.injury-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.injury-type {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.injury-date {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ─── Loading / Error states ────────────────────────────────── */
.profile-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-12) var(--space-6);
  color: var(--text-secondary);
  font-size: 14px;
}

.loading-pulse {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-glow);
  animation: pulse 1.4s ease-in-out infinite;
}

.profile-error {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-secondary);
}

/* ─── Compare ───────────────────────────────────────────────── */
.compare-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.compare-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}

.compare-slot {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
}

.slot-remove {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 22px;
  height: 22px;
  border: none;
  background: rgba(239,68,68,0.15);
  color: var(--red);
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.slot-remove:hover { background: rgba(239,68,68,0.3); }

.slot-photo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
}

.slot-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.slot-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.slot-quick {
  display: flex;
  gap: var(--space-2);
  font-size: 11px;
  color: var(--text-secondary);
}

.compare-add-area {
  padding: var(--space-4);
}

.compare-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.compare-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-3);
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.compare-metric {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}

.compare-metric:last-child { border-bottom: none; }

.metric-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.metric-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.metric-winner {
  font-size: 12px;
  font-weight: 600;
}

.metric-player-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.metric-player-name {
  font-size: 12px;
  font-weight: 600;
  width: 72px;
  flex-shrink: 0;
  text-align: right;
}

.metric-player-row .bar-track {
  flex: 1;
}

.metric-value {
  font-size: 12px;
  color: var(--text-secondary);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

#compare-bars-panel {
  padding: var(--space-5);
}

/* ─── Chat ──────────────────────────────────────────────────── */
.chat-page {
  height: calc(100dvh - var(--header-h) - var(--nav-h));
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  max-width: var(--max-w);
  margin: 0 auto;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-4);
  flex-shrink: 0;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(99,102,241,0.35);
}

.chat-header .page-title { font-size: 18px; }
.chat-header .page-subtitle { font-size: 12px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scroll-behavior: smooth;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
  padding: var(--space-8) 0;
}

.welcome-icon {
  font-size: 48px;
  filter: drop-shadow(0 0 20px rgba(99,102,241,0.4));
}

.chat-welcome h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.chat-welcome p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 340px;
  line-height: 1.6;
}

.suggested-questions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-top: var(--space-2);
}

.suggestion-chip {
  font-size: 13px;
  color: var(--accent-2);
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  font-family: var(--font-body);
  text-align: left;
  line-height: 1.4;
}

.suggestion-chip:hover {
  background: rgba(99,102,241,0.2);
  transform: translateY(-1px);
}

.chat-message {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
}

.chat-message.visible {
  opacity: 1;
  transform: translateY(0);
}

.chat-message--user {
  flex-direction: row-reverse;
}

.chat-message--user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) var(--space-1) var(--radius-lg);
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.msg-bubble {
  max-width: 80%;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--space-1) var(--radius-lg) var(--radius-lg) var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}

.chat-message--error .msg-bubble {
  border-color: rgba(239,68,68,0.25);
  background: rgba(239,68,68,0.08);
  color: var(--red);
}

.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-3) var(--space-5);
  margin-bottom: var(--space-3);
  border-radius: var(--radius-xl);
  flex-shrink: 0;
}

.chat-input-area textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  resize: none;
  line-height: 1.5;
  max-height: 120px;
}

.chat-input-area textarea::placeholder {
  color: var(--text-tertiary);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s, background 0.2s;
  box-shadow: 0 2px 12px rgba(99,102,241,0.4);
}

.chat-send-btn svg {
  width: 16px;
  height: 16px;
  color: #fff;
}

.chat-send-btn:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.chat-send-btn:not(:disabled):hover { opacity: 0.85; }
.chat-send-btn:not(:disabled):active { transform: scale(0.93); }

/* ─── Typing dots ───────────────────────────────────────────── */
.typing-dots {
  display: flex;
  gap: 5px;
  padding: 2px 0;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.30s; }
