/* VARIABLES Y BASE */
:root { 
    --primary: #00ff88; 
    --bg: #0f172a; 
    --card: #1e293b; 
    --text: #f1f5f9; 
    --text-dim: #94a3b8; 
    --danger: #ef4444; 
}

body { 
    background: var(--bg); 
    color: var(--text); 
    font-family: system-ui, sans-serif; 
    margin: 0; 
    padding: 15px; 
    padding-bottom: 140px; 
}

.hidden { display: none !important; }

/* --- CABECERA DE USUARIO --- */
#user-section header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    margin-bottom: 30px;
    gap: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

#user-section header img, 
#auth-section img {
    height: 55px; 
    width: auto;   
    flex-shrink: 0;    
    object-fit: contain;
    object-position: left center;    
    max-width: 140px; 
    min-width: 140px;    
    display: block;
    transform: scale(1.1); 
    transform-origin: left center;
    filter: drop-shadow(0 0 5px rgba(0, 255, 136, 0.2)); 
}

/* Solo para Firefox */
@-moz-document url-prefix() {
    #user-section header img {
        min-width: 120px; 
    }
}

#btn-logout {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

#btn-logout:hover {
    background: var(--danger);
    color: white;
}

/* --- COMUNIDAD Y SELECTORES --- */
.add-to-folder {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-left: 60px; 
    padding-right: 10px;
}

.add-to-folder select {
    flex: 1;
    min-width: 0; 
    height: 32px;
    font-size: 13px;
    padding: 0 8px;
    background-color: #000;
    color: #fff;
    border: 1px solid #334155;
    border-radius: 10px;
    cursor: pointer;
}

.add-to-folder .btn-plus {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.btn-plus {
    background: var(--primary);
    color: #0f172a;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}

/* --- ESTRUCTURA DE CARPETAS --- */
.folder-group {
    margin-top: 20px;
    margin-bottom: 25px;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    overflow: hidden;
    transition: transform 0.2s ease;
}

.folder-group.preprod-group {
    border-left: 4px solid #ffcc00 !important; 
    background: rgba(255, 204, 0, 0.03) !important;
}

.folder-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    cursor: pointer;
}

.cover-trigger {
    position: relative;
    cursor: pointer;
    width: 55px;
    height: 55px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #000;
}

.cover-trigger img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: 0.3s;
    font-size: 1.2rem;
}

.cover-trigger:hover .cover-overlay {
    opacity: 1 !important;
}

.folder-title {
    margin: 0;
    font-weight: bold;
    color: var(--primary);
    font-size: 0.95rem;
}

.folder-songs {
    display: none; 
    padding: 8px;
    flex-direction: column;
    gap: 4px;
    border-left: 2px solid rgba(0, 255, 136, 0.2);
    margin-left: 12px;
}

.folder-group.expanded .folder-songs {
    display: flex;
}

.expand-icon {
    transition: transform 0.3s ease;
    display: inline-block;
    margin-right: 5px;
    color: var(--primary);
}

.folder-group.expanded .expand-icon {
    transform: rotate(90deg);
}

/* --- ÁREA DE CARGA --- */
.drop-area {
    border: 2px dashed var(--text-dim);
    padding: 20px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.05);
    margin: 10px 0;
}

.drop-area.dragover {
    border-color: var(--primary);
    background: rgba(0, 255, 136, 0.1);
    transform: scale(1.02);
}

/* --- GRID Y RESPONSIVIDAD --- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 1200px; margin: 0 auto; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

/* --- LOGICA DE VISIBILIDAD WAVEFORM (NUEVO) --- */
@media (max-width: 500px) and (orientation: portrait) {
    #waveform {
        display: none !important;
    }
}

@media (orientation: landscape) or (min-width: 501px) {
    #waveform {
        display: block !important;
    }
}

.card { background: var(--card); padding: 15px; border-radius: 12px; }

