/* ==================================================================
   Mesa de Sonido — hoja de estilos
   Los colores y medidas se controlan desde las variables de :root.
   ================================================================== */

:root {
    --bg: #141414;
    --surface: rgba(18, 18, 18, 0.88);
    --surface-2: #262626;
    --surface-3: #333333;
    --border: #3d3d3d;
    --text: #e8e4df;
    --text-dim: #9d968d;
    --accent: #b32020;
    --accent-hover: #d83535;
    --playing: #2e8b57;
    --radius: 10px;
    --sidebar-width: 280px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.4;
}

#app {
    display: flex;
    min-height: 100vh;
}

h1,
h2 {
    color: var(--accent-hover);
    text-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
    margin: 0;
}

/* ------------------------------------------------------------ sidebar */

#sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: var(--sidebar-width);
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 16px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(4px);
}

#sidebar h1 {
    font-size: 1.35rem;
    text-align: center;
}

.hint {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-dim);
    text-align: center;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.chip {
    background-color: var(--surface-2);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.chip:hover {
    color: var(--text);
}

.chip.active {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.sound-list {
    list-style: none;
    margin: 0;
    padding: 0 4px 8px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
}

.sound-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    cursor: grab;
    user-select: none;
    transition: background-color 0.2s, border-color 0.2s;
}

.sound-item:hover {
    background-color: var(--accent);
    border-color: var(--accent);
}

.sound-item.previewing {
    border-color: var(--playing);
    box-shadow: 0 0 8px var(--playing);
}

.sound-item .badge {
    font-size: 0.68rem;
    color: var(--text-dim);
    background-color: rgba(0, 0, 0, 0.35);
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
}

.sound-item:hover .badge {
    color: #fff;
}

/* ------------------------------------------------------------ zona central */

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 16px 20px 0;
    min-width: 0;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
}

.board-section {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.board-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.board-header h2 {
    font-size: 1.15rem;
}

.controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.88rem;
}

.controls .check {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.controls input[type="range"] {
    width: 110px;
    accent-color: var(--accent);
}

.controls input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

/* ------------------------------------------------------------ tableros */

.board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    min-height: 96px;
    padding: 12px;
    background-color: rgba(0, 0, 0, 0.4);
    border: 2px dashed transparent;
    border-radius: var(--radius);
    transition: border-color 0.2s;
}

.board.drag-over {
    border-color: var(--accent-hover);
}

.board:empty {
    place-items: center;
}

.board:empty::after {
    content: 'Arrastra sonidos aquí desde la lista';
    color: var(--text-dim);
    font-size: 0.85rem;
    grid-column: 1 / -1;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tile.flash .tile-play {
    animation: flash 0.6s;
}

@keyframes flash {
    50% {
        background-color: var(--accent-hover);
    }
}

.tile-play {
    width: 100%;
    min-height: 56px;
    background-color: var(--surface-3);
    color: var(--text);
    border: 2px solid #555;
    border-radius: var(--radius);
    font-size: 0.9rem;
    padding: 6px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, border-color 0.2s;
}

.tile-play:hover {
    background-color: var(--accent);
}

.tile-play:active {
    transform: scale(0.96);
}

.tile.playing .tile-play {
    border-color: var(--playing);
    box-shadow: 0 0 10px var(--playing);
}

.tile-footer {
    display: flex;
    gap: 6px;
}

.tile-key {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 0.8rem;
    text-transform: uppercase;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: #1e1e1e;
    color: var(--text);
    caret-color: transparent;
}

.tile-key:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.tile-remove {
    background-color: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.tile-remove:hover {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ------------------------------------------------------------ controles genéricos */

.btn {
    border: none;
    border-radius: var(--radius);
    padding: 8px 16px;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn.danger {
    background-color: var(--accent);
    color: #fff;
}

.btn.danger:hover {
    background-color: var(--accent-hover);
}

.btn.ghost {
    background-color: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn.ghost:hover {
    border-color: var(--accent);
    color: var(--accent-hover);
}

input[type="search"],
select {
    padding: 8px 10px;
    font-size: 0.88rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: #1e1e1e;
    color: var(--text);
}

input[type="search"]:focus,
select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* ------------------------------------------------------------ pie y avisos */

footer {
    margin-top: auto;
    text-align: center;
    padding: 10px;
    color: var(--text-dim);
    font-size: 0.8rem;
}

footer p {
    margin: 0;
}

#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background-color: var(--accent);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 100;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ------------------------------------------------------------ scrollbar */

.sound-list::-webkit-scrollbar {
    width: 8px;
}

.sound-list::-webkit-scrollbar-thumb {
    background-color: var(--surface-3);
    border-radius: 4px;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 800px) {
    #app {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .sound-list {
        max-height: 40vh;
    }

    .toolbar {
        justify-content: center;
    }
}
