/* === CSS-переменные: светлая и тёмная тема === */
:root {
    --bg: #f5f5f7;
    --bg-card: #ffffff;
    --bg-input: #f0f0f3;
    --bg-hover: #e8e8ec;
    --text: #1a1a2e;
    --text-secondary: #6b6b80;
    --accent: #4361ee;
    --accent-hover: #3a56d4;
    --accent-light: #eef1ff;
    --danger: #e63946;
    --danger-hover: #d32f3f;
    --success: #2ec4b6;
    --border: #e0e0e6;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --radius: 12px;
    --radius-sm: 8px;
    --header-h: 56px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #252540;
    --bg-hover: #2a2a48;
    --text: #e8e8f0;
    --text-secondary: #8888a0;
    --accent: #5a7cff;
    --accent-hover: #7090ff;
    --accent-light: #1e2248;
    --danger: #ff4d5a;
    --danger-hover: #ff6b75;
    --success: #3dd6c8;
    --border: #2a2a48;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* === Сброс === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
}

/* === Хедер === */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    transition: background var(--transition);
}

.header.hidden { display: none; }

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 18px;
    user-select: none;
}

.logo-icon { font-size: 24px; }

.nav {
    display: flex;
    gap: 4px;
    margin-left: 16px;
}

.nav-mobile {
    display: none;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-link:hover, .nav-link.active {
    color: var(--accent);
    background: var(--accent-light);
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-version {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.8;
}

.user-email {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    line-height: 1;
}

.btn-icon:hover {
    color: var(--text);
    background: var(--bg-hover);
}

/* === Контент === */
.content {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
    padding-top: calc(var(--header-h) + 24px);
    min-height: 100dvh;
}

.content.no-header {
    padding-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Карточки === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: background var(--transition), border var(--transition);
}

/* === Формы === */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 15px;
    transition: border var(--transition), background var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    background: var(--bg-card);
}

.form-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* === Кнопки === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.2;
}

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

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

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

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

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

/* === Вкладки === */
.tabs {
    display: flex;
    gap: 0;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition);
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* === Запись с микрофона === */
.recorder-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px 16px;
}

.rec-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    position: relative;
}

.rec-btn::after {
    content: '';
    width: 28px;
    height: 28px;
    background: var(--danger);
    border-radius: 50%;
    transition: all var(--transition);
}

.rec-btn.recording {
    border-color: var(--danger);
    animation: pulse 1.5s infinite;
}

.rec-btn.recording::after {
    width: 22px;
    height: 22px;
    border-radius: 4px;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(230,57,70,0.3); }
    50% { box-shadow: 0 0 0 12px rgba(230,57,70,0); }
}

.rec-timer {
    font-size: 24px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.rec-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

/* === Загрузка файлов (drag-n-drop) === */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.drop-zone-icon {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
}

.drop-zone-text {
    font-size: 15px;
    font-weight: 500;
}

.drop-zone-hint {
    font-size: 12px;
    margin-top: 6px;
    opacity: 0.7;
}

.file-selected {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-weight: 500;
}

.upload-progress {
    margin-top: 12px;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    transition: width 0.15s ease;
}

/* === URL-ввод === */
.url-input-group {
    display: flex;
    gap: 8px;
}

.url-input-group .form-input {
    flex: 1;
}

/* === Прогресс/лоадер === */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loader-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* === Результат транскрипции === */
.result-area {
    margin-top: 20px;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.result-title {
    font-size: 16px;
    font-weight: 700;
}

.result-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.result-source-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.result-chunks-scroll {
    max-height: 360px;
    overflow-y: auto;
    min-height: 80px;
}

.loader-inline .loader-text {
    font-size: 13px;
}

.chunk-list {
    list-style: none;
}

.chunk-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.5;
}

.chunk-item:last-child { border-bottom: none; }

.chunk-time {
    font-weight: 600;
    color: var(--accent);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    margin-right: 8px;
    white-space: nowrap;
}

.full-text {
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
    padding: 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    max-height: 400px;
    overflow-y: auto;
}

/* === История === */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.history-item:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.history-icon {
    font-size: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-preview {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-date {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.history-empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-secondary);
}

.history-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.4;
}

/* === Авторизация === */
.auth-wrapper {
    width: 100%;
    max-width: 400px;
}

.auth-card {
    text-align: center;
}

.auth-card .logo {
    justify-content: center;
    font-size: 24px;
    margin-bottom: 8px;
}

.auth-card .logo-icon {
    font-size: 32px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.auth-switch {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-version {
    margin-top: 16px;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* === Ошибки и уведомления === */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    font-weight: 500;
}

.alert-error {
    background: #ffe5e7;
    color: var(--danger);
    border: 1px solid #ffcdd2;
}

[data-theme="dark"] .alert-error {
    background: #2a1215;
    border-color: #4a2025;
}

.alert-success {
    background: #e0f7f5;
    color: #1a8a7d;
    border: 1px solid #b2ede6;
}

[data-theme="dark"] .alert-success {
    background: #0f2a27;
    border-color: #1a4a45;
}

/* === Баннер обновления === */
.update-banner {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}
.update-banner .btn-primary {
    background: #fff;
    color: var(--accent);
}

/* === Утилиты === */
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* === Блок экспорта транскрипции === */
.export-block {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-top: 16px;
}
.export-block > .alert {
    flex: 1 1 100%;
}
.export-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.export-column .btn {
    justify-content: flex-start;
}
.export-column .btn-block { width: 100%; }

/* === Админ-панель === */
.adm-section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

.adm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.adm-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.adm-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.adm-stat-value {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.adm-level-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
}

.adm-level-ok { background: #e0f7f5; color: #1a8a7d; }
[data-theme="dark"] .adm-level-ok { background: #0f2a27; color: #3dd6c8; }
.adm-level-warning { background: #fff3cd; color: #856404; }
[data-theme="dark"] .adm-level-warning { background: #332b00; color: #ffc107; }
.adm-level-critical { background: #ffe5e7; color: var(--danger); }
[data-theme="dark"] .adm-level-critical { background: #2a1215; color: #ff4d5a; }

.adm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.adm-table th, .adm-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.adm-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.adm-logs-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.adm-logs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.adm-log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

.adm-log-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.adm-log-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* === Адаптив === */
@media (max-width: 600px) {
    .header-inner { padding: 0 12px; gap: 8px; justify-content: space-between; }
    .logo-text { font-size: 16px; }
    .app-version { font-size: 10px; }
    .nav { display: none; }
    .nav-mobile {
        display: flex;
        max-width: 720px;
        margin: calc(var(--header-h) + 4px) auto 8px;
        padding: 0 12px;
        gap: 4px;
    }
    .nav-mobile .nav-link {
        flex: 1;
        text-align: center;
    }
    .content { padding: 12px; padding-top: 12px; }
    .card { padding: 16px; }
    .url-input-group { flex-direction: column; }
    .tabs { font-size: 13px; }
    .export-block { flex-direction: column; }
}
