/* ============================================================
   ADR-038 — Text Editor / Subtitles modal redesign
   Файл подключается ПОСЛЕ theme.css и layout.css.
   Все селекторы скоупятся на #textEditorModal, поэтому
   остальной UI не затрагивается.
   ============================================================ */

#textEditorModal {
    --te-field-bg: rgba(255, 255, 255, 0.45);
    --te-field-bg-hover: rgba(255, 255, 255, 0.62);
    --te-field-bg-focus: rgba(255, 255, 255, 0.74);
    --te-field-border: rgba(255, 255, 255, 0.72);
    --te-accent: #B794F6;
    --te-accent-soft: rgba(183, 148, 246, 0.22);
    --te-radius: 12px;
}

/* ---------- Контейнер ---------- */

#textEditorModal .text-editor-container {
    max-width: 960px !important;
    width: 94vw;
    max-height: 92vh;
    padding: 28px 32px 26px !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.52) 0%, rgba(255, 255, 255, 0.34) 100%);
    backdrop-filter: blur(44px) saturate(180%);
    -webkit-backdrop-filter: blur(44px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow:
        0 32px 80px -20px rgba(45, 52, 54, 0.28),
        inset 0 1px 1px rgba(255, 255, 255, 0.9);
}

/* Фикс: glass-card:hover поднимал и масштабировал модалку */
#textEditorModal .text-editor-container:hover {
    transform: none !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.52) 0%, rgba(255, 255, 255, 0.34) 100%);
    border-color: rgba(255, 255, 255, 0.65);
    box-shadow:
        0 32px 80px -20px rgba(45, 52, 54, 0.28),
        inset 0 1px 1px rgba(255, 255, 255, 0.9);
}

#textEditorModal .modal-close {
    top: 20px;
    right: 22px;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    font-size: 20px;
}

#textEditorModal .modal-close:hover {
    background: rgba(255, 255, 255, 0.85);
}

/* ---------- Табы ---------- */

#textEditorModal .text-editor-tabs-container {
    padding: 0 !important;
    margin-bottom: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.55);
}

#textEditorModal .text-editor-tabs {
    gap: 28px;
}

#textEditorModal .text-tab-btn {
    padding: 0 2px 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

#textEditorModal .text-tab-btn:hover {
    color: var(--text-secondary);
}

#textEditorModal .text-tab-btn.active {
    color: var(--text-primary);
}

#textEditorModal .text-tab-btn.active::after {
    bottom: -1px;
}

/* ---------- Сетка ---------- */

#textEditorModal .text-editor-layout {
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 34px;
    align-items: start;
    overflow: hidden;
}

@media (max-width: 880px) {
    #textEditorModal .text-editor-layout {
        grid-template-columns: 1fr;
    }
}

/* ---------- Превью ---------- */

#textEditorModal .text-editor-preview {
    background: rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 22px;
    padding: 16px;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

#textEditorModal .shorts-canvas {
    width: 284px;
    height: 505px;
    border-radius: 18px;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.45);
}

/* Safe-зоны субтитров (ADR-038) — видны только на вкладке Subtitles */
.te-safe-zone {
    position: absolute;
    left: 8%;
    right: 8%;
    height: 0;
    border-top: 1px dashed rgba(255, 255, 255, 0.32);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 3;
}

.te-safe-zone::after {
    position: absolute;
    right: 0;
    top: -15px;
    font-family: 'Outfit', sans-serif;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

.te-safe-zone[data-pos="top"] { top: 14%; }
.te-safe-zone[data-pos="top"]::after { content: 'top'; }
.te-safe-zone[data-pos="center"] { top: 50%; }
.te-safe-zone[data-pos="center"]::after { content: 'center'; }
.te-safe-zone[data-pos="bottom"] { top: 89%; }
.te-safe-zone[data-pos="bottom"]::after { content: 'bottom'; }

#textEditorModal.subs-mode .te-safe-zone {
    opacity: 1;
}

/* Живое превью субтитров */
#subsPreview {
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 11%;
    text-align: center;
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.35;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.75);
    pointer-events: none;
    display: none;
    z-index: 4;
}

#textEditorModal.subs-mode #subsPreview {
    display: block;
}

#textEditorModal.subs-mode .draggable-text {
    display: none;
}

#textEditorModal .draggable-text {
    border-radius: 8px;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
}

/* ---------- Панель инструментов ---------- */

#textEditorModal .text-tools-panel {
    width: auto;
    min-width: 0;
    gap: 18px;
    max-height: 74vh;
    overflow-y: auto;
    padding-right: 8px;
}

#textEditorModal .text-tools-panel::-webkit-scrollbar {
    width: 6px;
}

#textEditorModal .text-tools-panel::-webkit-scrollbar-track {
    background: transparent;
}

