/* =========================
 *  ОБЩИЙ КОНТЕЙНЕР КАРТОЧКИ
 * ========================= */

/* Гарантируем, что всё внутри блока считает размеры по border-box,
   чтобы 100% ширины + padding не вылазили за родителя */
.nbx-tts-wrapper,
.nbx-tts-wrapper * ,
.nbx-tts-wrapper *::before,
.nbx-tts-wrapper *::after {
    box-sizing: border-box;
}

.nbx-tts-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;          /* никогда не шире родителя */
    margin: 24px 0;
    padding: 20px 22px 19px;
    border-radius: 24px;
    background: radial-gradient(circle at top left, #1d4ed8 0, #020617 40%, #020617 100%);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #f9fbff;
    overflow: hidden;
}

/* Компактный режим – чуть меньше карточка */

.nbx-tts-wrapper--compact {
    padding: 16px 18px 16px;
    border-radius: 20px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.75);
}

/* =========================
 *  ЗАГОЛОВОК / ПОДЗАГОЛОВОК
 * ========================= */

.nbx-tts-header {
    margin-bottom: 16px;
}

.nbx-tts-title {
    margin: 0 0 6px;
    font-size: 20px;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #ffffff;
}

.nbx-tts-subtitle {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: rgba(226, 232, 255, 0.78);
}

/* =========================
 *  ФОРМА
 * ========================= */

.nbx-tts-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.nbx-tts-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nbx-tts-label {
    font-size: 13px;
    font-weight: 500;
    color: rgba(226, 232, 255, 0.88);
}

/* Текстовое поле */

.nbx-tts-textarea {
    width: 100%;
    min-height: 96px;
    resize: vertical;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 255, 0.45);
    background: radial-gradient(circle at top, #0b1220 0, #020617 60%);
    color: #f9fbff;
    font-size: 14px;
    line-height: 1.5;
    padding: 11px 13px;
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.9);
}

.nbx-tts-textarea:focus {
    border-color: #38bdf8;
    box-shadow:
        0 0 0 1px rgba(56, 189, 248, 0.45),
        0 0 0 4px rgba(56, 189, 248, 0.2);
}

.nbx-tts-textarea::placeholder {
    color: rgba(148, 163, 255, 0.6);
}

/* Ряд селектов */

.nbx-tts-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.nbx-tts-field--language,
.nbx-tts-field--voice,
.nbx-tts-field--tone {
    flex: 1 1 180px;
}

/* Селекты */

.nbx-tts-select {
    width: 100%;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 255, 0.45);
    background: linear-gradient(135deg, #020617 0, #020617 55%, #020617 100%);
    color: #e5e7ff;
    font-size: 13px;
    padding: 7px 12px;
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.8);
}

/* Цвет фона и текста внутри выпадающего списка, чтобы он был читаем на любом фоне */
.nbx-tts-select option {
    background-color: #020617;
    color: #f9fbff;
}

/* Подсказка */

.nbx-tts-audio-help {
    font-size: 12px;
    color: rgba(199, 210, 254, 0.8);
}

/* =========================
 *  КНОПКА И СТАТУС
 * ========================= */

.nbx-tts-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 2px;
}

.nbx-tts-submit {
    border: none;
    background: linear-gradient(90deg, #22c55e 0%, #4ade80 50%, #22c55e 100%);
    color: #022c22;
    border-radius: 999px;
    padding: 9px 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow:
        0 12px 28px rgba(16, 185, 129, 0.45),
        0 0 0 1px rgba(5, 150, 105, 0.9);
    transition:
        transform 0.08s ease-out,
        box-shadow 0.12s ease-out,
        filter 0.12s ease-out;
}

.nbx-tts-submit:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow:
        0 18px 40px rgba(16, 185, 129, 0.6),
        0 0 0 1px rgba(5, 150, 105, 0.95);
}

