/* ===================================================================
   SLICER — Browser Audio Slicer App
   Stylesheet  ·  Dark Theme  ·  Inspired by ReCycle / Ableton
   =================================================================== */

/* ----- Custom Properties ------------------------------------------ */
:root {
    --bg-deepest: #0d0d1a;
    --bg-panel: #151528;
    --bg-surface: #1a1a2e;
    --bg-control: #2a2a4a;
    --border: #2a2a4a;
    --border-light: #3a3a5a;

    --accent-cyan: #00d4ff;
    --accent-orange: #ff6b35;

    --text-primary: #e0e0f0;
    --text-muted: #888899;
    --text-dim: #555566;

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    --font-ui:
        system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;

    --shadow-soft: 0 2px 12px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 8px rgba(0, 212, 255, 0.35);

    --transition-fast: 150ms ease;
    --transition-med: 250ms ease;
}

/* ----- Global Reset ----------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100vh;
    overflow: hidden;
    background: var(--bg-deepest);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ----- App Shell -------------------------------------------------- */
#app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    animation: fadeIn 400ms ease both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ----- Toolbar / Header ------------------------------------------ */
#toolbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 56px;
    min-height: 56px;
    padding: 0 20px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    gap: 12px;
    user-select: none;
    z-index: 20;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: auto;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#toolbar .app-title,
#toolbar h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 0.3px;
    white-space: nowrap;
    margin: 0;
}

#toolbar .app-title span,
#toolbar h1 span {
    color: var(--accent-orange);
}

#toolbar .app-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ----- Buttons ---------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    transition:
        background var(--transition-fast),
        color var(--transition-fast),
        filter var(--transition-fast),
        border-color var(--transition-fast),
        box-shadow var(--transition-fast);
}

.btn:focus-visible {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent-cyan);
    color: var(--bg-deepest);
    font-weight: 700;
}

.btn-primary:hover {
    filter: brightness(1.2);
}

.btn-primary:active {
    filter: brightness(0.95);
}

.btn-secondary {
    background: transparent;
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan);
}

.btn-secondary:hover {
    background: rgba(0, 212, 255, 0.1);
}

.btn-secondary:active {
    background: rgba(0, 212, 255, 0.18);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: none;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.btn-orange {
    background: var(--accent-orange);
    color: var(--bg-deepest);
    font-weight: 700;
}

.btn-orange:hover {
    filter: brightness(1.15);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ----- Workspace -------------------------------------------------- */
#workspace {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ----- Waveform Container ----------------------------------------- */
#waveform-container {
    position: relative;
    flex: 1;
    min-height: 200px;
    margin: 12px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

#waveform-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

/* ----- Drop Zone -------------------------------------------------- */
#drop-zone {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    border: 2px dashed #444466;
    border-radius: var(--radius-lg);
    background: rgba(13, 13, 26, 0.65);
    transition:
        border-color var(--transition-med),
        background var(--transition-med);
    cursor: pointer;
}

#drop-zone .drop-icon,
#drop-zone svg {
    width: 56px;
    height: 56px;
    opacity: 0.45;
    color: var(--text-muted);
    transition:
        opacity var(--transition-med),
        color var(--transition-med);
}

#drop-zone .drop-text,
#drop-zone p {
    font-size: 16px;
    color: var(--text-muted);
    text-align: center;
    transition: color var(--transition-med);
}

#drop-zone .drop-hint,
#drop-zone .drop-subtext {
    font-size: 12px;
    color: var(--text-dim);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.drop-icon {
    font-size: 48px;
    line-height: 1;
    opacity: 0.45;
    transition: opacity var(--transition-med);
}

.drag-over .drop-icon {
    opacity: 0.85;
}

/* Drag‑over active state */
#drop-zone.drag-over {
    border-color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.06);
}

#drop-zone.drag-over .drop-icon,
#drop-zone.drag-over svg {
    opacity: 0.85;
    color: var(--accent-cyan);
}

#drop-zone.drag-over .drop-text,
#drop-zone.drag-over p {
    color: var(--accent-cyan);
}

/* Hidden once file is loaded */
#drop-zone.hidden {
    display: none;
}

/* ----- Controls Bar ----------------------------------------------- */
#controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: auto;
    min-height: 80px;
    padding: 12px 20px;
    gap: 24px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    user-select: none;
}

/* ----- Transport -------------------------------------------------- */
#transport {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-shrink: 0;
}

#transport .btn,
#transport button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md);
    background: var(--bg-control);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    transition:
        background var(--transition-fast),
        color var(--transition-fast),
        box-shadow var(--transition-fast);
}

#transport .btn:hover,
#transport button:hover {
    background: #3a3a5e;
}

#transport .btn:active,
#transport button:active {
    background: #4a4a6e;
}

#transport .btn.active,
#transport button.active {
    background: var(--accent-cyan);
    color: var(--bg-deepest);
    box-shadow: var(--shadow-glow);
}

#transport .btn.stop.active,
#transport button.stop.active {
    background: var(--accent-orange);
    box-shadow: 0 0 8px rgba(255, 107, 53, 0.35);
}

