/* ==========================================================
   VoiceLink Download Manager — compact neon prototype
   Layout update only. Existing prototype JS IDs/data attrs stay intact.
   ========================================================== */

:root {
    --dm-panel: rgba(249, 251, 255, .985);
    --dm-panel-2: #f4f7fc;
    --dm-panel-3: #edf2f9;
    --dm-line: rgba(65, 83, 118, .14);
    --dm-line-strong: rgba(73, 94, 140, .25);
    --dm-text: #1d2638;
    --dm-muted: #7d899f;
    --dm-soft: #65728b;
    --dm-track: #dfe6f1;
    --dm-accent: #6656ff;
    --dm-accent-2: #1ed4ff;
    --dm-danger: #d85d70;
    --dm-shadow: 0 30px 90px rgba(14, 26, 52, .25);
}

.dashboard-app[data-theme="dark"] .vl-dm,
body:has(.dashboard-app[data-theme="dark"]) .vl-dm,
html[data-theme="dark"] .vl-dm,
body.dark .vl-dm,
.vl-dm[data-theme="dark"] {
    --dm-panel: rgba(15, 23, 38, .985);
    --dm-panel-2: #121c2e;
    --dm-panel-3: #182337;
    --dm-line: rgba(156, 176, 220, .12);
    --dm-line-strong: rgba(148, 171, 225, .22);
    --dm-text: #f4f7ff;
    --dm-muted: #8794ad;
    --dm-soft: #b4bfd4;
    --dm-track: #28344a;
    --dm-shadow: 0 36px 110px rgba(0, 0, 0, .58);
}

html.vl-dm-open { overflow: hidden; }
.vl-dm[hidden] { display: none !important; }
.vl-dm, .vl-dm *, .vl-dm *::before, .vl-dm *::after { box-sizing: border-box; }

.vl-dm {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 16px;
    color: var(--dm-text);
    font: 400 13px/1.35 inherit;
}

.vl-dm__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 8, 18, .68);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.vl-dm__panel {
    position: relative;
    z-index: 1;
    width: min(88vw, 1120px);
    max-height: calc(100dvh - 32px);
    overflow: auto;
    scrollbar-width: thin;
    padding: 16px 18px 17px;
    border: 1px solid var(--dm-line-strong);
    border-radius: 18px;
    background:
        radial-gradient(circle at 80% -10%, rgba(75, 92, 255, .08), transparent 35%),
        var(--dm-panel);
    box-shadow: var(--dm-shadow);
}

/* Header -------------------------------------------------- */
.vl-dm__header {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto 34px;
    align-items: center;
    gap: 11px;
}

.vl-dm__brand-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(99, 98, 255, .45);
    border-radius: 11px;
    color: #fff;
    font-size: 21px;
    background: linear-gradient(145deg, #7048ff, #24bfff);
    box-shadow: 0 0 20px rgba(66, 104, 255, .30);
}

.vl-dm__header-copy { min-width: 0; }
.vl-dm__header h2 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.025em; }
.vl-dm__header p { margin: 2px 0 0; color: var(--dm-muted); font-size: 10.8px; }

.vl-dm__header-cache {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 11px;
    border: 1px solid var(--dm-line);
    border-radius: 9px;
    background: color-mix(in srgb, var(--dm-panel-2) 88%, transparent);
}
.vl-dm__header-cache strong,
.vl-dm__header-cache small { display: block; white-space: nowrap; }
.vl-dm__header-cache strong { font-size: 10.3px; font-weight: 600; }
.vl-dm__header-cache small { margin-top: 1px; color: var(--dm-muted); font-size: 9px; }
.vl-dm__header-cache button {
    min-height: 26px;
    padding: 3px 8px;
    border: 1px solid color-mix(in srgb, var(--dm-danger) 40%, var(--dm-line));
    border-radius: 6px;
    background: transparent;
    color: var(--dm-danger);
    font: inherit;
    font-size: 9.5px;
    cursor: pointer;
}

.vl-dm__close {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--dm-line);
    border-radius: 9px;
    background: var(--dm-panel-2);
    color: var(--dm-soft);
    font: 300 21px/1 inherit;
    cursor: pointer;
}
.vl-dm__close:hover { border-color: var(--dm-line-strong); color: var(--dm-text); background: var(--dm-panel-3); }

