/**
 * Estilos para el Editor de Audio
 * editar.php
 */

/* ==========================================
   IMPORTACIONES Y ESTILOS BASE
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    font-family: 'Inter', sans-serif;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0f0f17;
}

::-webkit-scrollbar-thumb {
    background: #252532;
    border-radius: 4px;
}

/* Scrollbar del SCROLL GLOBAL - más gruesa y visible */
.global-scroll-area::-webkit-scrollbar {
    height: 14px;
}

.global-scroll-area::-webkit-scrollbar-track {
    background: #1a1a24;
    border-radius: 7px;
}

.global-scroll-area::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #6366f1, #818cf8);
    border-radius: 7px;
    border: 2px solid #1a1a24;
}

.global-scroll-area::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #818cf8, #a5b4fc);
}

/* Playhead global que atraviesa todas las pistas */
#globalPlayhead {
    background: linear-gradient(to bottom, #ef4444, #dc2626);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6), 0 0 16px rgba(239, 68, 68, 0.3);
    transition: opacity 0.2s;
}

#globalPlayhead::before {
    content: '';
    position: absolute;
    top: 0;
    left: -2px;
    right: -2px;
    bottom: 0;
    background: rgba(239, 68, 68, 0.15);
    pointer-events: none;
}

/* Marcador de posición inicial - Estado establecido (verde) */
#startPositionMarker.start-set {
    background: linear-gradient(to bottom, #22c55e, #16a34a) !important;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.7), 0 0 20px rgba(34, 197, 94, 0.4) !important;
}

#startPositionMarker.start-set .marker-top,
#startPositionMarker.start-set .marker-bottom {
    border-color: #22c55e transparent transparent transparent !important;
}

/* Animación de pulso cuando se establece el punto de inicio */
@keyframes pulse-green {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
    }

    50% {
        box-shadow: 0 0 16px rgba(34, 197, 94, 0.9), 0 0 24px rgba(34, 197, 94, 0.5);
    }
}

#startPositionMarker.start-set {
    animation: pulse-green 1.5s ease-in-out infinite;
}

/* Selección de audio */
.clip-selection {
    background: rgba(99, 102, 241, 0.25);
    border-left: 2px solid #6366f1;
    border-right: 2px solid #6366f1;
}

/* Handles de redimensionamiento de selección */
.selection-handle-left,
.selection-handle-right {
    background: rgba(99, 102, 241, 0.4);
    z-index: 10;
}

.selection-handle-left:hover,
.selection-handle-right:hover {
    background: rgba(99, 102, 241, 0.8);
}

.selection-handle-left:active,
.selection-handle-right:active {
    background: #6366f1;
}

/* Indicador visual en los handles */
.selection-handle-left::after,
.selection-handle-right::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 16px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 1px;
}

/* Barra de seek / línea de tiempo inferior */
#seekBar {
    background: linear-gradient(to bottom, #0a0a12, #12121a);
}

#seekBarTimeline:hover {
    background: rgba(255, 255, 255, 0.03);
}

#seekBarMarker {
    box-shadow: 0 0 6px rgba(250, 204, 21, 0.5);
    transition: left 0.05s ease-out;
}

/* Marcador de posición de inicio en las pistas */
#startPositionMarker {
    background: linear-gradient(to bottom, #fbbf24, #f59e0b);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
    opacity: 0.8;
    transition: left 0.05s ease-out;
}

#startPositionMarker:hover {
    opacity: 1;
}

/* Sliders de rango */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #6366f1;
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #6366f1;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Botones de herramientas */
.tool-btn {
    transition: all 0.15s;
}

.tool-btn:hover {
    background: rgba(99, 102, 241, 0.2);
}

.tool-btn.active {
    background: rgba(99, 102, 241, 0.3);
    border-color: #6366f1;
}

/* Contenedor waveform */
.waveform-container {
    background: linear-gradient(180deg, #0f0f17 0%, #16161f 100%);
}

/* Marcadores de timeline */
.timeline-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    cursor: ew-resize;
}

.timeline-marker:hover {
    width: 4px;
}

/* Select dropdowns */
select option {
    background-color: #0f0f17;
    color: white;
}

/* ==========================================
   SISTEMA MULTIPISTA
   ========================================== */

