/* ============================================================
   MTVoice — dark-glass + neon-green TTS generator
   ============================================================ */

@property --mtv-rim-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.mtvoice-container {
    --mtv-accent: #50FA7B;
    --mtv-window-bg: rgba(15, 15, 15, 0.97);
    --mtv-panel-bg: rgba(20, 20, 20, 0.85);
    --mtv-field-bg: rgba(40, 40, 40, 0.6);
    --mtv-text: #E8E8E8;
    --mtv-text-dim: #8A8A8A;
    --mtv-border: rgba(255, 255, 255, 0.12);
    --mtv-btn-text: #06210F;
    --mtv-height: 620px;
    --mtv-width: 100%;
    --mtv-radius: 14px;
    --mtv-font: 'Inter', sans-serif;

    font-family: var(--mtv-font);
    color: var(--mtv-text);
    box-sizing: border-box;
    width: 100%;
    margin: 24px 0;
}

.mtvoice-container *,
.mtvoice-container *::before,
.mtvoice-container *::after {
    box-sizing: border-box;
}

/* The hidden attribute must win over the display rules below
   (otherwise the modal, spinner and upload box show on load). */
.mtvoice-container [hidden] {
    display: none !important;
}

/* ---- studio shell ---- */
.mtv-studio {
    display: flex;
    gap: 0;
    min-height: var(--mtv-height);
    max-width: var(--mtv-width);
    margin: 0 auto;
    background: var(--mtv-window-bg);
    border: 1.5px solid var(--mtv-border);
    border-radius: var(--mtv-radius);
    overflow: hidden;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

/* ---- scrollbars ---- */
.mtvoice-container .mtv-select-options,
.mtvoice-container .mtv-history-list {
    scrollbar-width: thin;
}

.mtv-scroll-dark .mtv-select-options,
.mtv-scroll-dark .mtv-history-list {
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.mtv-scroll-light .mtv-select-options,
.mtv-scroll-light .mtv-history-list {
    scrollbar-color: rgba(0, 0, 0, 0.35) transparent;
}

.mtvoice-container .mtv-select-options::-webkit-scrollbar,
.mtvoice-container .mtv-history-list::-webkit-scrollbar {
    width: 8px;
}

.mtvoice-container .mtv-select-options::-webkit-scrollbar-track,
.mtvoice-container .mtv-history-list::-webkit-scrollbar-track {
    background: transparent;
}

.mtv-scroll-dark .mtv-select-options::-webkit-scrollbar-thumb,
.mtv-scroll-dark .mtv-history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 4px;
}

.mtv-scroll-light .mtv-select-options::-webkit-scrollbar-thumb,
.mtv-scroll-light .mtv-history-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.32);
    border-radius: 4px;
}

.mtv-left {
    flex: 1.45;
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-right: 1px solid var(--mtv-border);
    min-width: 0;
}

.mtv-right {
    flex: 1;
    padding: 16px 18px 20px;
    min-width: 280px;
    background: var(--mtv-panel-bg);
}

/* ---- editor ---- */
.mtv-text {
    flex: 1;
    width: 100%;
    min-height: 220px;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: var(--mtv-text);
    font-family: var(--mtv-font);
    font-size: 16px;
    line-height: 1.6;
    padding: 4px;
}

.mtv-text::placeholder {
    color: var(--mtv-text-dim);
}

.mtv-left-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    gap: 12px;
}

.mtv-charcount {
    font-size: 12px;
    color: var(--mtv-text-dim);
}

/* ---- generate button (Shiny CTA) ---- */
.mtv-generate-btn {
    --mtv-rim-angle: 0deg;
    --mtv-rim-percent: 14%;
    --mtv-rim-offset: 60deg;
    --mtv-rim-bg: var(--mtv-accent);
    --mtv-rim-highlight: var(--mtv-accent);
    --mtv-rim-shine: #ffffff;

    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    /* Fixed size (like MTVision) so the button never reflows as the cycling
       words change. min-width comfortably fits the longest label. */
    height: 44px;
    min-width: 240px;
    padding: 0 25px;
    box-sizing: border-box;
    white-space: nowrap;
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--mtv-btn-text);
    font-family: var(--mtv-font);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    background: linear-gradient(var(--mtv-rim-bg), var(--mtv-rim-bg)) padding-box;
}

