/* ============================================
   style.css — Стили для главной страницы
   ============================================ */

/* ---------- Шапка ---------- */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header h1 {
    font-size: 20px;
    font-weight: 600;
}
.header .header-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.header .header-controls .lesson-counter {
    font-size: 13px;
    opacity: 0.9;
    margin-right: 10px;
}

.btn-header {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
    white-space: nowrap;
    text-decoration: none;
}
.btn-header:hover {
    background: rgba(255, 255, 255, 0.3);
}
.btn-header.active {
    background: rgba(255, 255, 255, 0.35);
    border-color: white;
}
.btn-header .icon {
    margin-right: 4px;
}

/* ---------- Контейнер ---------- */
.container {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 70px);
}

/* ---------- Боковое меню ---------- */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e9ecef;
    overflow-y: auto;
    padding: 15px 0;
    flex-shrink: 0;
    height: calc(100vh - 70px);
    position: sticky;
    top: 70px;
}
.sidebar .sidebar-title {
    padding: 0 20px 12px;
    font-size: 14px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #f0f0f0;
}
.sidebar .lesson-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar .lesson-item:hover {
    background: #f8f9fa;
}
.sidebar .lesson-item.active {
    background: #f0f2ff;
    border-left-color: #667eea;
}
.sidebar .lesson-item .lesson-title {
    font-size: 15px;
    color: #333;
    font-weight: 500;
}
.sidebar .lesson-item .lesson-badge {
    font-size: 11px;
    background: #e9ecef;
    color: #888;
    padding: 2px 10px;
    border-radius: 12px;
}

/* ---------- Основная область ---------- */
.main-content {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    max-height: calc(100vh - 70px);
}

.lesson-header {
    margin-bottom: 30px;
}
.lesson-header h2 {
    font-size: 28px;
    color: #333;
    margin-bottom: 5px;
}
.lesson-header .lesson-meta {
    color: #888;
    font-size: 14px;
}
.lesson-header .lesson-meta .level-tag {
    background: #e8eaf6;
    padding: 2px 12px;
    border-radius: 12px;
    color: #5c6bc0;
    margin-right: 10px;
}

.lesson-content {
    max-width: 900px;
}

/* ---------- Предложения ---------- */
.sentence-block {
    background: white;
    border-radius: 12px;
    padding: 20px 25px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.2s;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}
.sentence-block:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
}
.sentence-block .sentence-number {
    color: #bbb;
    font-size: 14px;
    font-weight: 600;
    min-width: 30px;
    padding-top: 3px;
    user-select: none;
}
.sentence-block .sentence-body {
    flex: 1;
    min-width: 200px;
}

.sentence-block .sentence-audio-btn,
.sentence-block .sentence-progress {
    flex-shrink: 0;
}

/* --- Иероглифы с пиньинем --- */
.char-wrapper {
    display: inline-block;
    width: 2.8em;
    min-width: 2.8em;
    text-align: center;
    vertical-align: top;
    margin: 0 0.05em;
}
.char-wrapper .pinyin {
    display: block;
    font-size: 0.55em;
    color: #999;
    height: 1.8em;
    line-height: 1.8em;
    font-weight: 400;
    letter-spacing: 0.3px;
    transition: opacity 0.3s ease, transform 0.3s ease, font-size 0.3s ease;
    opacity: 0;
    transform: translateY(-5px);
    white-space: nowrap;
}
.char-wrapper .pinyin.visible {
    opacity: 1;
    transform: translateY(0);
}
.char-wrapper .pinyin.empty {
    visibility: hidden;
}
.char-wrapper .pinyin.visible {
    opacity: 1;
    transform: translateY(0);
}
.char-wrapper .pinyin.empty {
    visibility: hidden;
}
.char-wrapper .hanzi {
    display: block;
    font-size: 1.8em;
    line-height: 1.5em;
    font-weight: 500;
    color: #222;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sentence-block .sentence-hanzi {
    font-size: 20px;
    line-height: 1.6;
    margin-bottom: 3px;
    letter-spacing: 1px;
}