/* Track rows */
.track-row {
    min-height: 140px;
    transition: background-color 0.15s;
}

.track-row:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.track-row.selected {
    background-color: rgba(99, 102, 241, 0.1);
}

/* Track controls */
.track-controls {
    min-width: 128px;
}

/* Botones Mute/Solo activos */
.btn-mute.active {
    background-color: #ef4444 !important;
    color: white !important;
}

.btn-solo.active {
    background-color: #eab308 !important;
    color: black !important;
}

/* Waveform del track */
.track-waveform {
    position: relative;
    cursor: crosshair;
}

.track-waveform.dragging {
    cursor: grabbing;
}

/* Handle para mover el offset del audio */
.track-offset-handle {
    z-index: 15;
}

/* Waveform canvas dentro del track */
.track-waveform .waveform-canvas {
    position: absolute;
    top: 0;
    left: 0;
    min-width: 100%;
}

/* Track con audio desplazado */
.track-waveform[data-offset] .waveform-canvas {
    transition: left 0.1s ease-out;
}

/* Indicador de posición del track */
.track-position-indicator {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

/* Colores por track */
.track-row[data-track="0"] .waveform-canvas {
    --track-color: #6366f1;
}

.track-row[data-track="1"] .waveform-canvas {
    --track-color: #22c55e;
}

.track-row[data-track="2"] .waveform-canvas {
    --track-color: #f59e0b;
}

.track-row[data-track="3"] .waveform-canvas {
    --track-color: #ec4899;
}

/* Slider de volumen pequeño */
.track-volume::-webkit-slider-thumb {
    width: 10px;
    height: 10px;
}

.track-volume::-moz-range-thumb {
    width: 10px;
    height: 10px;
}

/* ==========================================
   PANEL MULTIPISTA TIPO DAW
   ========================================== */

/* Container de tracks */
#tracksList {
    display: block;
    overflow-y: auto;
    min-height: 140px;
}