/* ----- Sliders Area ----------------------------------------------- */
#sliders {
    display: flex;
    flex: 1;
    flex-direction: row;
    gap: 24px;
    min-width: 0;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 100px;
}

.slider-group label,
.slider-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    white-space: nowrap;
}

.slider-group .slider-value,
.slider-group output {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-cyan);
    min-width: 36px;
}

/* ----- Custom Range Input ----------------------------------------- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 20px;
    background: transparent;
    cursor: pointer;
}

input[type="range"]:focus {
    outline: none;
}

input[type="range"]:focus-visible {
    outline: none;
}

/* — Webkit Track — */
input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: var(--bg-control);
    border-radius: 2px;
    border: none;
}

/* — Webkit Thumb — */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    background: var(--accent-cyan);
    border: none;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 212, 255, 0.4);
    transition:
        box-shadow var(--transition-fast),
        transform var(--transition-fast);
}

input[type="range"]:hover::-webkit-slider-thumb {
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.6);
    transform: scale(1.12);
}

input[type="range"]:active::-webkit-slider-thumb {
    box-shadow: 0 0 14px rgba(0, 212, 255, 0.75);
    transform: scale(1.18);
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow:
        0 0 0 3px rgba(0, 212, 255, 0.3),
        0 0 10px rgba(0, 212, 255, 0.5);
}

/* — Firefox Track — */
input[type="range"]::-moz-range-track {
    height: 4px;
    background: var(--bg-control);
    border-radius: 2px;
    border: none;
}

/* — Firefox Thumb — */
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-cyan);
    border: none;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 212, 255, 0.4);
    transition:
        box-shadow var(--transition-fast),
        transform var(--transition-fast);
}

input[type="range"]:hover::-moz-range-thumb {
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.6);
    transform: scale(1.12);
}

input[type="range"]:active::-moz-range-thumb {
    box-shadow: 0 0 14px rgba(0, 212, 255, 0.75);
    transform: scale(1.18);
}

input[type="range"]:focus-visible::-moz-range-thumb {
    box-shadow:
        0 0 0 3px rgba(0, 212, 255, 0.3),
        0 0 10px rgba(0, 212, 255, 0.5);
}

/* Firefox progress fill */
input[type="range"]::-moz-range-progress {
    height: 4px;
    background: var(--accent-cyan);
    border-radius: 2px;
}

/* ----- Info Panel ------------------------------------------------- */
#info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
    text-align: right;
    white-space: nowrap;
}

#info span,
#info p,
#info div {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

#info .highlight,
#info strong {
    color: var(--accent-cyan);
    font-weight: 600;
}

#info .highlight-orange {
    color: var(--accent-orange);
    font-weight: 600;
}

/* ----- Scrollbar Styling ------------------------------------------ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-deepest);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-control);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Firefox thin scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-control) var(--bg-deepest);
}

/* ----- Utility / State -------------------------------------------- */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ----- Tooltip (optional UI) -------------------------------------- */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    background: #222240;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition:
        opacity var(--transition-fast),
        transform var(--transition-fast);
    z-index: 50;
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ----- Modal / About Dialog --------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin: 0;
}

.btn-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition:
        background var(--transition-fast),
        color var(--transition-fast);
}

.btn-modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--text-primary);
}

.modal-body p {
    margin: 0 0 12px;
}

.modal-body h3 {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--accent-orange);
    margin: 18px 0 8px;
}

.modal-body ol {
    margin: 0 0 12px 20px;
    padding: 0;
}

.modal-body ol li {
    margin-bottom: 6px;
}

.modal-body a {
    color: var(--accent-cyan);
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
    transition:
        color var(--transition-fast),
        border-color var(--transition-fast);
}

.modal-body a:hover {
    color: #fff;
    border-color: #fff;
}

.modal-body .hint {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 12px;
}

.modal-links {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.modal-links a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

/* ----- Responsive ------------------------------------------------- */
@media (max-width: 860px) {
    #controls {
        flex-wrap: wrap;
        height: auto;
        min-height: auto;
        padding: 12px 14px;
        gap: 14px;
    }

    #transport {
        order: 1;
    }

    #sliders {
        order: 3;
        flex-basis: 100%;
        flex-wrap: wrap;
        gap: 16px;
    }

    .slider-group {
        min-width: 120px;
        flex: 1 1 calc(33% - 16px);
    }

    #info {
        order: 2;
        align-items: flex-end;
    }
}

@media (max-width: 560px) {
    #toolbar {
        padding: 0 12px;
        height: 48px;
        min-height: 48px;
    }

    #toolbar .app-title,
    #toolbar h1 {
        font-size: 15px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    #waveform-container {
        margin: 8px;
        min-height: 160px;
    }

    #controls {
        padding: 10px 12px;
        gap: 10px;
    }

    #sliders {
        gap: 12px;
    }

    .slider-group {
        flex: 1 1 100%;
    }

    #info {
        flex-direction: row;
        gap: 10px;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
    }
}

/* ----- Selection (text highlight) --------------------------------- */
::selection {
    background: rgba(0, 212, 255, 0.3);
    color: #fff;
}

::-moz-selection {
    background: rgba(0, 212, 255, 0.3);
    color: #fff;
}
