/* CSS para el sistema de amigos */

.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--accent, #ff0d7a);
  color: white;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: bold;
  min-width: 18px;
  text-align: center;
  display: none;
}

.friends-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100%;
  background: #1a1a2e; /* Fondo sólido oscuro sin transparencia */
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
  transition: right 0.3s ease;
  z-index: 9999;
  display: flex;
  flex-direction: column;
}

.friends-panel.open {
  right: 0;
}

.friends-header {
  padding: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #14141e; /* Fondo sólido más oscuro */
}

.friends-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.friends-tabs {
  display: flex;
  background: #14141e; /* Fondo sólido */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  position: relative;
  transition: all 0.2s;
}

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

.tab-btn.active {
  color: var(--fg);
  background: var(--cardBg);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}

.tab-badge {
  background: var(--accent);
  color: white;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 10px;
  margin-left: 5px;
}

.friends-tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  background: #1a1a2e; /* Fondo sólido para el contenido */
}

.friends-tab-content.active {
  display: block;
}

.friends-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.friends-group {
  margin-bottom: 20px;
}

.group-title {
  font-size: 12px;
  text-transform: uppercase;
}

/* Estilos para partidas abiertas */
.matches-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-item {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--cardBg);
  border: 1px solid var(--cardBorder);
  border-radius: 8px;
  transition: all 0.2s;
}

.match-item:hover {
  background: var(--pillBg);
  border-color: var(--accent);
}

.match-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 12px;
  flex-shrink: 0;
}

.match-status.requester {
  background: #10b981; /* Verde para creador */
}

.match-status.accepter {
  background: #3b82f6; /* Azul para quien aceptó */
}

.match-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

.match-info {
  flex: 1;
  min-width: 0;
}

.match-opponent {
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
}

.match-details {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.match-time {
  font-size: 10px;
  color: var(--muted);
}

/* Tiempo crítico (≤ 1h) */
.time-danger {
  color: #f44336;
}

.match-turn {
  font-size: 10px;
  color: var(--muted);
}

.match-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--pillBg);
  border-radius: 8px;
  transition: background 0.2s;
}

.friend-item:hover {
  background: var(--cardBorder);
}

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

.friend-status.online {
  background: #4caf50;
  box-shadow: 0 0 5px #4caf50;
}

.friend-status.offline {
  background: #666;
}

.friend-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.friend-info {
  flex: 1;
  min-width: 0;
}

.friend-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-level {
  font-size: 12px;
  color: var(--muted);
}

.friend-actions {
  display: flex;
  gap: 5px;
}

.search-section {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.search-section .input {
  flex: 1;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--pillBg);
  border-radius: 8px;
}

/* Asegurar layout correcto: info a la izquierda, botón a la derecha */
.search-result-item .friend-info { flex: 1; min-width: 0; }
.search-result-item .btn { width: auto; flex-shrink: 0; padding: 10px 16px; }

.request-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--pillBg);
  border-radius: 8px;
  margin-bottom: 10px;
}

.request-group {
  margin-bottom: 20px;
}

.rankings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--pillBg);
  border-radius: 8px;
  position: relative;
}

.ranking-item .friend-avatar {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  object-fit: cover;
}

.ranking-item.top-rank {
  background: linear-gradient(135deg, var(--pillBg), var(--accent));
}

.ranking-item.top-rank .ranking-position {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #1a1a2e;
  border: 2px solid #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.ranking-item.top-rank .friend-avatar {
  border: 3px solid #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.ranking-item.current-user {
  border: 2px solid var(--accent);
}

.ranking-position {
  font-weight: 800;
  font-size: 18px;
  width: 30px;
  text-align: center;
  color: var(--accent);
  background: var(--card);
  border-radius: 50%;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.ranking-stats {
  display: flex;
  gap: 10px;
  font-size: 12px;
  margin-top: 2px;
}

.wins {
  color: #4caf50;
}

.losses {
  color: #f44336;
}

.winrate {
  color: var(--accent);
  font-weight: 600;
}

.stats-bar {
  height: 4px;
  background: var(--cardBorder);
  border-radius: 2px;
  margin-top: 5px;
  overflow: hidden;
}

.wins-bar {
  height: 100%;
  background: #4caf50;
  transition: width 0.3s;
}

.you-badge {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  background: var(--accent);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 20px;
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 20px;
}

.error {
  text-align: center;
  color: #f44336;
  padding: 20px;
}

.friend-status-text {
  color: var(--muted);
  font-size: 12px;
}

/* Panel de perfil de amigo */
.friend-profile-panel {
  max-width: 500px;
  margin: auto;
}

.profile-header-horizontal {
  display: flex;
  gap: 20px;
  align-items: center;
  margin: 20px 0;
}

.profile-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-info {
  flex: 1;
}

.profile-nickname {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 5px;
}

.stats-row {
  display: flex;
  justify-content: space-around;
  padding: 10px 0;
}

.stat-compact {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.profile-section.compact {
  padding: 10px 0;
}

.profile-section.compact h4 {
  font-size: 14px;
  margin-bottom: 10px;
}

/* Responsive para móviles */
@media (max-width: 768px) {
  .friends-panel {
    width: 100%;
    right: -100%;
  }
  
  .friends-tabs {
    font-size: 14px;
  }
  
  .tab-btn {
    padding: 10px 5px;
    font-size: 12px;
  }
}