/* Filas de tracks con waveform */
.track-row {
    display: flex;
    height: 140px;
    /* background se define por nth-child más abajo */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.track-row:hover {
    filter: brightness(1.1);
}

/* (track-controls eliminado - ahora usa track-panel) */

/* Waveform del track */
.track-waveform {
    flex: 1;
    height: 140px;
    position: relative;
    background: #0a0a0f;
    overflow: hidden;
}

.track-canvas {
    display: block;
}

/* Slider de volumen en tracks */
.track-row .track-volume {
    height: 3px;
    background: #252532;
    border-radius: 2px;
    -webkit-appearance: none;
    appearance: none;
}

.track-row .track-volume::-webkit-slider-thumb {
    width: 8px;
    height: 8px;
    background: #6366f1;
    border-radius: 50%;
    cursor: pointer;
    -webkit-appearance: none;
}

.track-row .track-volume::-moz-range-thumb {
    width: 8px;
    height: 8px;
    background: #6366f1;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Input de offset */
.track-offset {
    -moz-appearance: textfield;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.track-offset::-webkit-outer-spin-button,
.track-offset::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.track-offset:focus {
    outline: none;
    border-color: #6366f1;
}

/* Pista seleccionada */
.track-row.selected {
    background: rgba(99, 102, 241, 0.15) !important;
}

/* Botones M y S */
.btn-mute,
.btn-solo {
    font-weight: 600;
    transition: all 0.15s;
}

/* Botón multipista activo */
#btnMultitrack.active {
    background: rgba(99, 102, 241, 0.3);
    border-color: #6366f1;
}

/* ==========================================
   SISTEMA DE CÁPSULAS DAW
   ========================================== */

/* Timeline container */
.track-timeline {
    position: relative;
    /* background se define por nth-child en la sección de colores */
    min-height: 140px;
}

/* Cápsula del waveform */
.waveform-capsule {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(26, 37, 64, 0.85);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: box-shadow 0.15s;
    z-index: 5;
}

.waveform-capsule:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Handles de redimensionamiento de clips */
.clip-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.waveform-capsule:hover .clip-resize-handle {
    opacity: 0.7;
}

.clip-resize-handle:hover {
    opacity: 1 !important;
}

.clip-resize-left {
    left: 0;
    border-radius: 4px 0 0 4px;
}

.clip-resize-right {
    right: 0;
    border-radius: 0 4px 4px 0;
}

/* Indicador visual en los handles de resize */
.clip-resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 24px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 1px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

/* Handle de arrastre */
.capsule-handle {
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    user-select: none;
    transition: background 0.15s;
}

.capsule-handle:hover {
    filter: brightness(1.2);
}

.capsule-handle:active {
    cursor: grabbing !important;
}

/* Waveform dentro de la cápsula */
.capsule-waveform {
    position: relative;
    height: calc(100% - 16px);
    overflow: visible;
}

/* Playhead de reproducción */
.track-playhead {
    z-index: 20 !important;
}

/* Marcador de posición de inicio para play individual del clip */
.clip-start-marker {
    z-index: 25;
    transition: left 0.1s ease-out, transform 0.15s ease-out;
    box-shadow: 0 0 6px rgba(34, 211, 238, 0.6);
}

.clip-start-marker::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -1px;
    right: -1px;
    background: rgba(34, 211, 238, 0.2);
    pointer-events: none;
}

/* Animación de pulso suave para el marcador cyan */
@keyframes pulse-cyan {

    0%,
    100% {
        box-shadow: 0 0 6px rgba(34, 211, 238, 0.5);
    }

    50% {
        box-shadow: 0 0 12px rgba(34, 211, 238, 0.8);
    }
}

.clip-start-marker:not(.hidden) {
    animation: pulse-cyan 2s ease-in-out infinite;
}

.capsule-waveform canvas {
    display: block;
    max-width: none;
}

/* Grid del timeline (fondo) */
.timeline-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* Cursor de pegado */
.paste-cursor {
    z-index: 30;
    animation: pulse-cursor 1s ease-in-out infinite;
}

@keyframes pulse-cursor {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Contenedor de clips */
.clips-container {
    position: relative;
    z-index: 5;
}

/* Clip seleccionado */
.waveform-capsule.selected {
    box-shadow: 0 0 0 2px #6366f1, 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* Zoom local slider */
.track-local-zoom {
    height: 3px;
    background: #252532;
    border-radius: 2px;
    -webkit-appearance: none;
    appearance: none;
}

.track-local-zoom::-webkit-slider-thumb {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    cursor: pointer;
    -webkit-appearance: none;
}

.track-local-zoom::-moz-range-thumb {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Timeline ruler */
#timelineRuler {
    display: block;
    height: 24px;
}

/* ==========================================
   ESTILOS MÓVIL EDITAR (max-width: 600px)
   ========================================== */
@media (max-width: 600px) {

    /* Body: usar dvh para evitar problemas con barra de direcciones */
    body {
        height: 100dvh;
        min-height: -webkit-fill-available;
    }

    /* Navegación inferior fija y visible en móvil */
    nav.h-14 {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        padding-bottom: env(safe-area-inset-bottom);
        display: flex;
    }

    /* Agregar padding al contenido para no tapar con la nav fija */
    main {
        padding-bottom: 60px;
    }

    /* ========================================
       HEADER - controlado por global_header.css
       ======================================== */

    /* Elementos específicos de editar.php */
    #fileName {
        max-width: 100px !important;
        font-size: 0.65rem !important;
    }

    /* Botones Undo/Redo más pequeños */
    #btnUndo,
    #btnRedo {
        padding: 0.35rem !important;
    }

    #btnUndo svg,
    #btnRedo svg {
        width: 1rem !important;
        height: 1rem !important;
    }

    /* Botón exportar compacto */
    #btnExport {
        padding: 0.35rem 0.5rem !important;
        font-size: 0.65rem !important;
    }

    #btnExport svg {
        width: 0.875rem !important;
        height: 0.875rem !important;
    }

    /* ========================================
       BARRA DE HERRAMIENTAS SCROLLABLE
       ======================================== */
    header>div:last-child {
        height: auto !important;
        min-height: 44px !important;
        padding: 0.25rem !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        flex-wrap: nowrap !important;
        gap: 0.25rem !important;
    }

    header>div:last-child::-webkit-scrollbar {
        display: none !important;
    }

    /* Grupos de herramientas compactos */
    header>div:last-child>div {
        flex-shrink: 0 !important;
        padding: 0 0.35rem !important;
        gap: 0.15rem !important;
    }

    /* Botones de herramientas más pequeños */
    .tool-btn {
        padding: 0.35rem !important;
    }

    .tool-btn svg {
        width: 1.1rem !important;
        height: 1.1rem !important;
    }

    /* Ocultar texto en botones */
    #btnOpen span,
    #btnMerge span,
    .tool-btn span {
        display: none !important;
    }

    /* Dropdown de abrir */
    #btnOpen {
        padding: 0.35rem !important;
        border-radius: 0.35rem 0 0 0.35rem !important;
    }

    #btnOpenDropdown {
        padding: 0.35rem !important;
    }

    /* Zoom slider más pequeño */
    #zoomSlider {
        width: 50px !important;
    }

    /* Dropdown categorías - FIXED en móvil para evitar problemas con scroll */
    #categoriesDropdown {
        position: fixed !important;
        top: 90px !important;
        left: 0.5rem !important;
        right: 0.5rem !important;
        width: auto !important;
        max-height: 60vh !important;
        margin-top: 0 !important;
    }

    /* ========================================
       CONTENIDO PRINCIPAL
       ======================================== */
    main {
        flex-direction: column !important;
    }

    /* Sidebar de canciones - overlay en móvil */
    #songsSidebar {
        position: fixed !important;
        top: 120px !important;
        /* Debajo del header global (56px) + toolbar (64px) */
        left: 0 !important;
        bottom: 0 !important;
        width: 85% !important;
        max-width: 280px !important;
        z-index: 100 !important;
        transform: translateX(-100%) !important;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5) !important;
    }

    #songsSidebar.active {
        transform: translateX(0) !important;
    }

    /* Asegurar que la cabecera del sidebar sea visible */
    #songsSidebar>div:first-child {
        display: flex !important;
    }

    /* Estado vacío compacto */
    #emptyState svg {
        width: 4rem !important;
        height: 4rem !important;
    }
}