.nbx-tts-submit:active {
    transform: translateY(0);
    box-shadow:
        0 8px 18px rgba(16, 185, 129, 0.5),
        0 0 0 1px rgba(5, 150, 105, 0.9);
}

.nbx-tts-submit.is-loading {
    opacity: 0.7;
    cursor: default;
}

.nbx-tts-status {
    font-size: 12px;
    color: rgba(226, 232, 255, 0.8);
}

/* =========================
 *  РЕЗУЛЬТАТ
 * ========================= */

.nbx-tts-result {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nbx-tts-result-title {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: rgba(129, 140, 248, 0.95);
}

/* =========================
 *  КАСТОМНЫЙ АУДИОПЛЕЕР
 * ========================= */

.nbx-tts-player {
    display: flex;
    align-items: center;
    gap: 10px;
    background: radial-gradient(circle at top, #020617 0, #020617 60%, #020617 100%);
    border-radius: 16px;
    padding: 10px 14px;
    border: 1px solid rgba(148, 163, 255, 0.25);
}

.nbx-tts-btn-play,
.nbx-tts-btn-download {
    border: none;
    background: radial-gradient(circle at 20% 0, #22c55e 0, #16a34a 42%, #16a34a 100%);
    color: #01210f;
    border-radius: 999px;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 18px rgba(34, 197, 94, 0.5);
    transition:
        transform 0.08s ease-out,
        box-shadow 0.12s ease-out,
        filter 0.12s ease-out;
}

.nbx-tts-btn-play:hover,
.nbx-tts-btn-download:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow: 0 12px 28px rgba(34, 197, 94, 0.65);
}

.nbx-tts-btn-play.is-playing {
    background: radial-gradient(circle at 20% 0, #f9fafb 0, #e5e7eb 50%, #d1d5db 100%);
    color: #020617;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.6);
}

.nbx-tts-progress {
    flex: 1;
    height: 4px;
    border-radius: 999px;
    background: rgba(30, 64, 175, 0.5);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.nbx-tts-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, #22c55e 0%, #4ade80 100%);
}

.nbx-tts-time {
    font-size: 12px;
    color: rgba(209, 213, 255, 0.9);
    white-space: nowrap;
}

.nbx-tts-time-sep {
    opacity: 0.6;
    margin: 0 2px;
}

audio.nbx-tts-audio {
    display: none;
}

/* =========================
 *  СООБЩЕНИЯ
 * ========================= */

.nbx-tts-message {
    font-size: 12px;
    margin-top: 4px;
}

.nbx-tts-message--error {
    color: #f97373;
}

.nbx-tts-message--success {
    color: #bbf7d0;
}

/* =========================
 *  КОМПАКТНЫЙ РЕЖИМ
 * ========================= */

.nbx-tts-wrapper--compact .nbx-tts-title,
.nbx-tts-wrapper--compact .nbx-tts-subtitle {
    display: none;
}

.nbx-tts-wrapper--compact .nbx-tts-form {
    gap: 10px;
}

.nbx-tts-wrapper--compact .nbx-tts-textarea {
    min-height: 80px;
}

.nbx-tts-wrapper--compact .nbx-tts-row {
    gap: 8px;
}

.nbx-tts-wrapper--compact .nbx-tts-player {
    padding: 8px 10px;
    border-radius: 14px;
}

.nbx-tts-wrapper--compact .nbx-tts-result-title {
    display: none;
}

/* =========================
 *  АДАПТИВНОСТЬ
 * ========================= */

@media (max-width: 768px) {
    .nbx-tts-wrapper {
        margin: 20px 0;
        padding: 16px 15px 14px;
        border-radius: 22px;
    }

    .nbx-tts-row {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .nbx-tts-wrapper {
        padding: 14px 13px 12px;
        border-radius: 20px;
    }

    .nbx-tts-player {
        padding: 8px 10px;
        gap: 8px;
    }

    .nbx-tts-submit {
        width: 100%;
        justify-content: center;
    }
}
