* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f9f9f9;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    color: #ff0000;
    margin-bottom: 20px;
    font-size: 2em;
}

/* REPRODUCTOR PRINCIPAL */
.player-section {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.player-info {
    flex: 1;
}

.player-title {
    font-size: 18px;
    font-weight: 700;
    color: #030303;
    margin-bottom: 5px;
}

.player-subtitle {
    font-size: 14px;
    color: #606060;
}

.player-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.play-btn {
    background-color: #ff0000;
    color: white;
}

.play-btn:hover {
    background-color: #cc0000;
}

.play-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.nav-btn {
    background-color: #065fd4;
    color: white;
}

.nav-btn:hover {
    background-color: #0047a3;
}

.nav-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* CONTENEDOR DEL REPRODUCTOR CON PUBLICIDAD */
.player-with-ads {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

#playerContainer {
    flex: 1;
    min-width: 0;
}

.current-player {
    position: relative;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
}

.current-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.empty-player {
    position: relative;
    padding-bottom: 56.25%;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.empty-player-content {
    position: absolute;
    text-align: center;
    color: white;
}

.empty-player-content h3 {
    font-size: 24px;
    margin-bottom: 10px;
}

.empty-player-content p {
    font-size: 16px;
    opacity: 0.8;
}

/* ESPACIOS PUBLICITARIOS */
.ad-sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 320px;
    flex-shrink: 0;
}

.ad-space {
    background: #f5f5f5;
    border-radius: 8px;
    border: 2px dashed #ddd;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ad-space:hover {
    border-color: #999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ad-label {
    background: #e0e0e0;
    padding: 5px 10px;
    font-size: 11px;
    color: #666;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ad-content {
    padding: 20px;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #999;
}

.ad-content p {
    margin: 5px 0;
}

.ad-size {
    font-size: 12px;
    color: #bbb;
    font-style: italic;
}

/* Responsive para publicidad */
@media (max-width: 1200px) {
    .ad-sidebar {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .ad-sidebar {
        width: 250px;
    }
    
    .ad-content {
        padding: 15px;
        min-height: 200px;
    }
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    align-items: start;
}

/* CORRECCIÓN RESPONSIVE PARA MÓVILES */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .playlist-sidebar {
        order: 2; /* La playlist va después del contenido */
        position: static; /* Elimina el sticky en móviles */
        max-height: none; /* Elimina la restricción de altura */
    }
    .search-section {
        order: 1;
    }
}

.search-section {
    min-width: 0;
}

.search-form {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.search-input {
    width: 40%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    outline: none;
}

.search-input:focus {
    border-color: #ff0000;
}

.search-btn {
    padding: 12px 30px;
    font-size: 16px;
    background-color: #ff0000;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 10px;
}

.search-btn:hover {
    background-color: #cc0000;
}

.search-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: #606060;
}

.results-header {
    margin-bottom: 20px;
}

.results-count {
    color: #606060;
    font-size: 14px;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.video-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.video-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.video-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #000;
    overflow: hidden;
}

.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-info {
    padding: 12px;
}

.video-title {
    font-size: 14px;
    font-weight: 600;
    color: #030303;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-channel {
    font-size: 13px;
    color: #606060;
    margin-bottom: 10px;
}

.add-btn {
    width: 100%;
    padding: 8px;
    background-color: #065fd4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.add-btn:hover {
    background-color: #0047a3;
}

.add-btn.added {
    background-color: #00a152;
}

.add-btn.added:hover {
    background-color: #008c45;
}

/* PLAYLIST SIDEBAR */
.playlist-sidebar {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.playlist-title {
    font-size: 18px;
    font-weight: 700;
    color: #030303;
}

.playlist-count {
    background: #ff0000;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
}

.clear-btn {
    padding: 8px 16px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    margin-bottom: 15px;
}

.clear-btn:hover {
    background-color: #d32f2f;
}

.playlist-items {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.playlist-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
    transition: background 0.2s;
    cursor: pointer;
}

.playlist-item:hover {
    background: #f5f5f5;
}

.playlist-item.playing {
    background: #e3f2fd;
    border-left: 4px solid #065fd4;
}

.playlist-item img {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
}

.playlist-item-info {
    flex: 1;
    min-width: 0;
}

.playlist-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #030303;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.playlist-item-channel {
    font-size: 12px;
    color: #606060;
}

.remove-btn {
    padding: 4px 8px;
    background-color: #ff4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    align-self: center;
}

.remove-btn:hover {
    background-color: #cc0000;
}

.empty-playlist {
    text-align: center;
    padding: 40px 20px;
    color: #606060;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #606060;
}

/* MEJORAS ADICIONALES PARA MÓVILES */
@media (max-width: 768px) {
    .player-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .player-controls {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .control-btn {
        flex: 1;
        min-width: 100px;
    }
    
    .search-input {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .search-btn {
        width: 100%;
        margin-left: 0;
    }
    
    .video-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.5em;
    }
    
    .player-section {
        padding: 10px;
    }
}