<template>
  <div class="data-source-selector glass light">
    <div class="source-label">Fuente de datos:</div>
    <div class="source-buttons">
      <button 
        class="source-btn" 
        :class="{ active: modelValue === 'aggregated' }"
        @click="$emit('update:modelValue', 'aggregated')"
        title="Muestra el total histórico de todas las acciones registradas de los jugadores"
      >
        <span class="source-icon">📁</span>
        Datos Agregados (Histórico)
      </button>
      <button 
        class="source-btn" 
        :class="{ active: modelValue === 'active-rooms' }"
        @click="$emit('update:modelValue', 'active-rooms')"
        title="Muestra solo los datos de las salas actualmente activas"
      >
        <span class="source-icon">🔴</span>
        Salas Activas (Tiempo Real)
      </button>
    </div>
  </div>
</template>

<script setup lang="ts">
import type { DataSource } from '../composables/useEventFilters';

interface Props {
  modelValue: DataSource;
}

defineProps<Props>();

defineEmits<{
  'update:modelValue': [value: DataSource];
}>();
</script>

<style scoped>
.glass.light { 
  background: rgba(255, 255, 255, 0.78); 
  border: 1px solid rgba(229, 231, 235, 0.9); 
  box-shadow: 0 18px 50px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.6); 
  backdrop-filter: blur(18px) saturate(120%); 
  -webkit-backdrop-filter: blur(18px) saturate(120%); 
  border-radius: 16px; 
}

.data-source-selector {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  margin-bottom: 14px;
}

.source-label {
  font-size: 14px;
  font-weight: 700;
  color: #334155;
}

.source-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.source-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: rgba(255,255,255,0.6);
  color: #64748b;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.source-btn:hover {
  background: rgba(255,255,255,0.9);
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.source-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: #667eea;
  box-shadow: 0 6px 20px rgba(102,126,234,0.3);
}

.source-btn.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102,126,234,0.4);
}

.source-icon {
  font-size: 16px;
}

@media (max-width: 640px) {
  .data-source-selector {
    flex-direction: column;
    align-items: stretch;
  }
  
  .source-buttons {
    flex-direction: column;
  }
  
  .source-btn {
    justify-content: center;
  }
}
</style>