/* Shiny rim keeps cycling both when idle AND while generating (.is-generating),
   so the CTA animation continues during generation + waiting. */
.mtv-shiny .mtv-generate-btn:not(:disabled),
.mtv-shiny .mtv-generate-btn.is-generating {
    background:
        linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.4) 100%) padding-box,
        linear-gradient(var(--mtv-rim-bg), var(--mtv-rim-bg)) padding-box,
        conic-gradient(from calc(var(--mtv-rim-angle) - var(--mtv-rim-offset)),
            transparent 0%,
            var(--mtv-rim-highlight) var(--mtv-rim-percent),
            var(--mtv-rim-shine) calc(var(--mtv-rim-percent) * 2),
            var(--mtv-rim-highlight) calc(var(--mtv-rim-percent) * 3),
            transparent calc(var(--mtv-rim-percent) * 4)) border-box;
    animation: mtv-rim-rotate 3s linear infinite;
}

.mtv-glow .mtv-generate-btn:not(:disabled),
.mtv-glow .mtv-generate-btn.is-generating {
    box-shadow: 0 0 18px -2px var(--mtv-accent);
}

.mtv-generate-btn:hover:not(:disabled) {
    --mtv-rim-bg: #000000;
    color: #fff;
    background:
        linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.4) 100%) padding-box,
        linear-gradient(var(--mtv-rim-bg), var(--mtv-rim-bg)) padding-box,
        conic-gradient(from calc(var(--mtv-rim-angle) - var(--mtv-rim-offset)),
            transparent 0%,
            var(--mtv-rim-highlight) var(--mtv-rim-percent),
            var(--mtv-rim-shine) calc(var(--mtv-rim-percent) * 2),
            var(--mtv-rim-highlight) calc(var(--mtv-rim-percent) * 3),
            transparent calc(var(--mtv-rim-percent) * 4)) border-box;
}

/* Dead "disabled" look applies only when NOT generating — .is-generating keeps
   the animated CTA styling above (matches the MTVision behaviour). */
.mtv-generate-btn:disabled:not(.is-generating) {
    background: var(--mtv-field-bg);
    color: var(--mtv-text-dim);
    cursor: not-allowed;
    border-color: transparent;
    animation: none;
}

/* While generating: dark button + bright accent-colored status text (like
   MTVision), so the cycling words read clearly instead of dark-on-accent. */
.mtv-generate-btn.is-generating {
    --mtv-rim-bg: #000000;
    color: var(--mtv-accent);
    cursor: progress;
}

/* Keep the spinner visible on the dark generating background. */
.mtv-generate-btn.is-generating .mtv-spinner {
    border-color: rgba(255, 255, 255, 0.18);
    border-top-color: var(--mtv-accent);
}

.mtv-generate-btn.is-generating .mtv-gen-label {
    animation: mtv-status-pulse 2.8s ease-in-out infinite;
}

@keyframes mtv-status-pulse {
    0%, 100% { opacity: 0.8; }
    50%      { opacity: 1; }
}

@keyframes mtv-rim-rotate {
    to { --mtv-rim-angle: 360deg; }
}

.mtv-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.25);
    border-top-color: var(--mtv-btn-text);
    border-radius: 50%;
    animation: mtv-spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes mtv-spin { to { transform: rotate(360deg); } }

.mtv-status {
    margin-top: 12px;
    font-size: 13px;
    color: var(--mtv-text-dim);
}

.mtv-status.mtv-error { color: #ff6b6b; }

/* ---- player ---- */
.mtv-result { margin-top: 14px; }

.mtv-player {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--mtv-field-bg);
    border: 1.5px solid var(--mtv-border);
    border-radius: 10px;
    padding: 12px;
}

.mtv-play {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--mtv-accent);
    color: var(--mtv-btn-text);
    cursor: pointer;
    position: relative;
}

.mtv-play::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 54%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 7px 0 7px 11px;
    border-color: transparent transparent transparent var(--mtv-btn-text);
}

.mtv-play.mtv-playing::before {
    border: none;
    width: 9px;
    height: 11px;
    left: 50%;
    border-left: 3px solid var(--mtv-btn-text);
    border-right: 3px solid var(--mtv-btn-text);
}

.mtv-wave {
    flex: 1;
    height: 26px;
    border-radius: 4px;
    background: repeating-linear-gradient(90deg, var(--mtv-accent) 0 2px, transparent 2px 5px);
    opacity: 0.4;
    position: relative;
    overflow: hidden;
}

.mtv-wave-fill {
    position: absolute;
    inset: 0 100% 0 0;
    background: var(--mtv-accent);
    opacity: 0.5;
}

.mtv-time {
    font-size: 12px;
    color: var(--mtv-text-dim);
    min-width: 34px;
    text-align: right;
}

.mtv-download {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--mtv-text);
    text-decoration: none;
    border: 1px solid var(--mtv-border);
    border-radius: 6px;
    padding: 5px 9px;
    line-height: 0;
}

.mtv-download svg { width: 16px; height: 16px; display: block; }

.mtv-download:hover { border-color: var(--mtv-accent); color: var(--mtv-accent); }

/* ---- tabs ---- */
.mtv-tabs {
    display: flex;
    gap: 18px;
    border-bottom: 1px solid var(--mtv-border);
    margin-bottom: 16px;
}

.mtv-tab {
    background: none;
    border: none;
    color: var(--mtv-text-dim);
    font-family: var(--mtv-font);
    font-size: 14px;
    padding: 0 0 10px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.mtv-tab-active { color: var(--mtv-text); border-bottom-color: var(--mtv-accent); }

/* ---- fields ---- */
.mtv-field-group { margin-bottom: 18px; }

.mtv-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--mtv-text-dim);
    margin-bottom: 8px;
}

/* custom select */
.mtv-select { position: relative; outline: none; }

.mtv-select-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--mtv-field-bg);
    border: 1.5px solid var(--mtv-border);
    border-radius: 9px;
    padding: 9px 12px;
    cursor: pointer;
}

.mtv-select-trigger:hover { border-color: var(--mtv-accent); }

.mtv-select-avatar,
.mtv-option-avatar {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--mtv-accent), #1f7a3f);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #06210f;
    overflow: hidden;
}

/* Larger 64×64 thumbnails in the voice dropdown list. */
.mtv-option-avatar {
    width: 64px;
    height: 64px;
    font-size: 26px;
    position: relative;
}

.mtv-select-avatar img,
.mtv-option-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Small play/stop overlay on the thumbnail — previews the voice's clip. */
.mtv-preview-btn {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.mtv-option:hover .mtv-preview-btn,
.mtv-preview-btn.mtv-preview-playing { opacity: 1; }

/* Play triangle (idle). */
.mtv-preview-btn::before {
    content: "";
    width: 0;
    height: 0;
    margin-left: 3px;
    border-style: solid;
    border-width: 8px 0 8px 13px;
    border-color: transparent transparent transparent #fff;
}

/* Stop square (while previewing). */
.mtv-preview-btn.mtv-preview-playing::before {
    width: 12px;
    height: 12px;
    margin: 0;
    border: none;
    background: #fff;
}

.mtv-select-name { flex: 1; font-size: 13px; color: var(--mtv-text); }
.mtv-select-arrow { color: var(--mtv-text-dim); font-size: 12px; }

.mtv-select-options {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 320px;
    overflow-y: auto;
    background: var(--mtv-window-bg);
    border: 1.5px solid var(--mtv-border);
    border-radius: 10px;
    padding: 6px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.mtv-select.mtv-open .mtv-select-options { display: block; }

.mtv-option {
    display: flex;
    align-items: center; /* vertically center the name/description block against the 64px thumb */
    gap: 12px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.mtv-option:hover { background: var(--mtv-field-bg); }
.mtv-option-active { background: var(--mtv-field-bg); }

.mtv-option-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mtv-option-name { font-size: 13px; color: var(--mtv-text); font-weight: 500; }
.mtv-option-desc { font-size: 11px; color: var(--mtv-text-dim); }
.mtv-option-instruction { font-size: 10.5px; color: var(--mtv-accent); opacity: 0.85; }

/* upload */
.mtv-upload { margin-top: 10px; }

.mtv-upload-btn {
    width: 100%;
    background: transparent;
    border: 1.5px solid color-mix(in srgb, var(--mtv-accent) 45%, transparent);
    border-radius: 8px;
    padding: 9px;
    color: var(--mtv-accent);
    font-family: var(--mtv-font);
    font-size: 12px;
    cursor: pointer;
}

.mtv-upload-btn:hover { background: var(--mtv-field-bg); }
.mtv-upload-hint { color: var(--mtv-text-dim); }

.mtv-upload-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    background: var(--mtv-field-bg);
    border: 1.5px solid var(--mtv-border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
}

.mtv-upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mtv-upload-clear {
    background: none;
    border: none;
    color: var(--mtv-text-dim);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

/* sliders */
.mtv-slider-block { margin-bottom: 18px; }

.mtv-slider-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10.5px;
    color: var(--mtv-text-dim);
    margin-bottom: 7px;
}

.mtv-slider-val {
    width: 58px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--mtv-accent);
    background: var(--mtv-field-bg);
    border: 1px solid var(--mtv-border);
    border-radius: 6px;
    padding: 2px 4px;
    -moz-appearance: textfield;
}

.mtv-slider-val:focus {
    outline: none;
    border-color: var(--mtv-accent);
}

.mtv-slider-val::-webkit-outer-spin-button,
.mtv-slider-val::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.mtv-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
}

.mtv-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--mtv-accent);
    cursor: pointer;
    box-shadow: 0 0 8px color-mix(in srgb, var(--mtv-accent) 70%, transparent);
}

