/* ========================================= */
/* 🏋️ WORKOUT MODULE STYLES                 */
/* ========================================= */

/* --- 1. WIDGETS: NEXT WORKOUT & SLIDER --- */

/* Next Workout Widget (Single Large Card) */
.next-workout-card {
    background: var(--surface);
    border: 1px solid var(--border);
    /* Используем переменную для единого стиля скругления */
    border-radius: var(--radius);
    box-shadow: none;
    height: 80px;
    /* Убираем отступ у самой карточки, так как отступ задает контейнер выше */
    margin-bottom: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: stretch;
    box-sizing: border-box;
    width: 100%;
}

    .next-workout-card:active {
        opacity: 0.8;
        transform: scale(0.99);
    }

/* History/Favorite Slider (Horizontal Scroll) */
.history-slider-wrapper {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 0; /* Было 5px, лучше 0, если скроллбары скрыты */
    margin-bottom: 0; /* ❌ БЫЛО 25px -> СТАВИМ 0. Отступ уже задает контейнер ниже (#history-slider-container) */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

    .history-slider-wrapper::-webkit-scrollbar {
        display: none;
    }

.fav-plan-card {
    min-width: 260px;
    background: linear-gradient(135deg, rgba(145, 71, 255, 0.15) 0%, rgba(145, 71, 255, 0.05) 100%);
    border: 1px solid rgba(145, 71, 255, 0.3);
    border-radius: 16px;
    padding: 15px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s;
}

    .fav-plan-card:active {
        transform: scale(0.98);
    }

#history-slider-container {
    display: block;
    /* Делаем отступ таким же, как у категорий */
    margin-bottom: 12px;
    animation: fadeIn 0.4s ease;
    width: 100%;
}

/* --- 2. CATEGORIES & PLAN LIST --- */

/* Category Accordion Header */
.category-section-wrapper {
    /* Единый отступ между блоками */
    margin-bottom: 12px;
    width: 100%;
}

.block-res-input,
#workout-report-comment {
    min-height: 40px; /* Минимальная высота */
    resize: none; /* Отключаем ручное изменение размера пользователем */
    overflow: hidden; /* Прячем скроллбар, так как высота подстраивается */
    transition: height 0.05s ease; /* Минимальная задержка для плавности */
    box-sizing: border-box;
}

/* Заголовок категории (Сама плашка с картинкой) */
.user-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px; /* Убираем вертикальный паддинг, выравниваем флексом */
    margin-bottom: 0; /* Убираем отступ внутри обертки */
    cursor: pointer;
    /* Приводим скругление к единому стандарту (было 16px) */
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
    user-select: none;
    min-height: 80px; /* Высота как у виджета сверху */
    height: 80px;
}

    .user-category-header.styled:active {
        transform: scale(0.98);
    }