.sentence-block .sentence-translation {
    font-size: 16px;
    color: #666;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #eee;
}
.sentence-block .sentence-translation.hidden-translation {
    visibility: hidden;
}

/* --- Кнопка аудио --- */
.sentence-block .sentence-audio-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: #667eea;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}
.sentence-block .sentence-audio-btn:hover {
    background: #5a6fd6;
    transform: scale(1.05);
}
.sentence-block .sentence-audio-btn:active {
    transform: scale(0.95);
}
.sentence-block .sentence-audio-btn.no-audio {
    background: #ddd;
    color: #aaa;
    cursor: not-allowed;
}
.sentence-block .sentence-audio-btn.no-audio:hover {
    transform: none;
    background: #ddd;
}
.sentence-block .sentence-audio-btn.playing {
    background: #f44336;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ============================================
   ВСТРОЕННЫЙ АУДИО ПЛЕЕР
   ============================================ */
.sentence-player {
    display: none;
    width: 100%;
    padding: 12px 15px;
    margin-top: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.sentence-player.active {
    display: flex;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sentence-player .player-time {
    font-size: 13px;
    color: #888;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.sentence-player .player-progress {
    flex: 1;
    min-width: 100px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #e0e0e0;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.sentence-player .player-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: background 0.2s;
}
.sentence-player .player-progress::-webkit-slider-thumb:hover {
    background: #5a6fd6;
}
.sentence-player .player-progress::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.sentence-player .player-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.sentence-player .player-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #555;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sentence-player .player-btn:hover {
    background: #e9ecef;
}
.sentence-player .player-btn:active {
    transform: scale(0.95);
}

.sentence-player .player-btn-play {
    background: #667eea;
    color: white;
    width: 38px;
    height: 38px;
    font-size: 18px;
}
.sentence-player .player-btn-play:hover {
    background: #5a6fd6;
}
.sentence-player .player-btn-play.playing {
    background: #f44336;
}

.sentence-player .player-volume {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.sentence-player .player-volume span {
    font-size: 16px;
}
.sentence-player .player-volume input {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #e0e0e0;
    border-radius: 2px;
    outline: none;
}
.sentence-player .player-volume input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}
.sentence-player .player-volume input::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.sentence-player .player-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0 5px;
    transition: color 0.3s;
}
.sentence-player .player-close:hover {
    color: #333;
}

/* ---------- Прогресс ---------- */
.sentence-progress {
    display: inline-block;
    background: #667eea;
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    margin-left: 10px;
    cursor: help;
    flex-shrink: 0;
    align-self: center;
}
.sentence-progress:hover {
    background: #5a6fd6;
}

/* Дополнительные стили для прогресса */
.sentence-progress .progress-detail {
    display: none;
}
.sentence-progress:hover .progress-detail {
    display: block;
}

/* ---------- Адаптивность ---------- */
@media (max-width: 992px) {
    .sidebar {
        width: 220px;
    }
    .main-content {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        position: static;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
        padding: 10px 0;
    }
    .sidebar .sidebar-title {
        padding: 0 15px 8px;
        font-size: 12px;
    }
    .sidebar .lesson-item {
        padding: 8px 15px;
        font-size: 14px;
    }
    .main-content {
        max-height: none;
        padding: 15px;
    }
    .header h1 {
        font-size: 16px;
    }
    .header .header-controls .lesson-counter {
        font-size: 12px;
    }
    .btn-header {
        font-size: 11px;
        padding: 4px 10px;
    }
    .lesson-header h2 {
        font-size: 22px;
    }
    .sentence-block {
        padding: 15px;
    }
    .sentence-block .sentence-number {
        min-width: 25px;
        font-size: 12px;
    }
    .char-wrapper {
        width: 2.2em;
        min-width: 2.2em;
    }
    .char-wrapper .hanzi {
        font-size: 1.5em;
    }
    .char-wrapper .pinyin {
        font-size: 0.5em;
        height: 1.5em;
        line-height: 1.5em;
    }
    .sentence-block .sentence-hanzi {
        font-size: 17px;
    }
    .sentence-block .sentence-translation {
        font-size: 14px;
    }
    .sentence-block .sentence-audio-btn {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }
    .keyboard-hint {
        display: none !important;
    }
    
    /* Плеер на телефоне */
    .sentence-player {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
    }
    .sentence-player .player-progress {
        order: 3;
        flex-basis: 100%;
    }
    .sentence-player .player-volume input {
        width: 40px;
    }
    .sentence-player .player-buttons {
        gap: 4px;
    }
    .sentence-player .player-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    .sentence-player .player-btn-play {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 10px 12px;
    }
    .header h1 {
        font-size: 14px;
    }
    .btn-header {
        font-size: 10px;
        padding: 3px 8px;
    }
    .main-content {
        padding: 10px;
    }
    .sentence-block {
        padding: 12px;
    }
    .char-wrapper {
        width: 1.9em;
        min-width: 1.9em;
    }
    .char-wrapper .hanzi {
        font-size: 1.3em;
    }
    .char-wrapper .pinyin {
        font-size: 0.45em;
        height: 1.3em;
        line-height: 1.3em;
    }
    .sentence-block .sentence-hanzi {
        font-size: 15px;
    }
}

@media (min-width: 768px) {
    .keyboard-hint {
        display: block;
    }
}

/* Когда иероглифы скрыты — пиньинь становится крупнее */
.char-wrapper .hanzi.hidden-hanzi ~ .pinyin,
.char-wrapper .hanzi.hidden-hanzi + .pinyin {
    font-size: 1.6em !important;
    height: auto !important;
    line-height: 1.5 !important;
    color: #333 !important;
    font-weight: 500 !important;
    letter-spacing: 0.5px !important;
    margin-top: 0 !important;
}
/* Скрытие иероглифов (когда пиньинь скрыт — просто невидимы) */
.char-wrapper .hanzi.hidden-hanzi {
    visibility: hidden;
}

/* Расширение пиньиня, когда иероглифы скрыты И пиньинь показан */
.char-wrapper.hide-hanzi {
    width: auto;
    min-width: auto;
    padding: 0 0.15em;
}

.char-wrapper.hide-hanzi .hanzi {
    visibility: hidden;
    height: 0;
    line-height: 0;
    overflow: hidden;
}

.char-wrapper.hide-hanzi .pinyin {
    font-size: 1.6em;
    height: auto;
    line-height: 1.5;
    color: #333;
    font-weight: 500;
    letter-spacing: 0.5px;
    transform: translateY(0);
    margin-top: 0;
    padding-top: 0.3em;
    padding-bottom: 0.3em;
}

/* ============================================
   Детальная статистика по дням
   ============================================ */

.daily-detail-table-wrapper {
    max-height: 420px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.daily-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.daily-detail-table thead {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.daily-detail-table th {
    padding: 12px 15px;
    text-align: left;
    color: #555;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 2px solid #e9ecef;
    user-select: none;
}

.daily-detail-table th.sortable {
    cursor: pointer;
    transition: background 0.2s;
}

.daily-detail-table th.sortable:hover {
    background: #eef0f3;
}

.daily-detail-table th.sortable.active-sort {
    color: #667eea;
}

.daily-detail-table th .sort-arrow {
    display: inline-block;
    margin-left: 5px;
    font-size: 12px;
    color: #ccc;
}

.daily-detail-table th.active-sort .sort-arrow {
    color: #667eea;
}

.daily-detail-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}

.daily-detail-table tbody tr:hover {
    background: #f8f9fa;
}

.daily-detail-table tbody tr:last-child td {
    border-bottom: none;
}

.daily-detail-table-wrapper::-webkit-scrollbar {
    width: 8px;
}

.daily-detail-table-wrapper::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.daily-detail-table-wrapper::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.daily-detail-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}