input, select { background: #000; color: #fff; padding: 10px; border-radius: 10px; border: 1px solid #334155; width: 100%; margin-bottom: 8px; box-sizing: border-box; }
button { background: var(--primary); color: #000; font-weight: bold; border: none; border-radius: 10px; padding: 12px; cursor: pointer; transition: opacity 0.2s; }

/* --- TARJETAS DE TRACK --- */
.track-card { 
    background: rgba(0,0,0,0.2); 
    padding: 12px; 
    border-radius: 10px; 
    margin-bottom: 8px; 
    border: 2px solid transparent; 
    cursor: grab;
    transition: all 0.2s ease;
}
.track-card:hover { background: rgba(255, 255, 255, 0.05); }
.track-card:active { cursor: grabbing; }

.active-track { 
    border-left: 4px solid var(--primary) !important;
    background: rgba(0, 255, 136, 0.15) !important; 
    transform: translateX(5px);
    transition: all 0.3s ease;
}

.active-track .track-title {
    color: #fff;
    text-shadow: 0 0 8px var(--primary);
}

.track-content { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.track-title { display: block; font-weight: bold; color: var(--primary); font-size: 1rem; }
.track-meta { display: block; font-size: 0.8rem; color: var(--text-dim); }

.track-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 10px;
}

.btn-mini { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.05); color: #fff; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); }

/* --- REPRODUCTOR GLOBAL --- */
#global-player {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(15, 23, 42, 0.98); 
    border-top: 2px solid var(--primary);
    padding: 12px 20px;
    z-index: 10000;
    backdrop-filter: blur(15px);
}

.player-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

#waveform {
    flex: 2;
    height: 40px;
}

/* --- VOLUMEN Y CONTROLES --- */
.volume-container {
    display: flex;
    align-items: center; 
    gap: 10px;
    height: 32px;
}

#vol-icon {
    font-size: 16px;
    display: flex;
    align-items: center;
    color: var(--text);
    position: relative;
    top: -1.5px;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.2s;
    user-select: none;
}

#vol-icon:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

#vol-icon:active {
    transform: scale(0.9);
}

#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 90px;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    margin: 0;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary);
    margin-top: -6px;
}

/* --- MODAL DE RECORTE --- */
#cropper-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 20000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cropper-container-wrapper {
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    margin-bottom: 20px;
    overflow: hidden;
    border-radius: 12px;
}

.cropper-controls {
    display: flex;
    gap: 15px;
    width: 100%;
    max-width: 500px;
    justify-content: center;
}

.cropper-controls button {
    flex: 1;
    padding: 15px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-cancel-crop {
    background: #334155 !important;
    color: white !important;
}

@media (max-width: 400px) {
    .cropper-controls {
        flex-direction: column;
        gap: 10px;
    }
}

/* --- ARRASTRE (DRAG & DROP) --- */
.track-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    background: rgba(0, 255, 136, 0.2);
}

.folder-songs.drag-over {
    background: rgba(0, 255, 136, 0.05);
    outline: 2px dashed var(--primary);
}

/* --- BOTONES DE CONTROL --- */
.btn-control {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-control:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-control.active {
    background: var(--primary) !important;
    color: #0f172a !important;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
}

/* --- FEEDBACK VISUAL GLOBAL --- */
button, .btn-mini, .btn-danger, .btn-plus, .btn-control {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 2px;     
    overflow: hidden;
}

button:hover, .btn-mini:hover, .btn-danger:hover, .btn-plus:hover, .btn-control:hover {
    transform: translateY(-3px);
    filter: brightness(1.4);      
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.3), 0 6px 12px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

button:active, .btn-mini:active, .btn-danger:active, .btn-plus:active, .btn-control:active {
    transform: translateY(-1px);
    filter: brightness(0.9);
}

/* --- AJUSTES DE TARJETA --- */
.track-card img {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.badge-preprod {
    background: var(--primary);
    color: #0f172a;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
}

.badge-own {
    color: var(--primary);
    font-size: 0.8rem;
    border: 1px solid var(--primary);
    padding: 0 4px;
    border-radius: 3px;
    margin-right: 4px;
}

.track-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* --- NOTIFICACIONES --- */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { 
    background: var(--card); 
    color: var(--text); 
    padding: 12px 20px; 
    border-radius: 10px; 
    border-left: 4px solid var(--primary); 
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.stats-row {
    display: flex;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 4px;
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

/* --- SCROLLBARS --- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg);
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
    background: var(--card);
    border-radius: 10px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }