/* =============== EXERCISE LIBRARY =============== */
/* Секционный экран с горизонтальными каруселями */

/* ---- Экран библиотеки ---- */
#exercise-library {
    background: var(--bg-dashboard) !important;
}

/* ---- Контейнер страницы ---- */
.library-page {
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 100px;
}

.library-page::-webkit-scrollbar {
    display: none;
}

/* ---- Заголовок страницы ---- */
.library-page-header {
    padding: 16px 20px 8px;
}

.library-page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
}

/* ---- Счётчик и поиск ---- */
.library-counter {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 10px;
}

.library-counter strong {
    color: var(--dark);
    font-weight: 700;
    font-size: 14px;
}

.library-search-wrap {
    position: relative;
    margin-bottom: 4px;
}

.library-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.library-search-input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-small, 12px);
    background: var(--white);
    font-size: 14px;
    color: var(--dark);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.library-search-input:focus {
    border-color: var(--primary);
}

.library-search-input::placeholder {
    color: var(--text-secondary);
}

.library-search-no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ---- Секция ---- */
.library-section {
    margin-bottom: 24px;
}

.library-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    margin-bottom: 12px;
    -webkit-tap-highlight-color: transparent;
}

.library-section-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--dark);
}

.library-section-count {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray);
    background: var(--gray-light);
    padding: 2px 8px;
    border-radius: 10px;
}

.library-section-arrow {
    margin-left: auto;
    color: var(--gray);
    font-size: 18px;
    line-height: 1;
}

.library-section-arrow::after {
    content: '›';
}

.library-section-subtitle {
    padding: 0 20px;
    margin-top: -8px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--gray, #8c8279);
    line-height: 1.3;
}

/* ---- Карусель ---- */
.library-carousel {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
}
.library-carousel.dragging {
    cursor: grabbing;
    scroll-behavior: auto;
    user-select: none;
}

.library-carousel-card:first-child {
    margin-left: 20px;
}

.library-carousel-card:last-child {
    margin-right: 20px;
}

.library-carousel::-webkit-scrollbar {
    display: none;
}

/* ---- Карточка в карусели ---- */
.library-carousel-card {
    flex-shrink: 0;
    width: 44vw;
    max-width: 200px;
    background: var(--white);
    border-radius: var(--border-radius-small);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    scroll-snap-align: start;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.library-carousel-card:active {
    transform: scale(0.97);
}

.library-carousel-thumb {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    background: var(--muted, #C9BFA9);
    display: block;
}

.library-carousel-name {
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 42px;
}

/* ---- Drill-down вид секции ---- */
.library-drilldown {
    overflow-y: auto;
    padding-bottom: 100px;
    animation: slideIn 0.3s ease-out;
}

.library-drilldown-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
}

.library-drilldown-back {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--gray-light);
    color: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.library-drilldown-back:active {
    background: var(--muted);
}

.library-drilldown-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
}

.library-drilldown-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 20px;
}

.library-drilldown-card {
    border-radius: var(--border-radius-small);
    overflow: hidden;
    cursor: pointer;
    background: var(--white);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.library-drilldown-card:active {
    transform: scale(0.98);
}

.library-drilldown-thumb {
    width: 100%;
    aspect-ratio: 5/4;
    object-fit: cover;
    background: var(--muted, #C9BFA9);
    display: block;
}

.library-drilldown-name {
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.3;
}

/* ---- Модальное окно с видео ---- */
.library-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.library-modal {
    background: var(--white);
    width: 100%;
    height: 100%;
    overflow: hidden;
    animation: modalSlideUp 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.library-modal-video-wrap {
    flex: 1;
    background: #0a0a0a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.library-modal-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    position: relative;
    z-index: 1;
}

.library-modal-body {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    background: var(--white);
}

.library-modal-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark);
    flex: 1;
    line-height: 1.3;
}

.library-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-light);
    color: var(--dark);
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.library-modal-close:active {
    background: var(--muted);
}

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

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

@keyframes slideBack {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

/* ---- Текстовая карточка питания ---- */
.nutrition-meal-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
}

.nutrition-meal-card .library-carousel-name {
    text-align: center;
}

.nutrition-meal-card-icon {
    width: 100%;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-small, 12px) var(--border-radius-small, 12px) 0 0;
    color: white;
}

.nutrition-meal-card-icon svg {
    width: 28px;
    height: 28px;
}

.nutrition-meal-card-icon--large {
    width: 80px;
    height: 80px;
    aspect-ratio: auto;
    border-radius: var(--border-radius-small, 12px);
    flex-shrink: 0;
}

.nutrition-meal-card-icon--large svg {
    width: 32px;
    height: 32px;
}

/* Градиенты по типам приёмов пищи */
.meal-icon--breakfast {
    background: linear-gradient(135deg, #F6A623 0%, #F7C948 100%);
}

.meal-icon--lunch {
    background: linear-gradient(135deg, #56AB2F 0%, #A8E063 100%);
}

.meal-icon--dinner {
    background: linear-gradient(135deg, #C06A3E 0%, #E0956B 100%);
}

.meal-icon--snack {
    background: linear-gradient(135deg, #E55D87 0%, #F3A4B5 100%);
}

.nutrition-meal-card-cal {
    padding: 0 8px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary, #C06A3E);
}

/* ---- Placeholder для упражнений без видео ---- */
.workout-exercise-placeholder {
    width: 100%;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: var(--white, #fff);
    background: var(--muted, #C9BFA9);
    border-radius: var(--border-radius-small, 12px) var(--border-radius-small, 12px) 0 0;
}

.workout-exercise-placeholder--large {
    aspect-ratio: 5/4;
    font-size: 48px;
    border-radius: var(--border-radius-small, 12px) var(--border-radius-small, 12px) 0 0;
}

/* ---- Drill-down для питания (горизонтальная карточка) ---- */
.nutrition-drilldown-meal {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px;
}

.nutrition-drilldown-meal .library-drilldown-name {
    flex: 1;
}

/* ---- Статусы тренировок в карусели ---- */
.workout-carousel-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 6px;
    vertical-align: middle;
}

.workout-carousel-status.completed {
    background: rgba(76, 175, 80, 0.15);
    color: #4caf50;
}

.workout-carousel-status.partial {
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
}

/* ---- Calendar button in section header ---- */
.workout-drilldown-cal {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gray-light, #f5f0eb);
    color: var(--dark, #2c2520);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}

.workout-drilldown-cal:active {
    background: var(--muted, #C9BFA9);
}
