/* ==============================================
   НАСТРОЙКИ СОВРЕМЕННОГО ДИЗАЙНА (CSS Variables)
   ============================================== */

:root {
    --color-primary: #0071e3;
    --color-text: #1d1d1f;
    --color-text-secondary: #6e6e73;
    --color-background: #f5f5f7;
    --color-card-bg: #ffffff;
    --border-radius-main: 16px;
    --border-radius-small: 8px;
    --shadow-main: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.1);
}

/* ==============================================
   ГЛОБАЛЬНЫЕ СТИЛИ И ТИПОГРАФИКА
   ============================================== */

body {
    background-color: var(--color-background);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
/* Отступ под нижнее меню на мобильных */
@media (min-width: 992px) { body { padding-bottom: 0; } }
/* === СТИЛЬНАЯ МОБИЛЬНАЯ КОРЗИНА (Green Pill) === */
.mobile-cart-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    color: #868e96; /* Серый по умолчанию */
}

.mobile-cart-wrapper i {
    font-size: 1.5rem;
    transition: all 0.3s;
}

.mobile-cart-wrapper span.count-text {
    font-size: 0; /* Скрываем цифру, если 0 */
    font-weight: 700;
    margin-left: 0;
    opacity: 0;
    transition: all 0.3s;
    width: 0;
    overflow: hidden;
}

/* АКТИВНОЕ СОСТОЯНИЕ (Есть товары) */
.mobile-cart-wrapper.has-items {
    background-color: rgba(25, 135, 84, 0.15); /* Полупрозрачный зеленый */
    padding: 6px 12px;
    color: #198754; /* Насыщенный зеленый текст */
}

.mobile-cart-wrapper.has-items i {
    font-size: 1.2rem; /* Чуть уменьшаем иконку */
}

.mobile-cart-wrapper.has-items span.count-text {
    font-size: 1rem;
    margin-left: 6px;
    opacity: 1;
    width: auto;
}

/* Анимация "пульс" при добавлении */
@keyframes cart-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.mobile-cart-wrapper.bump {
    animation: cart-pop 0.3s ease-out;
}

/* --- Modern Timeline for Tracking --- */
.timeline {
    position: relative;
    padding-left: 10px;
}

.timeline-item {
    position: relative;
    padding-left: 30px; /* Отступ для линии */
    padding-bottom: 30px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

/* Вертикальная линия */
.timeline-item::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 5px;
    bottom: -5px; /* Тянется до следующего элемента */
    width: 2px;
    background-color: #e9ecef;
}

.timeline-item:last-child::before {
    display: none; /* Убираем линию у последнего элемента */
}

/* Точка (маркер) */
.timeline-marker {
    position: absolute;
    left: 0;
    top: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #fff;
    border: 3px solid #adb5bd;
    z-index: 1;
}

/* Активный (самый верхний) элемент */
.timeline-item.active .timeline-marker {
    border-color: #0d6efd; /* Primary color */
    background-color: #0d6efd;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.2); /* Пульсация */
}

.timeline-item.active .timeline-status {
    color: #0d6efd;
    font-weight: 700;
}

/* Тексты */
.timeline-date {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 2px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timeline-status {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    color: #212529;
}

.timeline-desc {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 4px;
}


/* Обновляем Z-Index для нижней панели, чтобы она была ниже модалок и блоков покупки */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;

    /* Задаем базовую высоту для старых экранов,
       а для новых — прибавляем к ней размер безопасной зоны */
    height: calc(60px + env(safe-area-inset-bottom));

    /* Оставляем padding-bottom, чтобы контент (иконки/текст)
       отталкивался от самого низа экрана */
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: content-box;
    background: #ffffff;
    box-shadow: 0 -1px 10px rgba(0,0,0,0.05);
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1020;
}

.mobile-bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #868e96;
    height: 100%;
    font-size: 1.5rem;
}
.mobile-bottom-nav .nav-item span {
    font-size: 0.65rem;
    font-weight: 500;
    margin-top: 2px;
}
.mobile-bottom-nav .nav-item.active {
    color: var(--color-primary);
}
.mobile-bottom-nav .nav-item:active {
    transform: scale(0.95);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    border-radius: var(--border-radius-small);
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    background-color: #0077ed;
    border-color: #0077ed;
}