.mtv-slider::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border: none;
    border-radius: 50%;
    background: var(--mtv-accent);
    cursor: pointer;
}

/* credits */
.mtv-credits {
    display: flex;
    gap: 14px;
    margin-top: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--mtv-border);
}

.mtv-credits > div { display: flex; flex-direction: column; gap: 2px; }
.mtv-credit-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--mtv-text-dim); }
.mtv-credit-val { font-size: 14px; color: var(--mtv-accent); font-weight: 600; }

/* history */
.mtv-history-list { display: flex; flex-direction: column; gap: 8px; }

.mtv-history-item {
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--mtv-field-bg);
    border: 1px solid var(--mtv-border);
    border-radius: 9px;
    padding: 9px;
}

.mtv-history-text {
    flex: 1;
    font-size: 11.5px;
    color: var(--mtv-text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mtv-history-del,
.mtv-history-dl {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 4px;
    color: var(--mtv-text-dim);
    cursor: pointer;
    text-decoration: none;
}

.mtv-history-del svg,
.mtv-history-dl svg { width: 16px; height: 16px; display: block; }

.mtv-history-del:hover { color: #ff6b6b; }
.mtv-history-dl:hover { color: var(--mtv-accent); }

.mtv-history-more {
    width: 100%;
    margin-top: 12px;
    background: var(--mtv-field-bg);
    border: 1px solid var(--mtv-border);
    border-radius: 8px;
    padding: 9px;
    color: var(--mtv-text);
    cursor: pointer;
    font-family: var(--mtv-font);
}

.mtv-history-empty { color: var(--mtv-text-dim); font-size: 13px; padding: 20px 0; text-align: center; }

/* modal */
.mtv-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}

.mtv-modal-box {
    position: relative;
    background: var(--mtv-window-bg);
    border: 1.5px solid var(--mtv-accent);
    border-radius: 12px;
    padding: 36px;
    max-width: 420px;
    width: 90%;
    text-align: center;
}

.mtv-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--mtv-text-dim);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.mtv-modal-icon { font-size: 42px; margin-bottom: 14px; }
.mtv-modal-title { color: var(--mtv-accent); margin: 0 0 12px; font-size: 22px; }
.mtv-modal-msg { color: var(--mtv-text); margin-bottom: 22px; line-height: 1.5; }

.mtv-modal-continue {
    width: 100%;
    background: var(--mtv-accent);
    color: var(--mtv-btn-text);
    border: none;
    border-radius: 8px;
    padding: 11px;
    font-family: var(--mtv-font);
    font-weight: 600;
    cursor: pointer;
}

/* restricted */
.mtvoice-restricted {
    background: #0f0f0f;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    margin: 24px 0;
}

.mtv-restricted-card h3 { color: #50FA7B; text-transform: uppercase; letter-spacing: 2px; }
.mtv-restricted-card p { color: #ccc; }

.mtv-restricted-login {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 26px;
    background: #50FA7B;
    color: #06210f;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
}

/* responsive */
@media (max-width: 760px) {
    .mtv-studio { flex-direction: column; }
    .mtv-left { border-right: none; border-bottom: 1px solid var(--mtv-border); }
    .mtv-right { min-width: 0; }
}