.user-category-title {
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.user-category-header .arrow-icon {
    font-size: 24px;
    z-index: 2;
}

/* Category Content (Accordion Body) */
.user-category-content {
    /* Основное (РАЗВЕРНУТОЕ) состояние */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* Плавная анимация */
    max-height: 5000px; /* Достаточная высота для контента */
    opacity: 1;
    overflow: hidden;
    margin-top: 10px; /* Твой отступ */
    margin-bottom: 10px; /* Твой отступ */
}

    /* СВЕРНУТОЕ состояние (добавляем max-height: 0) */
    .user-category-content.collapsed {
        max-height: 0; /* ВАЖНО: Схлопываем высоту в 0 */
        opacity: 0; /* Скрываем прозрачность */
        margin-top: 0; /* Убираем отступ сверху */
        margin-bottom: 0; /* Убираем отступ снизу */
        pointer-events: none; /* Запрещаем клики по скрытым элементам */
    }

/* Plan Card Item */
.plan-item {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    cursor: pointer;
    transition: all 0.2s;
    flex-direction: column;
}

    .plan-item:hover {
        border-color: var(--primary);
        background: var(--hover);
    }

    .plan-item.desc-open {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-bottom-color: transparent;
        z-index: 2;
    }

/* Plan Info badges */
.plan-info-line {
    font-size: 11px;
    color: var(--text-sec);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.plan-info-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(145, 71, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    color: var(--primary);
}

.plan-range {
    font-size: 10px;
    color: var(--text-sec);
    background: rgba(145, 71, 255, 0.05);
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
}

/* Plan Description Dropdown */
.plan-desc-block {
    display: none;
    background: var(--surface);
    border: 2px solid var(--border);
    border-top: 1px dashed var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 20px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    margin-top: -4px;
    position: relative;
    z-index: 1;
}

    .plan-desc-block.open {
        display: block !important;
        animation: slideDown 0.2s ease-out;
    }

/* --- 3. WORKOUT LIST (WEEKS) --- */

.week-header-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 15px;
    cursor: pointer;
    background: var(--surface);
    width: 100%;
    position: relative;
}

    .week-header-centered .week-main-title {
        font-weight: 700;
        font-size: 13px;
        letter-spacing: 0.5px;
        margin-bottom: 4px;
        text-transform: uppercase;
        color: var(--primary);
    }

    .week-header-centered .week-subtitle {
        font-size: 11px;
        color: var(--text-sec);
        text-align: center;
    }

    .week-header-centered .arrow-icon {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-sec);
    }

.week-wrapper {
    transition: all 0.2s ease;
}

.acc-content {
    display: none !important;
}

    .acc-content.open {
        display: block !important;
        animation: fadeIn 0.2s;
    }

/* Status Styles */
.std-item {
    background: var(--surface);
    border: none;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-card);
}

    .std-item:hover {
        background: var(--hover);
    }

    .std-item:active {
        transform: scale(0.98);
    }

.archived {
    opacity: 0.6;
}

    .archived b {
        text-decoration: line-through;
        text-decoration-thickness: 2px;
        text-decoration-color: var(--text-sec);
    }

.archive-divider-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 20px 0 10px 0;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    color: var(--text-sec);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
}

/* --- 4. WORKOUT EXECUTION (DETAILS) --- */

/* Task Spoiler (WOD Description) */
.wod-task-spoiler {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin-bottom: 8px;
    overflow: hidden;
}

.wod-task-header {
    padding: 12px 15px;
    background: var(--surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

    .wod-task-header:hover {
        background: var(--hover);
    }

.wod-task-content {
    background: var(--bg);
    padding: 15px;
    font-size: 13px;
    line-height: 1.5;
    display: none;
}

    .wod-task-content.open {
        display: block;
        animation: slideDown 0.2s ease-out;
    }

/* Report Blocks (Result Input) */
.report-block-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
}

.rb-header {
    padding: 12px;
    font-weight: 700;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

/* Tabs inside block */
.rb-toggles {
    display: flex;
    background: rgba(0,0,0,0.03);
    padding: 2px;
    border-radius: 8px;
    margin: 10px 10px 0 10px;
}

.rb-toggle-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-sec);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

    .rb-toggle-btn.active {
        background: var(--surface);
        color: var(--primary);
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

.rb-content-section {
    display: none;
    padding: 15px;
    font-size: 13px;
    line-height: 1.5;
    border-bottom: 1px solid var(--border);
}

    .rb-content-section.open {
        display: block !important;
    }

/* Static Values & Coach Replies */
.rb-static-value {
    font-size: 15px;
    color: var(--text);
    white-space: pre-wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.coach-reply-box {
    background: rgba(145, 71, 255, 0.04);
    border: 1px dashed var(--primary);
    border-radius: 8px;
    padding: 12px;
    margin-top: 15px;
    animation: fadeIn 0.3s ease;
}

/* View/Edit Mode Helpers */
.view-mode .edit-layer, .view-only .edit-layer, .edit-mode .view-layer {
    display: none !important;
}
/* Coach Exception: Coach inputs always visible */
.coach-reply-box .edit-layer, .report-block-wrapper .coach-input-text {
    display: block !important;
}

.coach-view-mode .block-res-input, .coach-view-mode .block-res-video {
    display: none !important;
}

/* Custom Blocks */
.cb-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid #FFAB00;
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 10px;
    position: relative;
}

.cb-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    color: var(--error);
    cursor: pointer;
}

/* --- 5. VIDEO COMPONENTS & EDITOR --- */

.btn-mini-video {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    transition: 0.2s;
    user-select: none;
}

    .btn-mini-video:active {
        transform: scale(0.95);
    }

    .btn-mini-video.has-video {
        background: rgba(145, 71, 255, 0.1);
        color: var(--primary);
        border-color: rgba(145, 71, 255, 0.3);
    }

    .btn-mini-video.coach-video {
        background: rgba(0, 230, 118, 0.1);
        color: #00E676;
        border-color: rgba(0, 230, 118, 0.3);
    }

/* Video Upload Progress */
.upload-progress-wrapper {
    width: 100%;
    margin-top: 8px;
    animation: fadeIn 0.3s ease;
}

.upload-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.upload-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease-out;
}