/* ==========================================
   BARRA DE MENÚ ESTILO ADOBE AUDITION
   ========================================== */

/* Menú principal */
.menu-item {
    position: relative;
}

.menu-btn {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    transition: all 0.15s ease;
}

.menu-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* Dropdown del menú */
.menu-dropdown {
    animation: menuFadeIn 0.15s ease;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-dropdown::-webkit-scrollbar {
    width: 6px;
}

.menu-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Acciones del menú */
.menu-action {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    transition: background 0.1s ease;
}

.menu-action:hover {
    background: rgba(99, 102, 241, 0.3) !important;
    color: white;
}

.menu-action:active {
    background: rgba(99, 102, 241, 0.5) !important;
}

/* Separador de secciones en menú Efectos */
.menu-dropdown .text-white\/40 {
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Efecto hover más pronunciado en menú Efectos */
.menu-dropdown button[data-action^="fx"]:hover {
    background: rgba(139, 92, 246, 0.3) !important;
}

/* Indicador de atajo de teclado */
.menu-action .text-white\/30 {
    font-size: 10px;
    font-family: monospace;
}

/* Responsive - Ocultar menú en móvil muy pequeño */
@media (max-width: 480px) {
    .menu-item:nth-child(n+5) {
        display: none;
    }

    .menu-btn {
        padding: 4px 6px !important;
        font-size: 11px;
    }
}

/* ==========================================
   MOBILE STYLES - EDITOR AREA
   ========================================== */
@media (max-width: 600px) {

    /* ========================================
       ÁREA DEL EDITOR
       ======================================== */
    #editorArea {
        flex: 1 !important;
        min-height: 0 !important;
    }

    /* Regla de tiempo más pequeña */
    #timeRuler {
        height: 20px !important;
    }

    /* Waveform ocupa más espacio */
    #waveformContainer {
        flex: 1 !important;
        min-height: 120px !important;
    }

    /* ========================================
       PANEL INFERIOR - COMPACTO
       ======================================== */
    #editorArea>div:last-child {
        height: auto !important;
        min-height: 70px !important;
        flex-direction: column !important;
        padding: 0.5rem !important;
    }

    /* Info del archivo - horizontal compacto */
    #editorArea>div:last-child>div:first-child {
        width: 100% !important;
        padding: 0.25rem !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    #editorArea>div:last-child>div:first-child .grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.25rem !important;
    }

    #editorArea>div:last-child>div:first-child .grid>div {
        font-size: 0.6rem !important;
    }

    /* Tiempo y selección - centrado */
    #editorArea>div:last-child>div:nth-child(2) {
        padding: 0.5rem !important;
        gap: 1rem !important;
    }

    #currentTime {
        font-size: 1.25rem !important;
    }

    #editorArea>div:last-child>div:nth-child(2) .text-xs {
        font-size: 0.55rem !important;
    }

    #editorArea>div:last-child>div:nth-child(2) .text-sm {
        font-size: 0.7rem !important;
    }

    /* Volumen - oculto o muy compacto */
    #editorArea>div:last-child>div:last-child {
        display: none !important;
    }

    /* ========================================
       MODALES ADAPTADOS
       ======================================== */
    #volumeModal>div,
    #exportModal>div {
        margin: 0.5rem !important;
        max-width: calc(100vw - 1rem) !important;
        max-height: 85vh !important;
    }

    #volumeModal h3,
    #exportModal h3 {
        font-size: 1rem !important;
    }

    /* Notificaciones */
    #notifications {
        top: 45px !important;
        right: 0.5rem !important;
        left: 0.5rem !important;
    }
}

