/* =====================================================
   MÓDULO PLAYLIST - ClickBar
   100% independiente del sistema base
   ===================================================== */

/* Botón flotante */
#cb-playlist-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 40;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #0f172a;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.4);
    display: none;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}
#cb-playlist-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(245, 158, 11, 0.6);
}
#cb-playlist-btn.cb-visible {
    display: flex;
}
#cb-playlist-btn .cb-pulse {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    background: #ef4444;
    border-radius: 50%;
    animation: cb-pulse-anim 1.5s infinite;
}
@keyframes cb-pulse-anim {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.6; }
}

/* Modal principal */
#cb-playlist-modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(6px);
    z-index: 55;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
#cb-playlist-modal.cb-open {
    display: flex;
}
#cb-playlist-panel {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    color: #e2e8f0;
}
#cb-playlist-panel header {
    padding: 16px 20px;
    border-bottom: 1px solid #1e293b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
#cb-playlist-panel header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #f59e0b;
}
#cb-playlist-panel header .cb-genre-tag {
    font-size: 10px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#cb-playlist-panel header button.cb-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 22px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}
#cb-playlist-panel header button.cb-close:hover {
    color: #fff;
}

/* Tabs */
.cb-tabs {
    display: flex;
    border-bottom: 1px solid #1e293b;
    background: #0b1220;
}
.cb-tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.cb-tab:hover { color: #cbd5e1; }
.cb-tab.cb-active {
    color: #f59e0b;
    border-bottom-color: #f59e0b;
}

/* Contenido scrollable */
.cb-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.cb-body::-webkit-scrollbar { width: 6px; }
.cb-body::-webkit-scrollbar-track { background: transparent; }
.cb-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

/* Tarjeta de canción */
.cb-song {
    background: #0b1220;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
    transition: all 0.2s;
}
.cb-song:hover {
    border-color: rgba(245, 158, 11, 0.4);
}
.cb-song.cb-playing {
    border-color: #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, #0b1220 100%);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
}
.cb-song img {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #1e293b;
}
.cb-song .cb-info {
    flex: 1;
    min-width: 0;
}
.cb-song .cb-info h5 {
    margin: 0 0 3px 0;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cb-song .cb-info p {
    margin: 0;
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cb-song .cb-position {
    font-size: 20px;
    font-weight: 800;
    color: #f59e0b;
    min-width: 30px;
    text-align: center;
}

/* Badges en canciones */
.cb-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.cb-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.cb-badge.cb-free { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.cb-badge.cb-impulse { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.cb-badge.cb-top { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.cb-badge.cb-own { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

/* Botones de acción en cada canción */
.cb-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.cb-btn-icon {
    background: #1e293b;
    border: none;
    color: #94a3b8;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.cb-btn-icon:hover { background: #334155; color: #fff; }
.cb-btn-icon.cb-liked {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}
.cb-btn-icon.cb-like-count {
    font-size: 12px;
    font-weight: 700;
}
.cb-btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Buscador */
.cb-search-box {
    position: relative;
    margin-bottom: 12px;
}
.cb-search-box input {
    width: 100%;
    background: #0b1220;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 12px 44px 12px 14px;
    color: #fff;
    font-size: 14px;
    outline: none;
}
.cb-search-box input:focus {
    border-color: #f59e0b;
}
.cb-search-box .cb-search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 16px;
}
.cb-search-status {
    text-align: center;
    font-size: 12px;
    color: #64748b;
    padding: 20px 10px;
}
.cb-search-status.cb-error { color: #f87171; }

/* Resultado de búsqueda */
.cb-result {
    background: #0b1220;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
    display: flex;
    gap: 10px;
    align-items: center;
}
.cb-result img {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.cb-result .cb-info { flex: 1; min-width: 0; }
.cb-result .cb-info h6 {
    margin: 0 0 2px 0;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cb-result .cb-info p {
    margin: 0;
    font-size: 10px;
    color: #64748b;
}

/* Botón principal */
.cb-btn-primary {
    background: #f59e0b;
    color: #0f172a;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.cb-btn-primary:hover { background: #fbbf24; }
.cb-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal de impulso */
#cb-impulse-modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.9);
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
#cb-impulse-modal.cb-open { display: flex; }
.cb-impulse-card {
    background: #0f172a;
    border: 2px solid #f59e0b;
    border-radius: 20px;
    max-width: 380px;
    width: 100%;
    padding: 24px;
    text-align: center;
}
.cb-impulse-card h4 {
    margin: 0 0 8px 0;
    color: #f59e0b;
    font-size: 18px;
    font-weight: 800;
}
.cb-impulse-card p {
    margin: 0 0 16px 0;
    color: #94a3b8;
    font-size: 13px;
}
.cb-impulse-card input {
    width: 100%;
    background: #0b1220;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 14px;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    outline: none;
    margin-bottom: 16px;
}
.cb-impulse-card input:focus { border-color: #f59e0b; }
.cb-impulse-btns {
    display: flex;
    gap: 8px;
}
.cb-impulse-btns button {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.cb-btn-skip {
    background: #1e293b;
    color: #cbd5e1;
}
.cb-btn-skip:hover { background: #334155; }

/* Empty state */
.cb-empty {
    text-align: center;
    padding: 40px 20px;
    color: #475569;
}
.cb-empty i {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
    color: #334155;
}
.cb-empty p {
    margin: 0;
    font-size: 13px;
}

/* Estación DJ */
#cb-dj-panel {
    display: none;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}
#cb-dj-panel.cb-visible { display: block; }
.cb-dj-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}
@media (min-width: 900px) {
    .cb-dj-grid { grid-template-columns: 1fr 1fr; }
}
.cb-dj-card {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 16px;
    padding: 20px;
}
.cb-dj-card h3 {
    margin: 0 0 16px 0;
    color: #f59e0b;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cb-dj-now {
    text-align: center;
    padding: 20px;
    background: #0b1220;
    border-radius: 12px;
    margin-bottom: 16px;
}
.cb-dj-now h4 {
    margin: 8px 0 4px 0;
    color: #fff;
    font-size: 18px;
}
.cb-dj-now p {
    margin: 0;
    color: #94a3b8;
    font-size: 13px;
}
.cb-dj-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 16px;
}
.cb-dj-actions button {
    padding: 14px 8px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.cb-dj-actions .cb-btn-complete { background: #10b981; color: #fff; }
.cb-dj-actions .cb-btn-skip2 { background: #f59e0b; color: #0f172a; }
.cb-dj-actions .cb-btn-reject { background: #ef4444; color: #fff; }

/* Panel de admin (config) */
#cb-playlist-config {
    display: none;
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
}
#cb-playlist-config.cb-visible { display: block; }

.cb-genre-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.cb-genre-item {
    background: #0b1220;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.cb-genre-item:hover { border-color: #f59e0b; }
.cb-genre-item input { accent-color: #f59e0b; }
.cb-genre-item label {
    font-size: 13px;
    color: #cbd5e1;
    cursor: pointer;
    flex: 1;
}

/* Aviso pequeño */
.cb-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 10px;
    padding: 12px;
    color: #fbbf24;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 480px) {
    #cb-playlist-btn {
        bottom: 16px;
        right: 16px;
        padding: 10px 16px;
        font-size: 13px;
    }
    #cb-playlist-panel {
        max-height: 95vh;
        border-radius: 16px;
    }
}