/* ==============================================
   НАВИГАЦИЯ И "ЖИВОЙ" ПОИСК
   ============================================== */
/* --- Стили для кнопок-ссылок в меню --- */
.navbar-nav .nav-item {
    margin-left: 0.25rem;
    margin-right: 0.25rem;
}

.navbar-nav .nav-link {
    padding: 0.5rem 1rem; /* Добавляем "воздуха" */
    border-radius: var(--border-radius-small); /* Скругляем углы */
    transition: all 0.2s ease-in-out;
    font-weight: 500; /* Делаем шрифт чуть жирнее */
}

/* Фон при наведении */
.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
    background-color: var(--color-background); /* Светлый фон (#f5f5f7) */
    color: var(--color-primary);
}

/* Выделение "опасных" кнопок */
.navbar-nav .nav-link.text-danger {
    color: #dc3545 !important;
}
.navbar-nav .nav-link.text-danger:hover {
    background-color: #f8d7da; /* Бледно-красный фон */
    color: #58151c !important;
}

.navbar {
    background-color: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid #ddd;
}

/* Стили для подзаголовка логотипа */
.navbar-subtitle {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
}

/* --- СТИЛИ ДЛЯ ИКОНКИ КОРЗИНЫ --- */
#cart-icon-link {
    position: relative; /* Чтобы значок-счетчик позиционировался относительно иконки */
    color: var(--color-text);
}
#cart-icon-link .bi-cart {
    width: 24px;
    height: 24px;
}
#cart-badge {
    position: absolute;
    top: -5px;
    right: -10px;
    font-size: 0.65rem;
    padding: 3px 6px;
}
/* -------------------------------- */


/* --- ИСПРАВЛЕНИЕ: Поиск теперь широкий на ПК --- */
/* СТАЛО */
#search-bar-container {
    max-width: 900px; /* Ваша ширина поиска */
    margin-left: auto;
    margin-right: auto;
    /* Убираем отступы контейнера по умолчанию, чтобы он не был "уже" */
    padding-left: 0;
    padding-right: 0;
}
#live-search-form {
    position: relative;
    width: 100%; /* <-- Форма теперь занимает 100% контейнера */
}
/* ------------------------------------------- */

#live-search-input {
    background-color: #f1f3f5 !important; /* Серый фон */
    font-size: 0.95rem;
    height: 44px; /* Высота под палец */
    transition: all 0.2s ease;
}
#live-search-input:focus {
    background-color: #fff !important;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1);
    border-color: #0d6efd !important;
}

/* Убираем отступ у .collapse, т.к. он теперь в .container */
@media (max-width: 991.98px) { /* < lg */
    .navbar-collapse .container {
        padding-left: 0;
        padding-right: 0;
    }
}

/* Контейнер результатов (остается без изменений) */
#search-results-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-card-bg);
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 var(--border-radius-main) var(--border-radius-main);
    box-shadow: var(--shadow-main);
    max-height: 50vh;
    overflow-y: auto;
    z-index: 1050;
    display: none;
    padding: 8px;
}
#search-results-container .list-group-item {
    border: none;
    border-radius: var(--border-radius-small);
    padding: 12px;
}
#search-results-container .list-group-item-action:hover {
    background-color: var(--color-background);
    transform: scale(1.02);
}

#search-results-container .search-result-name {
    font-weight: 400;
    color: var(--color-text);
    line-height: 1.1;
}

#search-results-container .search-result-sku {
    font-size: 0.9em;
    color: var(--color-text-secondary);
}

#search-results-container .search-result-price {
    font-weight: 500;
    color: var(--color-primary);
    white-space: nowrap;
    margin-left: 0.75rem; /* Отступ от артикула */
}

#search-results-container .search-result-meta {
    margin-top: 4px; /* Отступ от названия */
}

