/* Reset y variables CSS */
:root {
    --primary-color: #0066cc;
    --secondary-color: #f8f9fa;
    --accent-color: #dc3545;
    --background-light: #ffffff;
    --background-secondary: #f8f9fa;
    --text-dark: #212529;
    --text-muted: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--background-light) 0%, var(--secondary-color) 100%);
    color: var(--text-dark);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Dashboard */
.dashboard {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--background-light);
    box-shadow: 0 2px 10px var(--shadow-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo i {
    font-size: 2rem;
    color: var(--primary-color);
    animation: pulse 2s infinite;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
}

.status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
    font-weight: 600;
    color: var(--success-color);
}

.live-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.live-text {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.live-indicator {
    width: 10px;
    height: 10px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: blink 1s infinite;
    flex-shrink: 0;
}

.connection-info {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
    text-align: right;
}

/* Estadísticas Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    background: var(--background-secondary);
}

.stat-card {
    background: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px var(--shadow-color);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px var(--shadow-color);
}

.stat-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.stat-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Contenido principal */
.main-content {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    padding: 2rem;
    flex: 1;
}

/* Mapa */
.map-container {
    background: var(--background-light);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px var(--shadow-color);
}

.section-header {
    padding: 1.5rem;
    background: var(--background-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.3rem;
}

.section-header i {
    color: var(--primary-color);
}

.last-update {
    font-size: 0.8rem;
    color: var(--text-muted);
}

#map {
    height: 500px;
    background: var(--background-light);
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.countries-list,
.activity-chart,
.current-info,
.song-history {
    background: var(--background-light);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 0 4px 6px var(--shadow-color);
}

.countries-list h3,
.activity-chart h3,
.current-info h3,
.song-history h3 {
    padding: 1rem 1.5rem;
    background: var(--background-secondary);
    margin: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-dark);
}

.countries-list h3 i,
.activity-chart h3 i,
.current-info h3 i,
.song-history h3 i {
    color: var(--primary-color);
}

/* Lista de países */
#countries-ranking {
    padding: 1rem;
}

.country-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border-color);
}

.country-item:last-child {
    border-bottom: none;
}

.country-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.country-flag {
    font-size: 1.2rem;
}

.country-name {
    font-weight: 500;
    color: var(--text-dark);
}

.listener-count {
    background: var(--primary-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Gráfico de actividad */
.activity-chart {
    height: 280px;
}

#activityChart {
    padding: 1rem;
}

/* Información actual */
.now-playing {
    padding: 1.5rem;
}

.song-info {
    text-align: center;
}

.song-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.artist {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Historial de canciones */
.history-list {
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.history-item:hover {
    background-color: var(--background-secondary);
}

.history-item:last-child {
    border-bottom: none;
}

.history-item.loading {
    opacity: 0.6;
}

.history-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 45px;
    text-align: center;
    background: var(--background-secondary);
    border-radius: 8px;
    padding: 0.3rem 0.5rem;
}

.history-song {
    flex: 1;
}

.history-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.2rem;
    line-height: 1.3;
}

.history-artist {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.2;
}

/* Scroll personalizado para historial */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--background-secondary);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}

/* Animaciones */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card,
.map-container,
.countries-list,
.activity-chart,
.current-info,
.song-history {
    animation: fadeIn 0.6s ease-out;
}

/* Responsivo */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }
    
    .sidebar {
        grid-row: 2;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .status {
        align-items: center;
    }
    
    .live-status {
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        padding: 1rem;
        gap: 1rem;
    }
    
    .main-content {
        padding: 1rem;
        gap: 1rem;
    }
    
    #map {
        height: 400px;
    }
    
    .sidebar {
        grid-template-columns: 1fr;
    }
}

/* Estilos personalizados para Leaflet */
.leaflet-popup-content-wrapper {
    background: var(--background-light);
    color: var(--text-dark);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px var(--shadow-color);
}

.leaflet-popup-tip {
    background: var(--background-light);
    border: 1px solid var(--border-color);
}

.custom-popup {
    text-align: center;
    padding: 0.5rem;
}

.custom-popup h4 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
}

.custom-popup p {
    margin: 0;
    font-size: 0.9rem;
}