/* Summary ------------------------------------------------- */
.vl-dm__summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 12px 0 14px;
    overflow: hidden;
    border: 1px solid var(--dm-line);
    border-radius: 11px;
    background: var(--dm-panel-2);
}
.vl-dm__summary-item {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 12px;
}
.vl-dm__summary-item + .vl-dm__summary-item { border-left: 1px solid var(--dm-line); }
.vl-dm__summary-icon { color: #6277ff; font-size: 20px; line-height: 1; }
.vl-dm__summary strong, .vl-dm__summary small { display: block; }
.vl-dm__summary strong { font-size: 15px; font-weight: 620; }
.vl-dm__summary small { margin-top: 1px; color: var(--dm-muted); font-size: 9.7px; }

/* Two-column body ---------------------------------------- */
.vl-dm__layout {
    display: grid;
    grid-template-columns: minmax(0, .96fr) minmax(0, 1.04fr);
    gap: 18px;
}
.vl-dm__column { min-width: 0; }
.vl-dm__column--progress {
    padding-left: 18px;
    border-left: 1px solid var(--dm-line);
}
.vl-dm__section + .vl-dm__section { margin-top: 12px; }
.vl-dm__section-title {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}
.vl-dm__section-title > span {
    width: 23px;
    height: 23px;
    flex: 0 0 23px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    font-size: 10px;
    font-weight: 650;
    background: linear-gradient(145deg, #7049ff, #4c83ff);
    box-shadow: 0 0 13px rgba(91, 79, 255, .25);
}
.vl-dm__section-title h3 { margin: 0; font-size: 13px; font-weight: 620; }
.vl-dm__section-title p { margin: 2px 0 0; color: var(--dm-muted); font-size: 9.7px; }
.vl-dm__card {
    overflow: hidden;
    border: 1px solid var(--dm-line);
    border-radius: 10px;
    background: var(--dm-panel-2);
}

/* Audio format ------------------------------------------- */
.vl-dm__format-list { padding: 2px 12px; }
.vl-dm__radio-row {
    min-height: 37px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 0;
    cursor: pointer;
}
.vl-dm__radio-row + .vl-dm__radio-row { border-top: 1px solid var(--dm-line); }
.vl-dm__radio-row > input[type="radio"] {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    margin: 0;
    accent-color: #6557ff;
}
.vl-dm__radio-row > span:not(.vl-dm__mp3-extra) { min-width: 0; }
.vl-dm__radio-row strong, .vl-dm__radio-row small { display: block; }
.vl-dm__radio-row strong { font-size: 11.2px; font-weight: 600; }
.vl-dm__radio-row small { margin-top: 1px; color: var(--dm-muted); font-size: 9.1px; }
.vl-dm__format-copy { flex: 1; }
.vl-dm__mp3-extra {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--dm-soft);
    font-size: 9.6px;
    white-space: nowrap;
}
.vl-dm__mp3-extra input {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #6557ff;
}

/* Metadata compact checkboxes ---------------------------- */
.vl-dm__options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 12px;
    padding: 5px 12px;
}
.vl-dm__check-row {
    min-height: 31px;
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    color: var(--dm-soft);
    font-size: 10.4px;
}
.vl-dm__check-row:nth-child(n + 3) { border-top: 1px solid var(--dm-line); }
.vl-dm__check-row input {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    margin: 0;
    accent-color: #6557ff;
}
.vl-dm__check-row:has(input:checked) { color: var(--dm-text); }

/* Naming -------------------------------------------------- */
.vl-dm__naming { padding: 8px 9px; }
.vl-dm__naming select {
    width: 100%;
    height: 31px;
    padding: 0 9px;
    border: 1px solid var(--dm-line);
    border-radius: 7px;
    background: var(--dm-panel);
    color: var(--dm-text);
    font: inherit;
    font-size: 10.5px;
    outline: none;
}
.vl-dm__naming select:focus { border-color: rgba(100, 89, 255, .5); box-shadow: 0 0 0 3px rgba(100, 89, 255, .08); }
.vl-dm__naming small { display: block; margin-top: 5px; color: var(--dm-muted); font-size: 8.9px; }

/* Progress ------------------------------------------------ */
.vl-dm__progress-section { height: 100%; display: flex; flex-direction: column; }
.vl-dm__progress-card { padding: 3px 13px; }
.vl-dm__progress-row { padding: 9px 0 10px; }
.vl-dm__progress-row + .vl-dm__progress-row { border-top: 1px solid var(--dm-line); }
.vl-dm__progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}
.vl-dm__progress-head > strong { font-size: 10.8px; font-weight: 580; }
.vl-dm__progress-head span { text-align: right; }
.vl-dm__progress-head b, .vl-dm__progress-head small { display: block; }
.vl-dm__progress-head b { font-size: 10.4px; font-weight: 650; }
.vl-dm__progress-head small { color: var(--dm-muted); font-size: 8.7px; }
.vl-dm__track {
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--dm-track);
}
.vl-dm__track i {
    display: block;
    width: var(--progress);
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #704cff, #1bdcff);
    box-shadow: 0 0 7px rgba(40, 194, 255, .7), 0 0 15px rgba(102, 74, 255, .28);
    transition: width .62s cubic-bezier(.22, .75, .2, 1);
}
.vl-dm__progress-row[data-stage="process"] .vl-dm__track i {
    background: linear-gradient(90deg, #7d4bff, #cf55ff);
    box-shadow: 0 0 8px rgba(183, 73, 255, .5);
}
.vl-dm__progress-row[data-stage="prepare"] .vl-dm__track i {
    background: linear-gradient(90deg, #00bd98, #42e3c4);
    box-shadow: 0 0 8px rgba(49, 220, 183, .48);
}
.vl-dm__progress-row[data-stage="zip"] .vl-dm__track i {
    background: linear-gradient(90deg, #348dff, #7e67ff);
    box-shadow: 0 0 8px rgba(82, 111, 255, .48);
}

/* Download sits directly under Progress ------------------ */
.vl-dm__download-zone {
    margin-top: 11px;
    min-height: 106px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 12px 14px;
    border: 1px solid var(--dm-line);
    border-radius: 11px;
    background:
        radial-gradient(circle at 50% 30%, rgba(88, 72, 255, .10), transparent 55%),
        var(--dm-panel-2);
}
.vl-dm__download {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--dm-text);
    font: inherit;
    cursor: pointer;
}
.vl-dm__download-ring {
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(115, 128, 255, .78);
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    background: linear-gradient(145deg, #6546ff, #27a8ff);
    box-shadow:
        0 0 0 5px rgba(93, 81, 255, .06),
        0 0 22px rgba(70, 99, 255, .48),
        inset 0 0 18px rgba(255, 255, 255, .08);
    transition: transform .2s ease, box-shadow .2s ease;
}
.vl-dm__download:hover .vl-dm__download-ring {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 0 0 6px rgba(93, 81, 255, .07), 0 0 28px rgba(70, 99, 255, .60);
}
.vl-dm__download-copy strong, .vl-dm__download-copy small { display: block; text-align: left; }
.vl-dm__download-copy strong { font-size: 12px; font-weight: 620; }
.vl-dm__download-copy small { margin-top: 2px; color: var(--dm-muted); font-size: 8.8px; }
.vl-dm__cancel {
    min-height: 30px;
    padding: 4px 12px;
    border: 1px solid var(--dm-line);
    border-radius: 7px;
    background: transparent;
    color: var(--dm-muted);
    font: inherit;
    font-size: 9.8px;
    cursor: pointer;
}
.vl-dm__cancel:hover { border-color: var(--dm-line-strong); color: var(--dm-text); }

/* Cache confirm ------------------------------------------ */
.vl-dm__confirm {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(2, 6, 13, .58);
    backdrop-filter: blur(5px);
}
.vl-dm__confirm[hidden] { display: none !important; }
.vl-dm__confirm-card {
    width: min(92vw, 390px);
    padding: 18px;
    border: 1px solid var(--dm-line-strong);
    border-radius: 12px;
    background: var(--dm-panel);
    box-shadow: var(--dm-shadow);
}
.vl-dm__confirm-card h3 { margin: 0; font-size: 15px; font-weight: 630; }
.vl-dm__confirm-card p { margin: 7px 0 15px; color: var(--dm-muted); font-size: 10.5px; }
.vl-dm__confirm-card > div { display: flex; justify-content: flex-end; gap: 7px; }
.vl-dm__confirm-card button {
    min-height: 30px;
    padding: 4px 11px;
    border: 1px solid var(--dm-line);
    border-radius: 7px;
    background: var(--dm-panel-2);
    color: var(--dm-text);
    font: inherit;
    font-size: 10px;
    cursor: pointer;
}

/* Responsive --------------------------------------------- */
@media (max-width: 900px) {
    .vl-dm__panel { width: min(95vw, 820px); max-height: calc(100dvh - 22px); }
    .vl-dm__header { grid-template-columns: 40px minmax(0, 1fr) 34px; }
    .vl-dm__header-cache { display: none; }
    .vl-dm__layout { grid-template-columns: 1fr; }
    .vl-dm__column--progress { padding-left: 0; border-left: 0; }
}

@media (max-width: 620px) {
    .vl-dm { padding: 7px; }
    .vl-dm__panel { width: calc(100vw - 14px); max-height: calc(100dvh - 14px); padding: 13px; border-radius: 14px; }
    .vl-dm__summary { grid-template-columns: 1fr; }
    .vl-dm__summary-item + .vl-dm__summary-item { border-left: 0; border-top: 1px solid var(--dm-line); }
    .vl-dm__options { grid-template-columns: 1fr; }
    .vl-dm__check-row:nth-child(n + 2) { border-top: 1px solid var(--dm-line); }
    .vl-dm__download-zone { flex-direction: column; gap: 9px; }
}

/* ==========================================================
   Download Manager lifecycle additions
   ========================================================== */

.vl-dm.is-minimized {
    display: none !important;
}

.vl-dm.is-job-active .vl-dm__close::before {
    content: '';
}

.vl-dm.is-job-active input,
.vl-dm.is-job-active select {
    pointer-events: none;
}

.vl-dm__progress-row.is-current .vl-dm__track {
    box-shadow: 0 0 18px rgba(73, 178, 255, .18);
}

.vl-dm__progress-row.is-complete .vl-dm__progress-head b {
    opacity: .92;
}

.vl-dm__mp3-extra.is-disabled {
    opacity: .36;
}

.vl-dm__cancel {
    border: 1px solid var(--vl-dm-border, rgba(120, 140, 175, .25));
    border-radius: 6px;
    background: transparent;
    color: inherit;
    min-height: 34px;
    padding: 6px 12px;
    cursor: pointer;
}

.vl-dm__confirm-card .is-danger {
    border-color: rgba(230, 82, 82, .48) !important;
    background: rgba(230, 82, 82, .10) !important;
}

.vl-dm-mini {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 2147482000;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 190px;
    min-height: 48px;
    padding: 7px 12px 7px 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--vl-dm-text, #eef5ff);
    background:
        linear-gradient(var(--vl-dm-panel, #101824), var(--vl-dm-panel, #101824)) padding-box,
        linear-gradient(110deg, #4ad8ff, #8b67ff, #44e5c3, #4ad8ff) border-box;
    background-size: 100% 100%, 250% 250%;
    box-shadow: 0 10px 32px rgba(0,0,0,.24), 0 0 22px rgba(83, 143, 255, .10);
    cursor: pointer;
    animation: vlDmMiniBorder 3s linear infinite, vlDmMiniHeartbeat 1.8s ease-in-out infinite;
}

.vl-dm-mini[hidden] { display: none !important; }

.vl-dm-mini__icon {
    width: 31px;
    height: 31px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(82, 148, 255, .11);
    box-shadow: inset 0 0 0 1px rgba(99, 169, 255, .22), 0 0 14px rgba(87, 150, 255, .10);
    font-size: 17px;
}

.vl-dm-mini__copy {
    display: grid;
    gap: 1px;
    text-align: left;
}

.vl-dm-mini__copy strong { font-size: 12px; font-weight: 700; }
.vl-dm-mini__copy small { font-size: 10px; opacity: .62; }

@keyframes vlDmMiniBorder {
    to { background-position: 0 0, 250% 0; }
}

@keyframes vlDmMiniHeartbeat {
    0%, 100% { transform: scale(1); }
    48% { transform: scale(1.018); }
    62% { transform: scale(1.006); }
}

@media (prefers-reduced-motion: reduce) {
    .vl-dm-mini { animation: none; }
}

@media (max-width: 700px) {
    .vl-dm-mini {
        right: 12px;
        bottom: 12px;
        min-width: 172px;
    }
}
