/* Suno V6 reference attachments: compact "+" toggle + collapsible panel.
   The panel lives inside the main prompt column (block below the prompt),
   so opening it never shifts the two-column layout horizontally. */

/* Layout when the "+" is available (V6 Simple mode only):
   left to right: Simple/Custom switch, Instrumental toggle, "+" pill. */
.musiveo-generation-workspace .musiveo-prompt-input-wrap.musiveo-has-v6-toggle .musiveo-mode-switch-inline {
    right: auto;
    left: 16px;
    bottom: 10px;
}

.musiveo-generation-workspace .musiveo-prompt-input-wrap.musiveo-has-v6-toggle .musiveo-instrumental-toggle-inline {
    left: 172px;
}

/* Width guard: the prompt column keeps its designed floor on desktop but
   can never exceed (or shrink below) the available row width. */
.musiveo-prompt-layout .musiveo-prompt-column.musiveo-main-column {
    min-width: min(33rem, 100%);
}

/* Legacy upload box: always fill its column (it collapses when the column
   is squeezed by competing flex styles during init). */
.musiveo-generation-workspace .musiveo-upload-area {
    width: 100%;
    max-width: 350px;
    box-sizing: border-box;
}

/* Generate-mode row state, driven by a workspace class (rendered server-side
   and kept in sync on mode switches). !important is intentional: several
   modules set competing inline flex styles during staggered init, and the
   generate state must win while active. Inline styles take over again for
   cover/extend/etc. once the class switches away. */
.musiveo-generation-workspace.musiveo-genmode-generate .musiveo-prompt-column.musiveo-upload-column {
    display: none !important;
}

.musiveo-generation-workspace.musiveo-genmode-generate .musiveo-prompt-column.musiveo-main-column {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    min-width: min(33rem, 100%) !important;
}

/* Nudge the instrumental toggle placement inside the prompt box. */
.musiveo-generation-workspace .musiveo-prompt-input-wrap .musiveo-instrumental-toggle-inline {
    position: absolute;
    left: 16px;
    bottom: 12px;
    z-index: 2;
    bottom: 10px;
}

/* + pill lives on the RIGHT side of the prompt box (swapped with mode switch). */
.musiveo-v6-refs-toggle {
    position: absolute;
    bottom: 12px;
    left: auto;
    right: 12px;
    z-index: 3;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgb(34 34 34 / 55%);
    background: linear-gradient(135deg, #1b1b1b26 0%, #1c1c1d 100%);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    /* Playful shake once on page load to hint at the new feature. */
    animation: musiveoV6Shake 0.7s ease 1s 1;
}

.musiveo-v6-refs-toggle:hover {
    border-color: #383343;
    background: linear-gradient(135deg, #3a3641 0%, #37343e 100%);
    box-shadow: 0 0 0 3px rgb(0 0 0 / 25%), 0 2px 10px rgb(159 104 218 / 35%);
}

.musiveo-v6-refs-toggle:focus-visible {
    outline: 2px solid #a78bfa;
    outline-offset: 2px;
}

.musiveo-v6-refs-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}

.musiveo-v6-refs-icon img {
    display: block;
    width: 18px;
    height: 18px;
    object-fit: contain;
    /* The supplied SVGs use dark-grey fills; normalize both states to the
       button's white foreground without relying on blend-mode behavior. */
    filter: brightness(0) invert(1);
    opacity: 0.92;
}

.musiveo-v6-refs-icon-checked {
    display: none;
}

.musiveo-v6-refs-toggle.musiveo-has-items .musiveo-v6-refs-icon-empty {
    display: none;
}

.musiveo-v6-refs-toggle.musiveo-has-items .musiveo-v6-refs-icon-checked {
    display: inline-flex;
}

@keyframes musiveoV6Shake {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-14deg); }
    40% { transform: rotate(12deg); }
    60% { transform: rotate(-8deg); }
    80% { transform: rotate(6deg); }
}

@media (prefers-reduced-motion: reduce) {
    .musiveo-v6-refs-toggle {
        animation: none;
    }
}

/* Count badge. */
.musiveo-v6-refs-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: #8b5cf6;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* Hover tooltip. */
.musiveo-v6-refs-tip {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    width: max-content;
    max-width: 220px;
    padding: 6px 10px;
    border-radius: 8px;
    background: #1f1b2e;
    border: 1px solid #8b5cf6;
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    white-space: normal;
    text-align: center;
    pointer-events: none;
    z-index: 10;
}

.musiveo-v6-refs-toggle:hover .musiveo-v6-refs-tip {
    display: block;
}

/* Collapsible panel: full width of the main column, no horizontal shift. */
.musiveo-v6-references {
    width: 100%;
    max-width: 100%;
    margin-top: 10px;
    border: 1px solid #2b2b2b;
    border-radius: 12px;
    padding: 10px;
    background: #101010;
    box-sizing: border-box;
}

.musiveo-v6-refs-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