/* ==============================================
   КАРТОЧКА ТОВАРА (Wildberries Style v3)
   ============================================== */

.product-card {
    border: none;
    background-color: var(--color-card-bg);
    border-radius: var(--border-radius-main);
    transition: all 0.3s ease-in-out;
    box-shadow: var(--shadow-main);
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.product-image-wrapper {
    position: relative; /* Для плашки скидки */
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 1rem;
    background-color: #fff;
    border-top-left-radius: var(--border-radius-main);
    border-top-right-radius: var(--border-radius-main);
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.discount-badge {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background-color: #d90429;
    color: white;
    padding: 4px 8px;
    border-radius: var(--border-radius-small);
    font-size: 0.9rem;
    font-weight: 700;
    z-index: 10;
    line-height: 1;
}

.personal-badge {
    left: 1rem; /* Слева */
    right: auto;
    background-color: #0d6efd; /* Синий */
}

.product-card .card-body {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
}

/* 1. Сначала мы убираем все стили шрифта с самого .card-title */
.card-body .card-title {
    /* Оставляем только отступ и высоту */
    margin-bottom: 0.5rem;
    min-height: 2.1rem; /* (0.8rem * 1.3 * 2 строки) */
}

/* 2. А теперь применяем все стили к самой ссылке ВНУТРИ */
.card-body .card-title a {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--color-text);
    display: inline-block;
    line-height: 1.3;
    /* Отменяем стили Bootstrap для <a> */
    text-decoration: none;
}

/* Добавляем подчеркивание при наведении */
.card-body .card-title a:hover {
    text-decoration: underline;
}
/* --------------------------------------------------------- */
/* --------------------------------------------------------- */

.card-body .card-text {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.product-card .card-footer {
    background-color: transparent;
    border-top: 1px solid #f0f0f0;
    padding: 0.75rem;
}

.product-card .product-price {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

/* --- НОВЫЕ СТИЛИ ДЛЯ СТЕППЕРА --- */
.quantity-stepper {
    display: flex;
    width: 100%;
    border: 1px solid #ddd;
    border-radius: var(--border-radius-small);
    overflow: hidden; /* Чтобы скруглить углы у кнопок */
}

.quantity-stepper .btn {
    flex: 0 0 40px; /* Фикс. ширина 40px */
    border: none;
    border-radius: 0;
    font-size: 1.2rem;
    padding-top: 0;
    padding-bottom: 0;
    z-index: 1; /* Чтобы были поверх input */
}
.quantity-stepper .btn:hover {
    background-color: #e9ecef;
}

.quantity-stepper .product-quantity-input {
    flex: 1 1 auto; /* Занимает все оставшееся место */
    border: none;
    padding: 0.375rem 0.5rem;
    /* Убираем стрелки у input[type=number] */
    -moz-appearance: textfield;
}

.quantity-stepper .product-quantity-input::-webkit-outer-spin-button,
.quantity-stepper .product-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

@media (max-width: 767.98px) {
    /* Уменьшаем заголовок на странице товара */
    h1.display-6 {
        font-size: 1.25rem;
    }
}

/* ==============================================
   СТИЛИ ДЛЯ АДМИН-ПАНЕЛИ
   ============================================== */

.admin-sidebar .nav-link.active {
    font-weight: 500;
    color: #0d6efd;
}

/* --- Стили для "водопада" цены в заказе --- */
.price-waterfall li {
    display: flex;
    justify-content: space-between;
}
.price-waterfall li span:first-child {
    color: var(--color-text-secondary);
    padding-right: 10px;
}

/* ==============================================
   МОБИЛЬНЫЙ ВИД (КОМПАКТНЫЙ + ПОЛНОЕ НАЗВАНИЕ)
   ============================================== */

@media (max-width: 767.98px) {

    /* 1. Внешний вид карточки */
    .product-card {
        height: 100%; /* Гарантирует растягивание на всю высоту колонки */
    }

    /* 2. Картинка: уменьшаем отступы */
    .product-image-wrapper {
        padding: 4px; /* Минимальный отступ */
        border-radius: var(--border-radius-main) var(--border-radius-main) 0 0;
    }

    /* Бейджи скидок делаем крошечными */
    .discount-badge {
        font-size: 0.65rem;
        padding: 2px 4px;
        bottom: 4px;
        right: 4px;
    }
    .personal-badge {
        left: 4px;
    }

    /* 3. Тело карточки: всё лишнее убрать */
    .product-card .card-body {
        padding: 8px; /* Компактные отступы внутри */
        flex-grow: 1; /* ЭТО ГЛАВНОЕ: заставляет body занять всё свободное место, толкая футер вниз */
    }

    /* 4. Название товара: ПОЛНОЕ, но мелкое */
    .card-body .card-title {
        margin-bottom: 4px;
        min-height: 0; /* Сбрасываем фикс. высоту */
        height: auto;  /* Высота по контенту */
    }

    .card-body .card-title a {
        font-size: 0.75rem; /* 12px шрифт */
        line-height: 1.2;
        font-weight: 500;
        /* Никакого line-clamp, текст течет полностью */
    }

    /* 5. Характеристики (Артикул, РРЦ, Наличие) */
    .card-text {
        display: none !important; /* Артикул можно скрыть на телефоне для экономии, или оставить */
    }

    .list-unstyled.small {
        font-size: 0.65rem; /* Очень мелкий шрифт для тех. данных */
        margin-top: 4px !important;
        line-height: 1.2;
        margin-bottom: 0; /* Убираем отступ снизу */
    }
    .list-unstyled.small li {
        margin-bottom: 1px;
    }

    /* 6. Футер (Цена и Кнопки) */
    .product-card .card-footer {
        padding: 8px;
        background: none;
        border-top: 1px solid rgba(0,0,0,0.05);
    }

    /* Цена */
    .product-card .product-price {
        font-size: 0.9rem; /* 14-15px */
        margin-bottom: 6px;
    }
    .product-card .product-price .text-decoration-line-through {
        font-size: 0.7rem !important;
    }

    /* 7. Ультра-тонкие кнопки управления */
    .add-to-cart-form {
        gap: 4px !important;
    }

    /* Степпер (+ 1 -) */
    .quantity-stepper {
        height: 26px; /* Фиксированная высота */
    }
    .quantity-stepper .btn {
        flex: 0 0 28px;
        font-size: 0.9rem; /* Мелкие плюсики */
        line-height: 1;
        padding: 0;
        height: 100%;
    }
    .quantity-stepper .product-quantity-input {
        height: 100%;
        font-size: 0.8rem;
        padding: 0;
    }

    /* Кнопка Купить */
    .add-to-cart-form .btn {
        font-size: 0.75rem; /* 12px */
        padding: 0;
        height: 28px; /* Тонкая кнопка */
        line-height: 26px;
        width: 100%;
    }

    /* Сообщение "Добавлено" */
    .cart-success-message {
        font-size: 0.6rem;
        margin-top: 2px !important;
        text-align: center;
    }
}

.rrc-badge {
    position: absolute;
    top: 6px;      /* Небольшой отступ сверху */
    left: 6px;     /* Слева */
    background-color: rgba(50, 50, 50, 0.85);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.65rem; /* Очень компактный шрифт */
    font-weight: 600;
    z-index: 5;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); /* Легкая тень для читаемости */
}

/* 2. Десктопные иконки */
.nav-icon-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
    min-width: 60px;
}
.nav-icon-link:hover {
    background-color: #f8f9fa;
    text-decoration: none;
    color: var(--color-primary) !important;
}
.nav-icon-link i {
    margin-bottom: 2px;
}

/* 3. МОБИЛЬНАЯ НИЖНЯЯ ПАНЕЛЬ (TAB BAR) */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px; /* Стандартная высота таббара */
    background: #ffffff;
    box-shadow: 0 -1px 10px rgba(0,0,0,0.05);
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1040; /* Ниже модалок (1050), но выше контента */
    padding-bottom: env(safe-area-inset-bottom); /* Для iPhone X+ */
}