/* Editor Modal Specifics */
#modal-video-editor .settings-card {
    background: #1e1e1e;
    color: #fff;
    border: 1px solid #333;
    padding: 0;
    overflow: hidden;
    max-width: 500px;
}

#vid-step-1 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 30px;
    text-align: center;
    background: linear-gradient(180deg, #1e1e1e 0%, #121212 100%);
}

.vid-icon-wrapper {
    width: 90px;
    height: 90px;
    background: rgba(145, 71, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.vid-upload-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 12px 32px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(145, 71, 255, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#vid-editor-src, #vid-editor-canvas {
    border-radius: 12px;
    background: #000;
}

.trim-slider-wrapper {
    width: 100%;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.trim-slider-container {
    position: relative;
    height: 40px;
    width: 100%;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.trim-track-bg {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    transform: translateY(-50%);
}

#vid-trim-fill {
    position: absolute;
    top: 50%;
    height: 6px;
    background: var(--primary);
    border-radius: 3px;
    transform: translateY(-50%);
    z-index: 1;
}

.trim-slider-container input[type=range] {
    -webkit-appearance: none;
    pointer-events: none;
    position: absolute;
    z-index: 2;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    margin: 0;
    background: transparent;
    height: 100%;
}

    .trim-slider-container input[type=range]::-webkit-slider-thumb {
        -webkit-appearance: none;
        pointer-events: auto;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: #ffffff;
        border: 3px solid var(--primary);
        cursor: grab;
        margin-top: 0;
    }

/* --- 6. LEADERBOARD (FLOATING CARDS) --- */
.floating-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-card);
}

.floating-task-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}

    .floating-task-header.active .arrow-icon {
        transform: rotate(180deg);
    }

.floating-task-content {
    display: none;
    padding: 4px 0;
    font-size: 14px;
    line-height: 1.4;
    border-top: 1px dashed var(--border);
    margin-top: 2px;
    white-space: pre-wrap;
}

    .floating-task-content.open {
        display: block !important;
        animation: fadeIn 0.3s ease-out;
    }

/* --- 7. MISC & WATERMARK --- */
#workout-watermark-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 900;
    pointer-events: none;
    display: none;
    overflow: hidden;
}

.watermark-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(6, 1fr);
    width: 200%;
    height: 200%;
    transform: rotate(-30deg) translate(-25%, -25%);
    opacity: 0.04;
}

.watermark-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 900;
    text-transform: uppercase;
}

.anti-copy-area-on #workout-watermark-overlay {
    display: block;
}

.report-popup-wide {
    max-width: 450px !important;
    width: 100% !important;
    padding: 15px !important;
}

/* ========================================= */
/* 🛠️ POPUP FIXES                            */
/* ========================================= */

/* Скрываем верхнюю кнопку закрытия (крестик) в попапе следующей тренировки,
   так как внизу уже есть большая кнопка "Закрыть" */
#report-popup-modal .modal-close-btn,
#report-popup-modal .close-icon {
    display: none !important;
}