:root {
    --primary-color: #d10000;
    --secondary-color: #000;
    --text-color: #fff;
    --bg-color: #111;
    --card-bg: #1a1a1a;
    --border-color: #333;
}

/* Estilos base */
html, body {
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    
    /* Imagen de fondo */
    background-image: url('imagen/fondo.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Header */
.header {
    background: var(--secondary-color);
    color: var(--text-color);
    padding: 1rem 0;
    border-bottom: 3px solid var(--primary-color);
    width: 100%;
}

.header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.header .subtitle {
    font-size: clamp(0.65rem, 2vw, 0.9rem);
    margin: 0.3rem 0 0;
    font-weight: 300;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.4), 0 0 8px rgba(209, 0, 0, 0.4);
    position: relative;
    font-style: italic;
    font-family: 'Times New Roman', serif;
    line-height: 1.3;
}

/* Contenedor principal */
.container-main {
    padding: clamp(1rem, 3vw, 2rem);
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Selector de categorías */
.category-selector {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    padding: 0.5rem 0;
}

.category-btn {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    font-size: clamp(0.7rem, 2vw, 0.9rem);
}

.category-btn:hover, .category-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* Tooltip para categorías */
.category-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
    z-index: 100;
    margin-bottom: 10px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s;
}

.category-btn:hover::after {
    visibility: visible;
    opacity: 1;
}

.category-btn:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% - 5px);
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #333;
    z-index: 101;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s;
}

.category-btn:hover::before {
    visibility: visible;
    opacity: 1;
}

/* Grid de estaciones */
.stations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: clamp(0.8rem, 2vw, 1.5rem);
    margin-bottom: 100px;
    width: 100%;
}

/* Tarjetas de estaciones */
.station-card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    position: relative;
}

.station-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border-color: var(--primary-color);
}

.station-card.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color);
}

.station-img-container {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
}

.station-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.station-info {
    padding: 1rem;
    flex-grow: 1;
    text-align: center;
}

.station-name {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    margin: 0 0 0.5rem 0;
    font-weight: bold;
    color: #aaa;
}

.station-location {
    font-size: clamp(0.8rem, 1.5vw, 0.9rem);
    color: #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.station-category {
    display: inline-block;
    background: rgba(209, 0, 0, 0.2);
    color: var(--primary-color);
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: clamp(0.7rem, 1.5vw, 0.8rem);
    margin-top: 0.5rem;
}

/* Reproductor */
.player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--secondary-color);
    border-top: 3px solid var(--primary-color);
    padding: clamp(0.5rem, 2vw, 1rem);
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 2vw, 1.5rem);
    z-index: 1000;
    flex-wrap: wrap;
}

.player-cover {
    width: clamp(40px, 8vw, 60px);
    height: clamp(40px, 8vw, 60px);
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    transition: transform 0.5s;
}

.player-cover.playing {
    animation: rotate 10s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.player-info {
    flex-grow: 1;
    color: #aaa;
    min-width: 150px;
}

.player-title {
    font-size: clamp(0.8rem, 2vw, 1rem);
    margin: 0;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.player-station {
    font-size: clamp(0.6rem, 1.5vw, 0.7rem);
    color: #aaa;
    margin: 0.2rem 0 0 0;
}

.station-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1.5vw, 1rem);
    justify-content: center;
}