#textEditorModal .text-tools-panel::-webkit-scrollbar-thumb {
    background: rgba(183, 148, 246, 0.35);
    border-radius: 3px;
}

#textEditorModal .modal-title {
    font-size: 22px !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em !important;
    text-transform: none !important;
    margin: 0 !important;
    color: var(--text-primary) !important;
}

#textEditorModal .te-hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 5px 0 0;
}

#textEditorModal .tool-group {
    gap: 8px;
    min-width: 0;
}

#textEditorModal .tool-label {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 1 !important;
}

/* ---------- Поля ввода ---------- */

#textEditorModal .tool-select,
#textEditorModal .tool-textarea,
#textEditorModal .tool-num-input {
    width: 100%;
    max-width: none;
    height: 42px;
    padding: 0 14px;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--te-field-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--te-field-border);
    border-radius: var(--te-radius);
    outline: none;
    transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.7);
}

#textEditorModal .tool-textarea {
    height: auto;
    min-height: 170px;
    padding: 14px;
    line-height: 1.65;
    resize: vertical;
    cursor: text;
}

#textEditorModal #subsText {
    min-height: 160px;
    font-size: 14px;
}

#textEditorModal .tool-num-input {
    text-align: center;
    font-weight: 600;
}

#textEditorModal .tool-select::placeholder,
#textEditorModal .tool-textarea::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

#textEditorModal .tool-select:hover,
#textEditorModal .tool-textarea:hover,
#textEditorModal .tool-num-input:hover {
    background: var(--te-field-bg-hover);
}

#textEditorModal .tool-select:focus,
#textEditorModal .tool-textarea:focus,
#textEditorModal .tool-num-input:focus {
    background: var(--te-field-bg-focus);
    border-color: var(--te-accent);
    box-shadow:
        0 0 0 3px var(--te-accent-soft),
        inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

#textEditorModal select.tool-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23636E72' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

#textEditorModal .tool-textarea::-webkit-scrollbar {
    width: 6px;
}

#textEditorModal .tool-textarea::-webkit-scrollbar-thumb {
    background: rgba(183, 148, 246, 0.3);
    border-radius: 3px;
}

/* ---------- Колонки ---------- */

#textEditorModal .editor-two-cols {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px 20px;
}

#textEditorModal .editor-col {
    gap: 16px;
    min-width: 0;
}

/* ---------- Segmented control (Source: Text / Voiceover) ---------- */

#textEditorModal .subs-mode-switch {
    display: flex !important;
    gap: 4px !important;
    padding: 4px;
    border-radius: var(--te-radius);
    background: rgba(255, 255, 255, 0.32);
    border: 1px solid var(--te-field-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

#textEditorModal .subs-mode-btn {
    flex: 1;
    height: 34px;
    padding: 0 !important;
    border: none;
    border-radius: 9px !important;
    background: transparent;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    transition: all 0.22s ease;
}

#textEditorModal .subs-mode-btn:hover {
    color: var(--text-primary);
}

#textEditorModal .subs-mode-btn.active {
    background: #ffffff;
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(45, 52, 54, 0.12);
}

/* ---------- Слайдеры (тонкие, как в settings-panel) ---------- */

#textEditorModal .slider-container {
    position: relative;
    width: 100%;
    height: 20px;
    display: flex;
    align-items: center;
    padding: 0;
    margin: 0;
}

#textEditorModal .slider,
#textEditorModal .tool-slider {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 100% !important;
    height: 20px !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer;
    position: relative;
    z-index: 5;
}

#textEditorModal .slider-track-bg {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 3px;
    background: rgba(45, 52, 54, 0.08) !important;
    border-radius: 99px;
    clip-path: ellipse(100% 50% at 50% 50%);
    z-index: 1;
}

#textEditorModal .slider-progress {
    display: block !important;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 3px;
    background: var(--accent-gradient);
    border-radius: 99px;
    clip-path: ellipse(100% 50% at 50% 50%);
    pointer-events: none;
    overflow: hidden;
    z-index: 2;
}

#textEditorModal .slider-progress::after {
    content: "";
    position: absolute;
    top: 0;
    left: -150%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.4) 50%,
            rgba(255, 255, 255, 0) 100%);
    animation: sliderGlare 4s infinite linear;
}

#textEditorModal .slider::-webkit-slider-runnable-track,
#textEditorModal .tool-slider::-webkit-slider-runnable-track {
    height: 20px;
    background: transparent;
    border: none;
}

#textEditorModal .slider::-webkit-slider-thumb,
#textEditorModal .tool-slider::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 16px !important;
    height: 16px !important;
    margin-top: 0 !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 3px solid var(--te-accent) !important;
    box-shadow: 0 4px 10px rgba(183, 148, 246, 0.3) !important;
    filter: none !important;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

