/* ============================================================
   Video Transcriber — Styles v2
   ============================================================
   Тёмная тема, карточки задач, модальное окно, toast-уведомления.
   Нет внешних зависимостей.
   ============================================================ */

/* === CSS-переменные === */
:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #252836;
    --text: #e4e6eb;
    --text-secondary: #8b8f9a;
    --accent: #4f8cff;
    --accent-hover: #3a7af0;
    --success: #34c759;
    --error: #ff453a;
    --warning: #ff9f0a;
    --border: #2c2f3a;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* === Reset === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 32px 20px;
}

/* === Заголовок === */
header {
    text-align: center;
    margin-bottom: 36px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-top h1 {
    flex: 1;
    text-align: center;
}

.user-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.user-header__name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ============================================================
   Drop-zone — всегда видна
   ============================================================ */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.1s;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.drop-zone:active {
    transform: scale(0.995);
}

.drop-zone__icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.drop-zone__content p {
    margin: 4px 0;
}

.drop-zone__hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.drop-zone__formats {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 12px;
}

/* ============================================================
   Карточки активных задач
   ============================================================ */
#active-tasks {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-card--processing {
    border-left: 3px solid var(--accent);
}

.task-card--done {
    border-left: 3px solid var(--success);
}

.task-card--error {
    border-left: 3px solid var(--error);
}

.task-card--uploading {
    border-left: 3px solid var(--warning);
}

/* Заголовок карточки */
.task-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.task-card__filename {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 70%;
}

/* Тело карточки */
.task-card__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-card__status-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.task-card__message {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.task-card__message--error {
    color: var(--error);
}

/* Spinner */
.task-card__spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

/* Иконки */
.task-card__done-icon {
    color: var(--success);
    font-size: 1.2rem;
    font-weight: 700;
}

.task-card__error-icon {
    color: var(--error);
    font-size: 1.2rem;
}

/* Прогресс-бар в карточке */
.task-card__progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
}

.task-card__progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.task-card--uploading .task-card__progress-fill {
    background: var(--warning);
}

.task-card__progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.task-card__progress-text {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.task-card__chunk-info {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 500;
}

/* Кнопки в карточке */
.task-card__actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

/* ============================================================
   Кнопки
   ============================================================ */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-small {
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-danger:hover {
    background: rgba(255, 69, 58, 0.12);
}

/* ============================================================
   Модальное окно
   ============================================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 820px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp 0.25s ease;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 0;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80%;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.modal-actions {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
}

.modal .result-preview {
    margin: 0 24px 24px;
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
}

/* ============================================================
   Результат (preview текст)
   ============================================================ */
.result-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
    font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text);
}

/* ============================================================
   История
   ============================================================ */
#history-section {
    margin-top: 40px;
}

#history-section h2 {
    font-size: 1.2rem;
    margin-bottom: 16px;
}

.history-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px;
    background: var(--bg-card);
    border-radius: var(--radius);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}

.history-table th,
.history-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.history-table th {
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-table td {
    font-size: 0.9rem;
}

.history-table tbody tr:hover {
    background: var(--bg-hover);
}

.history-table tbody tr:last-child td {
    border-bottom: none;
}

.td-filename {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-actions {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
}

/* Бейджи статусов */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-done {
    background: rgba(52, 199, 89, 0.15);
    color: var(--success);
}

.badge-error {
    background: rgba(255, 69, 58, 0.15);
    color: var(--error);
}

.badge-processing {
    background: rgba(79, 140, 255, 0.15);
    color: var(--accent);
}

.badge-queued {
    background: rgba(255, 159, 10, 0.15);
    color: var(--warning);
}

/* ============================================================
   Toast-уведомления
   ============================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 2000;
    max-width: 90%;
    text-align: center;
    pointer-events: none;
}

.toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast--info {
    background: var(--accent);
}

.toast--error {
    background: var(--error);
}

.toast--success {
    background: var(--success);
}

/* ============================================================
   Утилиты
   ============================================================ */
.hidden {
    display: none !important;
}

section {
    margin-bottom: 20px;
}

/* ============================================================
   Скроллбар
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================================
   Адаптивность
   ============================================================ */
@media (max-width: 600px) {
    .container {
        padding: 16px 12px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .drop-zone {
        padding: 28px 16px;
    }

    .task-card {
        padding: 12px 14px;
    }

    .task-card__filename {
        max-width: 60%;
        font-size: 0.85rem;
    }

    .task-card__actions {
        flex-wrap: wrap;
    }

    .modal-content {
        width: 96%;
        max-height: 90vh;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    .modal-actions {
        flex-wrap: wrap;
    }

    .history-table th:nth-child(2),
    .history-table td:nth-child(2) {
        display: none;
    }

    .td-filename {
        max-width: 120px;
    }
}