.player-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: clamp(0.8rem, 2vw, 1rem);
    cursor: pointer;
    transition: color 0.3s;
    width: clamp(30px, 6vw, 40px);
    height: clamp(30px, 6vw, 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.player-btn:hover {
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

.player-btn i {
    pointer-events: none;
}

.visualizer {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 40px;
    margin-left: clamp(0.5rem, 1.5vw, 1rem);
}

.visualizer-bar {
    width: 4px;
    background: var(--primary-color);
    border-radius: 2px;
    transition: height 0.1s;
}

.player-meta {
    text-align: center;
    font-size: clamp(0.7rem, 1.5vw, 0.8rem);
    color: #aaa;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.top-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.player-meta div {
    margin-bottom: 0.2rem;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: clamp(0.5rem, 1.5vw, 1rem);
}

.volume-slider {
    width: clamp(60px, 10vw, 80px);
}

.no-stations {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: #777;
}

/* Estado de conexión */
.connection-status {
    font-size: clamp(0.7rem, 1.5vw, 0.8rem);
    margin-top: 0.3rem;
}

.status-connecting {
    color: #ffcc00;
}

.status-playing {
    color: #4CAF50;
}

.status-error {
    color: #f44336;
}

/* Favoritos */
.favorite-control {
    margin-left: 10px;
}

.favorite-control .fa-star {
    color: #ccc;
    transition: all 0.3s;
}

.favorite-control .favorited {
    color: red;
}

.station-card .favorite-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    color: red;
    font-size: 12px;
    display: none;
    z-index: 2;
}

.station-card.favorited .favorite-badge {
    display: block;
}

/* Categorías flotantes */
.floating-categories-container {
    position: fixed;
    left: -60px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 900;
    transition: left 0.3s ease;
    display: none;
}

.floating-categories-container.visible {
    left: 10px;
    display: block;
}

.floating-categories-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 0 10px 10px 0;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.floating-categories-container .category-btn {
    width: 50px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.categories-container {
    position: relative;
    z-index: 1000;
    transition: all 0.3s ease;
}

.floating-categories-container .category-btn svg,
.categories-container .category-btn svg {
    width: 24px !important;
    height: 24px !important;
    transform: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Media queries para responsividad */
@media (max-width: 992px) {
    .stations-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    .stations-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .player {
        flex-wrap: wrap;
        gap: 0.8rem;
        padding: 0.8rem;
    }
    
    .player-controls {
        order: 1;
        width: 100%;
        justify-content: center;
    }
    
    .visualizer {
        order: 2;
        width: 100%;
        justify-content: center;
        margin: 0;
    }
    
    .player-meta {
        order: 3;
        width: 100%;
        text-align: center;
    }
    
    .volume-control {
        margin: 0.5rem auto;
    }
}

@media (max-width: 576px) {
    .stations-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.8rem;
    }
    
    .station-img {
        width: 60px;
        height: 60px;
    }
    
    .station-info {
        padding: 0.8rem;
    }
}

/* Ajustes específicos para header y categorías en pantallas pequeñas */
@media (max-width: 480px) {
    .header {
        padding: 0.5rem 0.3rem;
        text-align: center;
    }
    
    .header h1 {
        font-size: clamp(1.1rem, 3vw, 1.3rem);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0 0.5rem;
    }
    
    .header .subtitle {
        font-size: clamp(0.6rem, 1.5vw, 0.65rem);
        white-space: normal;
        line-height: 1.2;
        max-width: 100%;
        padding: 0 0.5rem;
        margin: 0.2rem 0 0;
    }
    
    .category-selector {
        overflow-x: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin: 0.5rem 0;
    }
    
    .category-selector::-webkit-scrollbar {
        display: none;
    }
    
    .category-btn {
        flex: 0 0 auto;
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }
    
    .stations-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    
    .player-title {
        max-width: 100%;
    }
    
    .player-cover {
        width: 40px;
        height: 40px;
    }
}

/* Ajustes adicionales para pantallas muy estrechas */
@media (max-width: 320px) {
    .header h1 {
        font-size: 1.1rem;
    }
    
    .header .subtitle {
        font-size: 0.6rem;
    }
    
    .category-btn {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }
    
    .stations-grid {
        grid-template-columns: 1fr;
    }
    
    .player {
        padding: 0.5rem;
    }
}

/* Estilos para el slider de volumen */
input[type="range"] {
    -webkit-appearance: none;
    width: 100px;
    background: transparent;
    height: 6px;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: var(--primary-color);
    border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 1px solid var(--primary-color);
    border-radius: 50%;
    margin-top: -4px;
    cursor: pointer;
}

input[type="range"]::-moz-range-track {
    height: 6px;
    background: var(--primary-color);
    border-radius: 3px;
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #fff;
    border: 1px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

/* Tooltip general */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 100;
}