#textEditorModal .slider::-webkit-slider-thumb:hover,
#textEditorModal .tool-slider::-webkit-slider-thumb:hover {
    transform: scale(1.12) !important;
}

#textEditorModal .slider::-moz-range-track,
#textEditorModal .tool-slider::-moz-range-track {
    height: 3px;
    background: transparent;
    border: none;
}

#textEditorModal .slider::-moz-range-thumb,
#textEditorModal .tool-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--te-accent);
    box-shadow: 0 4px 10px rgba(183, 148, 246, 0.3);
    cursor: pointer;
}

/* Строка «слайдер + значение» */
#textEditorModal .slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

#textEditorModal .setting-value {
    flex-shrink: 0;
    min-width: 46px;
    text-align: center;
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #8B5CF6;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 6px;
    padding: 4px 8px;
}

/* ---------- Цветовые свотчи ---------- */

#textEditorModal .color-grid {
    gap: 12px;
}

#textEditorModal .color-swatch,
#textEditorModal .shadow-swatch {
    width: 28px;
    height: 28px;
    box-shadow:
        0 2px 8px rgba(45, 52, 54, 0.14),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

#textEditorModal .color-swatch:hover,
#textEditorModal .shadow-swatch:hover {
    transform: scale(1.12);
}

#textEditorModal .color-swatch.active,
#textEditorModal .shadow-swatch.active {
    border-color: var(--te-accent);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(183, 148, 246, 0.35);
}

/* Нативный color-picker → круглый свотч */
#textEditorModal .te-color-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

#textEditorModal input[type="color"].te-color-dot {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    padding: 0;
    border: 2px solid var(--te-field-border);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(45, 52, 54, 0.14);
    appearance: none;
    -webkit-appearance: none;
    overflow: hidden;
}

#textEditorModal input[type="color"].te-color-dot::-webkit-color-swatch-wrapper {
    padding: 0;
}

#textEditorModal input[type="color"].te-color-dot::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

#textEditorModal .te-color-hex {
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

/* ---------- Тайминги ---------- */

#textEditorModal .timing-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#textEditorModal .time-field {
    gap: 6px;
    min-width: 0;
}

#textEditorModal .time-field span {
    font-family: 'Outfit', sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    opacity: 1;
}

/* ---------- Voiceover file ---------- */

#textEditorModal #subsVoFile {
    height: auto;
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 500;
    border-style: dashed;
    border-color: rgba(183, 148, 246, 0.55);
    color: var(--text-secondary);
    cursor: pointer;
}

#textEditorModal #subsVoFile::file-selector-button {
    margin-right: 12px;
    padding: 7px 14px;
    border: none;
    border-radius: 8px;
    background: rgba(183, 148, 246, 0.15);
    color: #7C5BC7;
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease;
}

#textEditorModal #subsVoFile::file-selector-button:hover {
    background: rgba(183, 148, 246, 0.3);
}

#textEditorModal #subsVoStatus {
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0;
}

/* ---------- Список сохранённых слоёв ---------- */

#textEditorModal #layersListItems {
    max-height: 96px;
    gap: 6px !important;
}

/* ---------- Футер ---------- */

#textEditorModal .modal-footer-text-editor {
    margin-top: 4px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.55);
    gap: 10px;
}

#textEditorModal .modal-footer-text-editor .btn-delete-text,
#textEditorModal .modal-footer-text-editor .btn-modal-action {
    flex: 1;
    height: 44px !important;
    padding: 0 12px !important;
    border-radius: 22px !important;
    font-family: 'Outfit', sans-serif;
    font-size: 12px !important;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: all 0.25s ease;
}

#textEditorModal .btn-delete-text {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #ef4444;
}

#textEditorModal .btn-delete-text:hover {
    background: rgba(239, 68, 68, 0.16);
    color: #ef4444;
}

#textEditorModal .btn-save-text {
    background: rgba(255, 255, 255, 0.45) !important;
    border: 1px solid var(--te-field-border) !important;
    color: var(--text-primary) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: none !important;
}

#textEditorModal .btn-save-text:hover {
    background: rgba(255, 255, 255, 0.7) !important;
    transform: none;
    box-shadow: none !important;
}

#textEditorModal #btnApplyToShorts,
#textEditorModal #btnApplySubtitles {
    background: var(--accent-gradient);
    border: none;
    color: #ffffff;
    box-shadow: 0 8px 22px rgba(183, 148, 246, 0.35);
}

#textEditorModal #btnApplyToShorts:hover:not(:disabled),
#textEditorModal #btnApplySubtitles:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(183, 148, 246, 0.42);
}

#textEditorModal .modal-footer-text-editor button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}
