/* ========================================
   AudioLingua — Глобальные стили
======================================== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #64748b;
    --success: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Курсор ожидания при загрузке */
body.loading {
    cursor: wait !important;
}
body.loading * {
    cursor: wait !important;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: cursor 0.2s;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.nav-link.active, .nav-link:hover {
    color: var(--primary);
}

/* Main & Steps */
.main {
    padding: 2rem 0;
}

/* 🌟 ПЛАВНАЯ АНИМАЦИЯ ШАГОВ (убирает подёргивание) */
.step {
    display: none;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.step.active {
    display: block;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--background);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    width: 100%;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Upload Card */
.upload-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.upload-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.tab {
    background: none;
    border: none;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
}

.tab.active {
    color: var(--primary);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.text-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: var(--transition);
}

.text-input:focus {
    outline: none;
    border-color: var(--primary);
}

.text-stats {
    display: flex;
    gap: 1.5rem;
    margin: 1rem 0 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.file-drop-zone {
    border: 2px dashed var(--border);
    padding: 3rem;
    text-align: center;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.file-drop-zone:hover {
    border-color: var(--primary);
    background: #f0f4ff;
}

.file-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.file-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.url-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.setting-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.setting-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

.setting-row {
    margin-bottom: 1.5rem;
}

.setting-row label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 1rem;
}

.speed-control {
    display: flex;
    gap: 0.5rem;
}

.speed-btn {
    flex: 1;
    padding: 0.5rem;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.speed-btn.active {
    border-color: var(--primary);
    background: #e0e7ff;
    color: var(--primary);
}

.settings-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

/* Progress */
.progress-container {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    border: 6px solid var(--border);
    border-top: 6px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.spinner.active {
    display: block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

#progress-status {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0.5rem 0 1.5rem;
    font-weight: 500;
    min-height: 1.5rem;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 2rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.5s ease;
}

.progress-steps {
    text-align: left;
    max-width: 400px;
    margin: 0 auto 2rem;
}

.progress-step {
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    background: var(--background);
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: var(--transition);
    opacity: 0.6;
}

.progress-step.active {
    background: #e0e7ff;
    color: var(--primary);
    font-weight: 600;
    opacity: 1;
    transform: translateX(5px);
}

.progress-step.completed {
    background: #d1fae5;
    color: #059669;
    opacity: 1;
}

.progress-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 1rem;
}

/* Player */
.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.lesson-actions {
    display: flex;
    gap: 0.5rem;
}

.player-container {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.control-btn {
    width: 45px;
    height: 45px;
    border: none;
    background: var(--background);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: var(--border);
}

.btn-play {
    width: 60px;
    height: 60px;
    background: var(--primary);
    color: white;
    font-size: 1.5rem;
}

.btn-play:hover {
    background: var(--primary-dark);
}

.time-display {
    flex: 1;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: monospace;
}

.speed-toggle-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.speed-toggle-btn:hover {
    background: var(--background);
}

.text-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    max-height: 500px;
    overflow-y: auto;
}

/* 🌟 Стили для чанков (сегментов) */
.chunk-block {
    background: var(--background);
    padding: 1.5rem;
    border-radius: var(--radius);
    border-left: 4px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
}

.chunk-block:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

.chunk-block.active {
    border-left-color: var(--primary);
    background: #f0f4ff;
}

.chunk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.chunk-badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.chunk-sentences {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.chunk-content {
    margin-bottom: 1rem;
}

.sentence-pair {
    margin-bottom: 0.75rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
}

.sentence-original {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.sentence-translation {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.chunk-explanation {
    background: #f0f4ff;
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0.5rem 0;
    border-left: 3px solid var(--primary);
}

.chunk-audio audio {
    width: 100%;
    margin-top: 0.5rem;
    height: 40px;
}

/* Vocabulary */
.vocabulary-panel {
    background: var(--background);
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.vocabulary-panel h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.vocab-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.vocab-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: var(--radius);
}

.vocab-word {
    font-weight: 600;
    color: var(--primary);
    min-width: 120px;
}

.vocab-translation {
    color: var(--text-secondary);
    flex: 1;
    margin: 0 1rem;
}

.vocab-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.6;
    transition: var(--transition);
}

.vocab-btn:hover {
    opacity: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.export-option:hover {
    background: var(--surface);
    border-color: var(--primary);
}

.export-icon {
    font-size: 1.5rem;
}

.export-info {
    flex: 1;
}

.export-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.export-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .nav { display: none; }
    .settings-grid { grid-template-columns: 1fr; }
    .audio-controls { flex-wrap: wrap; }
    .time-display { width: 100%; margin: 0.5rem 0; text-align: center; }
}