.mobile-bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #868e96; /* Серый неактивный */
    height: 100%;
    font-size: 1.5rem; /* Иконки */
}

.mobile-bottom-nav .nav-item span {
    font-size: 0.65rem; /* Подписи */
    font-weight: 500;
    margin-top: 2px;
}

.mobile-bottom-nav .nav-item.active {
    color: var(--color-primary); /* Синий активный */
}

.mobile-bottom-nav .nav-item:active {
    transform: scale(0.95); /* Эффект нажатия */
}

/* 4. Бейджи уведомлений */
.badge.rounded-circle {
    min-width: 10px;
    min-height: 10px;
}

/* Скрываем мобильные блоки на ПК и наоборот - это уже делает Bootstrap (d-lg-none),
   но убедитесь, что bottom-nav скрыт на широких экранах */
@media (min-width: 992px) {
    .mobile-bottom-nav { display: none !important; }
}

#search-results-container {
    top: 50px; /* Отступ от инпута */
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    border: none;
    z-index: 1100;
}
/* ==============================================
   LMS MOBILE OPTIMIZATION (Добавить в конец CSS)
   ============================================== */

@media (max-width: 991.98px) {
    body.has-bottom-panel {
        padding-bottom: calc(140px + env(safe-area-inset-bottom)) !important;
    }

    body.has-no-bottom-panel {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }

    /* 1. Глобальные отступы и шрифты */
    h1.h3, h1.display-6 {
        font-size: 1.5rem; /* Уменьшаем заголовки */
        margin-bottom: 1rem !important;
    }

    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* 2. Скрываем хлебные крошки на мобильном, они занимают место */
    nav[aria-label="breadcrumb"] {
        display: none;
    }

    /* 3. Оптимизация страницы УРОКА (lesson.html) */
    .video-container {
        margin-bottom: 1rem;
        box-shadow: none; /* Убираем тяжелые тени */
        border-radius: 8px;
    }

    .lesson-content {
        font-size: 1rem;
        line-height: 1.6;
        margin-bottom: 2rem !important; /* Уменьшаем отступ до кнопок */
    }

    /* Делаем кнопки навигации (Назад/Дальше) фиксированными внизу экрана */
    .d-flex.justify-content-between.border-top {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;

        /* Меняем padding, добавляя safe-area вниз */
        padding: 10px 15px calc(10px + env(safe-area-inset-bottom)) 15px;

        z-index: 1030;
        border-top: 1px solid #dee2e6 !important;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.05);
        display: flex;
        gap: 10px;
    }

    /* Кнопки в нижней панели делаем компактнее */
    .d-flex.justify-content-between.border-top .btn {
        flex: 1; /* Растягиваем кнопки равномерно */
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    /* 4. Сайдбар "Содержание курса" на мобильном */
    .col-lg-4 .card {
        border-radius: 0; /* Убираем скругление */
        margin-left: -12px; /* Растягиваем на всю ширину */
        margin-right: -12px;
        box-shadow: none !important;
        border-top: 1px solid #eee !important;
        margin-top: 0 !important;
    }

    .col-lg-4 .card-header {
        background-color: #f8f9fa !important;
        padding: 1rem;
    }

    /* 5. Страница СПИСКА КУРСОВ (index.html) */

    /* Таблицы-вкладки (Learning Tabs) делаем со скроллом, а не переносом */
    .learning-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 5px;
        background: transparent;
        margin-bottom: 1rem !important;
        /* Скрываем скроллбар */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .learning-tabs::-webkit-scrollbar {
        display: none;
    }

    .learning-tabs .nav-link {
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        background: #fff;
        border: 1px solid #eee;
        margin-right: 8px;
    }
    .learning-tabs .nav-link.active {
        background: var(--color-primary);
        color: #fff;
        border-color: var(--color-primary);
    }

    /* Фильтры брендов */
    .brand-filter-btn {
        padding: 0.3rem 0.8rem;
        font-size: 0.8rem;
    }

    /* Карточки курсов более компактные */
    .card-body.p-4 {
        padding: 1rem !important;
    }
}