/* Overlay para sidebar en móvil */
#sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99;
}

@media (max-width: 600px) {
    #sidebarOverlay.active {
        display: block !important;
    }
}

/* ==========================================
   COLORES DE FILAS - 4 COLORES POR CLASE
   ========================================== */

/* Fila Azul índigo */
.track-row.track-color-1 {
    background: linear-gradient(90deg, #12202f 0%, #0d1822 100%);
}

.track-row.track-color-1 .track-timeline {
    background: #0a1520;
}

.track-row.track-color-1 .track-panel {
    background: linear-gradient(180deg, #12202f 0%, #0a0d12 100%);
    border-right: 2px solid #6366f1;
}

/* Fila Púrpura/Magenta */
.track-row.track-color-2 {
    background: linear-gradient(90deg, #201220 0%, #180d18 100%);
}

.track-row.track-color-2 .track-timeline {
    background: #1a0a18;
}

.track-row.track-color-2 .track-panel {
    background: linear-gradient(180deg, #201220 0%, #0d0a0d 100%);
    border-right: 2px solid #ec4899;
}

/* Fila Verde esmeralda */
.track-row.track-color-3 {
    background: linear-gradient(90deg, #0d201a 0%, #0a1812 100%);
}

.track-row.track-color-3 .track-timeline {
    background: #0a1810;
}

.track-row.track-color-3 .track-panel {
    background: linear-gradient(180deg, #0d201a 0%, #080d0a 100%);
    border-right: 2px solid #22c55e;
}

/* Fila Naranja/Ámbar */
.track-row.track-color-4 {
    background: linear-gradient(90deg, #201a0d 0%, #18120a 100%);
}

.track-row.track-color-4 .track-timeline {
    background: #1a1508;
}

.track-row.track-color-4 .track-panel {
    background: linear-gradient(180deg, #201a0d 0%, #0d0a08 100%);
    border-right: 2px solid #f59e0b;
}

/* Borde inferior visible entre filas */
.track-row {
    border-bottom: 2px solid rgba(255, 255, 255, 0.2) !important;
}

/* ==========================================
   ARRASTRAR CLIPS ENTRE FILAS
   ========================================== */

/* Fila destino cuando se arrastra un clip sobre ella */
.track-row.drop-target {
    background: rgba(99, 102, 241, 0.2) !important;
    box-shadow: inset 0 0 0 2px rgba(99, 102, 241, 0.7);
}

.track-row.drop-target .track-timeline {
    background: rgba(99, 102, 241, 0.15) !important;
}

/* ==========================================
   PANEL DE EFECTOS SECUNDARIO - PERILLAS
   ========================================== */

/* Panel unificado de controles - STICKY para que no se mueva con scroll horizontal */
.track-panel {
    width: 200px;
    flex-shrink: 0;
    padding: 4px 6px;
    /* background y border-right se definen por nth-child en la sección de colores */
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 3px;
    position: sticky;
    left: 0;
    z-index: 10;
}

/* Header: nombre + eliminar */
.track-header {
    display: flex;
    align-items: center;
    gap: 4px;
}

.track-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.track-name {
    flex: 1;
    font-size: 10px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-header .btn-remove {
    padding: 2px;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.15s;
}

.track-header .btn-remove:hover {
    color: #ef4444;
}

/* Transporte: play, pause, stop, M, S */
.track-transport {
    display: flex;
    align-items: center;
    gap: 2px;
}

.track-transport .btn-track-play,
.track-transport .btn-track-pause,
.track-transport .btn-track-stop {
    padding: 3px;
    background: #1a1a24;
    border-radius: 3px;
    transition: all 0.15s;
}

.track-transport .btn-track-play {
    color: #22c55e;
}

.track-transport .btn-track-play:hover {
    background: #22c55e;
    color: white;
}

.track-transport .btn-track-pause {
    color: #f59e0b;
}

.track-transport .btn-track-pause:hover {
    background: #f59e0b;
    color: white;
}

.track-transport .btn-track-stop {
    color: rgba(255, 255, 255, 0.5);
}

.track-transport .btn-track-stop:hover {
    background: #ef4444;
    color: white;
}

.track-transport .btn-mute,
.track-transport .btn-solo {
    padding: 2px 6px;
    font-size: 9px;
    font-weight: 700;
    background: #1a1a24;
    border-radius: 3px;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.15s;
}

.track-transport .btn-mute.active {
    background: #ef4444;
    color: white;
}

.track-transport .btn-solo.active {
    background: #eab308;
    color: black;
}

.track-duration {
    margin-left: auto;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.4);
    font-family: monospace;
}

/* Volumen */
.track-volume-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.track-volume-row .track-volume {
    flex: 1;
    height: 4px;
}

/* Contenedor de perillas - una sola fila con todos */
.knobs-row {
    display: flex;
    justify-content: space-between;
    gap: 2px;
    padding: 2px 0;
}

/* Contenedor de cada perilla */
.knob-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

/* Label de la perilla - debajo */
.knob-label {
    font-size: 6px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Perilla giratoria */
.knob {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(145deg, #252532, #1a1a24);
    border: 2px solid #333340;
    position: relative;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Perilla pequeña para efectos secundarios */
.knob.small {
    width: 20px;
    height: 20px;
}

.knob.small .knob-indicator {
    height: 7px;
    transform-origin: center 8px;
}

.knob:hover {
    border-color: #6366f1;
}

.knob:active {
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

/* Indicador de posición de la perilla */
.knob-indicator {
    position: absolute;
    width: 2px;
    height: 8px;
    background: #6366f1;
    border-radius: 1px;
    left: 50%;
    top: 2px;
    transform-origin: center 10px;
    transform: translateX(-50%);
    box-shadow: 0 0 3px rgba(99, 102, 241, 0.6);
}

/* Fila de grabación con barra de nivel */
.record-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 2px;
}

.record-row .record-time {
    font-size: 9px;
    font-family: monospace;
    color: rgba(255, 255, 255, 0.4);
    min-width: 32px;
    text-align: right;
}

.record-row .record-time.recording {
    color: #ef4444;
    font-weight: 600;
}

/* Anillo de LED alrededor de la perilla */
.knob-ring {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: #6366f1;
    opacity: 0;
    transition: opacity 0.2s;
}

.knob:hover .knob-ring,
.knob.active .knob-ring {
    opacity: 1;
}

/* Valor de la perilla */
.knob-value {
    font-size: 7px;
    color: rgba(255, 255, 255, 0.4);
    min-width: 20px;
    text-align: center;
}

/* Colores específicos por tipo de efecto */
/* EQ 3 bandas */
.knob.bass .knob-indicator {
    background: #ef4444;
    box-shadow: 0 0 3px rgba(239, 68, 68, 0.6);
}

.knob.bass:hover {
    border-color: #ef4444;
}

.knob.mid .knob-indicator {
    background: #22c55e;
    box-shadow: 0 0 3px rgba(34, 197, 94, 0.6);
}

.knob.mid:hover {
    border-color: #22c55e;
}

.knob.treble .knob-indicator {
    background: #3b82f6;
    box-shadow: 0 0 3px rgba(59, 130, 246, 0.6);
}

.knob.treble:hover {
    border-color: #3b82f6;
}

/* Efectos */
.knob.echo .knob-indicator {
    background: #8b5cf6;
    box-shadow: 0 0 3px rgba(139, 92, 246, 0.6);
}

.knob.echo:hover {
    border-color: #8b5cf6;
}

.knob.reverb .knob-indicator {
    background: #06b6d4;
    box-shadow: 0 0 3px rgba(6, 182, 212, 0.6);
}

.knob.reverb:hover {
    border-color: #06b6d4;
}

.knob.flanger .knob-indicator {
    background: #f59e0b;
    box-shadow: 0 0 3px rgba(245, 158, 11, 0.6);
}

.knob.flanger:hover {
    border-color: #f59e0b;
}

/* Botón de grabación - icono de micrófono */
.btn-track-record {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(145deg, #252532, #1a1a24);
    border: 2px solid #333340;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-track-record svg {
    width: 14px;
    height: 14px;
    fill: #22c55e;
    transition: all 0.2s;
}

.btn-track-record:hover {
    border-color: #22c55e;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.btn-track-record.recording {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.2);
    animation: pulse-record 1s ease-in-out infinite;
}

.btn-track-record.recording svg {
    fill: #ef4444;
    animation: pulse-dot 0.5s ease-in-out infinite;
}

/* Barra de nivel de audio horizontal */
.audio-level-bar {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.audio-level-bar .level-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e 0%, #22c55e 60%, #eab308 60%, #eab308 85%, #ef4444 85%, #ef4444 100%);
    border-radius: 4px;
    transition: width 0.05s ease-out;
}

.audio-level-bar .level-peak {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #fff;
    border-radius: 1px;
    transition: left 0.1s ease-out;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

/* Cuando está grabando, la barra pulsa en rojo */
.audio-level-bar.recording .level-fill {
    background: linear-gradient(90deg, #ef4444 0%, #ef4444 60%, #f59e0b 60%, #f59e0b 85%, #dc2626 85%, #dc2626 100%);
}

@keyframes pulse-record {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 15px rgba(239, 68, 68, 0.8);
    }
}

@keyframes pulse-dot {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Mini visualizador de grabación */
.record-visualizer {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 20px;
    padding: 2px;
}

.record-visualizer .bar {
    width: 3px;
    background: #22c55e;
    border-radius: 1px;
    transition: height 0.05s;
}

.record-visualizer.recording .bar {
    background: #ef4444;
    animation: visualizer-bar 0.3s ease-in-out infinite;
}

.record-visualizer.recording .bar:nth-child(1) {
    animation-delay: 0s;
}

.record-visualizer.recording .bar:nth-child(2) {
    animation-delay: 0.1s;
}

.record-visualizer.recording .bar:nth-child(3) {
    animation-delay: 0.05s;
}

.record-visualizer.recording .bar:nth-child(4) {
    animation-delay: 0.15s;
}

.record-visualizer.recording .bar:nth-child(5) {
    animation-delay: 0.08s;
}

.record-visualizer.recording .bar:nth-child(6) {
    animation-delay: 0.12s;
}

@keyframes visualizer-bar {

    0%,
    100% {
        height: 4px;
    }

    50% {
        height: 18px;
    }
}

/* Tiempo de grabación */
.record-time {
    font-size: 9px;
    font-family: monospace;
    color: rgba(255, 255, 255, 0.5);
    min-width: 40px;
    text-align: center;
}

.record-time.recording {
    color: #ef4444;
    font-weight: bold;
}

/* Pista GRABANDO - estilo dinámico cuando está grabando */
.track-row.recording-active {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.02) 30%, transparent 60%);
    animation: recording-pulse 2s ease-in-out infinite;
}

@keyframes recording-pulse {

    0%,
    100% {
        background-color: rgba(239, 68, 68, 0.02);
    }

    50% {
        background-color: rgba(239, 68, 68, 0.06);
    }
}

.track-row.recording-active .track-panel {
    background: linear-gradient(180deg, #1a0808 0%, #0d0d14 100%);
    border-right-color: rgba(239, 68, 68, 0.4);
}

/* (Estilos de monitor vertical eliminados - ahora usa audio-level-bar horizontal) */