.musiveo-v6-ref-group {
    min-width: 0;
    border: 1px dashed #3a3a3a;
    border-radius: 10px;
    padding: 8px;
    background: #141414;
    box-sizing: border-box;
}

.musiveo-v6-ref-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.musiveo-v6-ref-icon {
    flex: 0 0 auto;
    color: #a78bfa;
}

.musiveo-v6-ref-limit {
    font-weight: 400;
    font-size: 11px;
    opacity: 0.65;
}

.musiveo-v6-ref-dropzone {
    display: block;
    border: 2px dashed #404040;
    border-radius: 8px;
    padding: 10px 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.musiveo-v6-ref-dropzone:hover,
.musiveo-v6-ref-dropzone.musiveo-v6-dragover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.08);
}

.musiveo-v6-ref-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 132px;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
}

.musiveo-v6-ref-item {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    background: #1c1c1c;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 4px 6px;
}

.musiveo-v6-ref-thumb {
    width: 64px;
    height: 64px;
    min-width: 64px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #3a3a3a;
}

.musiveo-v6-video-preview {
    width: 100%;
    height: auto;
    max-height: 240px;
    object-fit: contain;
    border-radius: 8px;
    background: #000;
    display: block;
}

.musiveo-v6-video-item {
    flex-direction: column;
    align-items: stretch;
}

.musiveo-v6-video-item-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin-top: 4px;
}

/* Upload progress: spinner + bar. */
.musiveo-v6-spinner {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-radius: 50%;
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-top-color: #8b5cf6;
    animation: musiveoV6Spin 0.8s linear infinite;
}

@keyframes musiveoV6Spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .musiveo-v6-spinner {
        animation: none;
    }
}

.musiveo-v6-progress-wrap {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.musiveo-v6-progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    font-size: 11px;
    opacity: 0.8;
}

.musiveo-v6-progress-bar {
    height: 5px;
    border-radius: 3px;
    background: #333;
    overflow: hidden;
}

.musiveo-v6-progress-bar i {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: linear-gradient(90deg, #8b5cf6, #a855f7);
    transition: width 0.2s ease;
}

.musiveo-v6-ref-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.musiveo-v6-ref-remove {
    flex: 0 0 auto;
    background: #3a3a3a;
    border: none;
    border-radius: 6px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    line-height: 1;
    color: #fff;
}

.musiveo-v6-ref-remove:hover {
    background: #dc2626;
}

.musiveo-v6-local-warn {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 600;
    color: #f59e0b;
    white-space: nowrap;
}

.musiveo-v6-pending {
    opacity: 0.7;
}

.musiveo-v6-refs-counter-line {
    margin: 6px 0 0;
    min-height: 18px;
}

/* Light theme. */
.musiveo-theme-light .musiveo-v6-references {
    background: #f6f6f8;
    border-color: #ddd;
}

.musiveo-theme-light .musiveo-v6-ref-group {
    background: #fff;
    border-color: #ccc;
}

.musiveo-theme-light .musiveo-v6-ref-item {
    background: #f0f0f3;
    border-color: #ddd;
}

.musiveo-theme-light .musiveo-v6-refs-tip {
    background: #fff;
    color: #222;
}

/* Responsive: stack on small screens, panel always full width. */
@media (max-width: 720px) {
    .musiveo-v6-refs-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .musiveo-v6-refs-tip {
        left: 0;
        transform: none;
    }
}

/* Mobile prompt box: lay the three controls out in one wrapping row
   (textarea full width first), neutralizing the desktop overlays and the
   negative-margin pull-up so nothing overlaps or escapes the box. */
@media (max-width: 768px) {
    .musiveo-prompt-input-wrap {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .musiveo-prompt-input-wrap textarea.musiveo-prompt-input {
        flex: 1 1 100%;
        order: 0;
    }

    .musiveo-generation-workspace .musiveo-prompt-input-wrap .musiveo-mode-switch-inline {
        order: 1;
        position: static;
        margin: 0;
        left: auto;
        right: auto;
        bottom: auto;
    }

    .musiveo-generation-workspace .musiveo-prompt-input-wrap .musiveo-instrumental-toggle-inline {
        order: 2;
        position: static;
        margin: 0;
        left: auto;
        bottom: auto;
    }

    .musiveo-generation-workspace .musiveo-prompt-input-wrap .musiveo-v6-refs-toggle {
        order: 3;
        position: static;
        margin: 0;
        left: auto;
        right: auto;
        bottom: auto;
    }

    .musiveo-generation-workspace .musiveo-prompt-input-wrap.musiveo-has-v6-toggle .musiveo-instrumental-toggle-inline,
    .musiveo-generation-workspace .musiveo-prompt-input-wrap.musiveo-has-v6-toggle .musiveo-mode-switch-inline {
        left: auto;
    }

    .musiveo-v6-refs-tip {
        bottom: auto;
        top: calc(100% + 8px);
        right: 0;
    }
}

/* Video list holds a single full preview: never trap it in the scroller. */
#musiveo-v6-video-list {
    max-height: none;
    overflow: visible;
}
