/* ============================================================
   ГЛОБАЛЬНЫЕ СТИЛИ
   ============================================================ */
* {
    box-sizing: border-box;
}

body {
    background-color: #ffffff;
    color: #2d2d2d;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 1.05rem;
    line-height: 1.6;
}

a {
    color: #2d2d2d;
    transition: color 0.2s ease;
}

a:hover {
    color: #555555;
    text-decoration: none;
}

/* ===== ШАПКА (умеренная) ===== */
header {
    background-color: #2d2d2d !important;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 15px 0 !important;
    /* высота шапки уменьшена */
}

/* ГРУППЫ В ШАПКЕ */
.header-group {
    display: flex;
    align-items: center;
}

.header-group-left {
    flex-shrink: 0;
    margin-right: 20px;
    /* отступ от центра */
}

.header-group-center {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 15px;
    min-width: 180px;
}

.header-group-right {
    flex-shrink: 0;
    margin-left: 20px;
    text-align: right;
}

/* Логотип */
header a img {
    max-height: 60px;
    width: auto;
}

/* Кнопки в шапке */
header .btn-outline-light {
    border-color: #ffffff;
    color: #ffffff;
    font-size: 0.85rem !important;
    padding: 4px 14px !important;
    border-radius: 30px;
    transition: all 0.2s ease;
}

header .btn-outline-light:hover {
    background-color: #ffffff;
    color: #2d2d2d;
    transform: scale(1.03);
}

/* Поле поиска */
header .form-control {
    height: 38px;
    font-size: 0.95rem;
    border-radius: 30px 0 0 30px !important;
}

header .btn-outline-light[type="submit"] {
    height: 38px;
    border-radius: 0 30px 30px 0 !important;
    padding: 0 16px;
    font-size: 0.95rem;
}

/* Корзина */
header a[href="/cart"] {
    font-size: 1.2rem;
    font-weight: 600;
}

header .badge {
    font-size: 0.9rem;
    padding: 4px 8px;
}

/* Адаптив */
@media (max-width: 992px) {
    header .d-flex {
        flex-direction: column;
        align-items: center !important;
        text-align: center;
    }

    .header-group-left,
    .header-group-right {
        margin: 0 !important;
        width: 100%;
        text-align: center !important;
        justify-content: center !important;
    }

    .header-group-center {
        margin: 8px 0 !important;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .header-group-center form {
        max-width: 100% !important;
        width: 100%;
    }

    header .btn-outline-light {
        font-size: 0.8rem !important;
        padding: 3px 10px !important;
    }

    header a img {
        height: 45px !important;
    }
}

@media (max-width: 576px) {
    header .form-control {
        height: 34px;
        font-size: 0.85rem;
    }

    header .btn-outline-light[type="submit"] {
        height: 34px;
        font-size: 0.85rem;
        padding: 0 12px;
    }
}

/* ============================================================
   КОНТЕЙНЕР (широкий)
   ============================================================ */
.container,
header .container,
footer .container,
nav .container {
    max-width: 1600px !important;
    width: 95% !important;
    padding-left: 30px !important;
    padding-right: 30px !important;
}

/* ============================================================
   КАРТОЧКИ ТОВАРОВ
   ============================================================ */
.card {
    border: none;
    border-radius: 12px;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
    animation: fadeUp 0.5s ease forwards;
    opacity: 0;
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.card-img-top {
    border-radius: 12px 12px 0 0;
    transition: transform 0.3s ease;
}

.card:hover .card-img-top {
    transform: scale(1.02);
}

.card-body {
    padding: 1.25rem;
}

.card-title {
    font-weight: 600;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: #2d2d2d;
}

.card-text {
    color: #555555;
    font-size: 0.95rem;
}

/* Оранжевая обводка карточек */
.product-card {
    border: 1px solid #ff8c00 !important;
    border-radius: 12px;
    transition: all 0.25s ease;
}

.product-card:hover {
    border-color: #e67e22 !important;
    box-shadow: 0 8px 20px rgba(255, 140, 0, 0.15);
}

/* Серый прямоугольник для названия товара в карточке */
.product-card .card-header {
    background-color: #cccbcb !important;
    border-bottom: 1px solid #e0e0e0;
    border-radius: 12px 12px 0 0;
    padding: 10px 15px;
}

.product-card .card-title {
    margin: 0;
}

/* Анимация появления */
@keyframes fadeUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.card:nth-child(1) {
    animation-delay: 0.05s;
}

.card:nth-child(2) {
    animation-delay: 0.10s;
}

.card:nth-child(3) {
    animation-delay: 0.15s;
}

.card:nth-child(4) {
    animation-delay: 0.20s;
}

.card:nth-child(5) {
    animation-delay: 0.25s;
}

.card:nth-child(6) {
    animation-delay: 0.30s;
}

/* ============================================================
   КНОПКИ (общие)
   ============================================================ */
.btn {
    border-radius: 30px;
    padding: 0.4rem 1.2rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: #2d2d2d;
    border-color: #2d2d2d;
}

.btn-primary:hover {
    background-color: #1a1a1a;
    border-color: #1a1a1a;
    transform: scale(0.97);
}

.btn-success {
    background-color: #3a3a3a;
    border-color: #3a3a3a;
}

.btn-success:hover {
    background-color: #2a2a2a;
    border-color: #2a2a2a;
    transform: scale(0.97);
}

.btn-outline-primary {
    color: #2d2d2d;
    border-color: #2d2d2d;
}

.btn-outline-primary:hover {
    background-color: #2d2d2d;
    border-color: #2d2d2d;
    color: #ffffff;
}

/* ============================================================
   КАТЕГОРИИ (левая колонка + горизонтальное меню)
   ============================================================ */
/* Левая колонка – список категорий (подкатегории) */
.list-group-item {
    background-color: #bfbebe !important;
    border: 1px solid #c4c4c4 !important;
    border-radius: 30px !important;
    padding: 0 !important;
    margin-bottom: 6px;
    transition: background-color 0.2s, border-color 0.2s;
}

.list-group-item a {
    display: block;
    padding: 8px 18px;
    border-radius: 30px;
    color: #fcfbfb;
    text-decoration: none;
}

.list-group-item.active {
    background-color: #ff8c00 !important;
    border-color: #ff8c00 !important;
}

.list-group-item.active a {
    color: #ffffff !important;
}

.list-group-item:not(.active):hover {
    background-color: #989898 !important;
    border-color: #919191 !important;
}

/* Горизонтальные кнопки главных категорий (nav-pills) */
.nav-pills {
    background-color: transparent !important;
    padding: 10px 0 !important;
}

.nav-pills .nav-link {
    background-color: #ffffff !important;
    color: #dc3545 !important;
    border: 1px solid #ced4da !important;
    border-radius: 30px !important;
    padding: 0.3rem 1rem !important;
    margin: 0 4px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-pills .nav-link:hover {
    background-color: #ffffff !important;
    color: #a71d2a !important;
    border-color: #adb5bd !important;
}

.nav-pills .nav-link.active {
    background-color: #ffffff !important;
    color: #000000 !important;
    border-color: #ced4da !important;
    font-weight: 600;
}

.nav-pills .nav-link:focus {
    box-shadow: none;
}

/* ============================================================
   МОДАЛЬНЫЕ ОКНА
   ============================================================ */
.modal-content {
    border-radius: 20px;
    border: none;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    border-bottom: 1px solid #eeeeee;
    background-color: #fafafa;
    border-radius: 20px 20px 0 0;
}

.modal-footer {
    border-top: 1px solid #eeeeee;
    background-color: #fafafa;
    border-radius: 0 0 20px 20px;
}

.modal-title {
    font-weight: 600;
    color: #2d2d2d;
}

/* Широкая модалка (почти на весь экран) */
.modal-fullscreen .modal-dialog {
    max-width: 95vw !important;
    width: 95vw !important;
    margin: 1.75rem auto !important;
}

.modal-fullscreen .modal-content {
    border-radius: 20px;
}

.modal-fullscreen .modal-body {
    padding: 2rem 3rem;
}

.modal-fullscreen .col-md-5,
.modal-fullscreen .col-md-7 {
    padding: 0 20px;
}

.modal-fullscreen .col-md-7 {
    flex: 0 0 55%;
    max-width: 55%;
}

/* Карусель внутри модалки */
.carousel-item img {
    max-height: 60vh !important;
    object-fit: contain;
    width: 100%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.carousel-item img:hover {
    transform: scale(1.02);
}

.carousel-control-prev,
.carousel-control-next {
    width: 50px;
    height: 50px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.carousel-control-prev {
    left: -15px;
}

.carousel-control-next {
    right: -15px;
}

.carousel-control-prev:hover,
.carousel-control-next:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.6);
}

.carousel-control-prev-icon,
.carousel-control-next-icon {
    width: 30px;
    height: 30px;
}

/* ============================================================
   ЛАЙТБОКС (увеличенная картинка)
   ============================================================ */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
    opacity: 1;
}

.lightbox-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.lightbox-overlay.active img {
    transform: scale(1);
}

/* ============================================================
   КОММЕНТАРИИ
   ============================================================ */
.comment-item {
    border-bottom: 1px solid #eeeeee;
    padding: 10px 0;
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-item strong {
    color: #2d2d2d;
}

.comment-item .text-muted {
    color: #888888 !important;
}

/* ============================================================
   РЕЙТИНГ (звёзды)
   ============================================================ */
.star-rating {
    display: inline-block;
    direction: rtl;
    font-size: 24px;
    unicode-bidi: bidi-override;
}

.star-rating input {
    display: none;
}

.star-rating label {
    color: #ccc;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s ease;
}

.star-rating label:hover,
.star-rating label:hover~label,
.star-rating input:checked~label {
    color: #f5c300;
}

.stars {
    font-size: 22px;
    color: #f5c300;
}

.rating-text {
    font-size: 14px;
    color: #888888;
    margin-left: 5px;
}

/* ============================================================
   ЧАТ
   ============================================================ */
#chatHistory {
    background-color: #f9f9f9;
    border-radius: 12px;
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
}

.message-item {
    margin-bottom: 8px;
}

.message-item .d-inline-block {
    word-wrap: break-word;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

/* Кнопка чата (фиксированная) */
#chatButton .btn {
    box-shadow: 0 4px 12px rgba(45, 45, 45, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chatButton .btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 20px rgba(45, 45, 45, 0.3);
}

/* ============================================================
   АДАПТИВНОСТЬ
   ============================================================ */
@media (max-width: 992px) {
    header .d-flex {
        flex-direction: column;
        align-items: center !important;
        text-align: center;
    }

    header div[style*="flex: 0 0 auto"] {
        min-width: unset;
        width: 100%;
        text-align: center !important;
    }

    header div[style*="flex: 1 1 auto"] {
        max-width: 100%;
        flex-direction: column;
        gap: 10px;
    }

    header .btn-outline-light {
        font-size: 0.9rem !important;
        padding: 4px 14px !important;
    }

    header a[href="/cart"] {
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .card {
        margin-bottom: 20px;
    }

    .list-group-item a {
        padding: 6px 12px;
    }
}

@media (max-width: 576px) {
    header .form-control {
        height: 40px;
        font-size: 0.95rem;
    }

    header .btn-outline-light[type="submit"] {
        height: 40px;
        font-size: 0.95rem;
        padding: 0 15px;
    }

    header a img {
        height: 60px !important;
    }
}

/* ============================================================
   ДОПОЛНИТЕЛЬНО: Сетка карточек (3 колонки с большими отступами)
   ============================================================ */
@media (min-width: 992px) {
    .col-md-4 {
        flex: 0 0 33.3333%;
        max-width: 33.3333%;
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* ===== Миниатюры под каруселью ===== */
.thumbnail-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.thumbnail-row img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.thumbnail-row img:hover {
    transform: scale(1.08);
    border-color: #ff8c00;
    box-shadow: 0 2px 8px rgba(255, 140, 0, 0.3);
}

.thumbnail-row img.active-thumb {
    border-color: #ff8c00;
    box-shadow: 0 0 0 2px #ff8c00;
}

/* ===== УМЕНЬШАЕМ МОДАЛКУ ТОВАРА (более узкая) ===== */
.modal-fullscreen .modal-dialog {
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
}

.modal-fullscreen .modal-body {
    padding: 1.5rem 2rem !important;
}

.modal-fullscreen .carousel-item img {
    max-height: 50vh !important;
}

.thumbnail-row img {
    width: 60px !important;
    height: 60px !important;
}

.modal-fullscreen .col-md-5,
.modal-fullscreen .col-md-7 {
    padding: 0 15px !important;
}

.modal-fullscreen .col-md-7 {
    flex: 0 0 50% !important;
    max-width: 50% !important;
}

/* И немного уменьшаем миниатюры, если они есть */
.thumbnail-row img {
    width: 60px !important;
    /* было 70px */
    height: 60px !important;
    /* было 70px */
}

/* Уменьшаем отступы внутри правой колонки */
.modal-fullscreen .col-md-5,
.modal-fullscreen .col-md-7 {
    padding: 0 15px !important;
    /* было 0 20px */
}

.modal-fullscreen .col-md-7 {
    flex: 0 0 50% !important;
    /* было 55% */
    max-width: 50% !important;
}

.comment-item.highlight {
    background-color: #fff3cd;
    transition: background-color 0.5s;
}

/* ============================================================
   АДАПТИВ ДЛЯ МОБИЛЬНЫХ (ДОПОЛНИТЕЛЬНЫЙ)
   ============================================================ */

/* Планшеты и маленькие ноутбуки */
@media (max-width: 992px) {
    header {
        padding: 10px 0 !important;
    }

    .header-group-left {
        margin-right: 10px;
    }

    .header-group-right {
        margin-left: 10px;
    }

    .header-group-center {
        margin: 0 8px;
        gap: 8px;
    }

    header a img {
        max-height: 40px;
    }

    header .btn-outline-light {
        font-size: 0.75rem !important;
        padding: 3px 10px !important;
    }

    header .form-control {
        height: 34px;
        font-size: 0.85rem;
    }

    header .btn-outline-light[type="submit"] {
        height: 34px;
        font-size: 0.85rem;
        padding: 0 12px;
    }

    header a[href="/cart"] {
        font-size: 1rem;
    }

    header .badge {
        font-size: 0.75rem;
        padding: 2px 6px;
    }

}

/* Телефоны (ширина до 576px) */
@media (max-width: 576px) {

    /* ----- Показываем верхнюю серую полосу ----- */
    div[style*="background-color: #f0f0f0"] {
        display: block !important;
        font-size: 0.65rem !important;
        padding: 3px 0 !important;
    }

    /* ----- Шапка ----- */
    header {
        padding: 6px 0 !important;
    }

    header a img {
        max-height: 30px !important;
    }

    .header-group-left {
        margin-right: 0 !important;
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    /* ----- Поиск: горизонтально, кнопка короче ----- */
    .header-group-center {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 4px !important;
        margin: 4px 0 !important;
        width: 100%;
    }

    .header-group-center form {
        flex-direction: row !important;
        gap: 4px !important;
        max-width: 70% !important;
        width: auto !important;
        margin: 0 !important;
        flex: 0 1 auto;
    }

    .header-group-center form .form-control {
        height: 28px !important;
        font-size: 0.7rem !important;
        padding: 2px 10px !important;
        border-radius: 30px 0 0 30px !important;
        width: 100% !important;
        flex: 1 1 auto;
    }

    .header-group-center form .btn-outline-light[type="submit"] {
        height: 28px !important;
        font-size: 0.65rem !important;
        padding: 0 8px !important;
        border-radius: 0 30px 30px 0 !important;
        width: auto !important;
        flex: 0 0 auto;
        white-space: nowrap;
        max-width: 60px !important;
    }

    /* ----- Правая группа: корзина и кнопки в строку, чуть крупнее ----- */
    .header-group-right {
        margin-left: 0 !important;
        width: 100%;
        justify-content: center;
        flex-wrap: nowrap !important;
        gap: 6px !important;
        display: flex !important;
        align-items: center !important;
    }

    .header-group-right a[href="/cart"] {
        font-size: 0.9rem !important;
        margin-right: 4px !important;
    }

    .header-group-right .badge {
        font-size: 0.7rem !important;
        padding: 2px 5px !important;
    }

    .header-group-right .btn-outline-light {
        font-size: 0.75rem !important;
        padding: 3px 10px !important;
        white-space: nowrap !important;
    }

    .header-group-right .position-relative .badge {
        font-size: 0.5rem !important;
        padding: 1px 4px !important;
        top: -4px !important;
        right: -4px !important;
    }

    /* ----- Карточки товаров (2 колонки) ----- */
    .col-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    .product-card .card-header {
        padding: 4px 6px !important;
    }

    .product-card .card-title {
        font-size: 0.8rem !important;
    }

    .product-card .card-img-top {
        height: 100px !important;
    }

    .product-card .card-body {
        padding: 6px !important;
    }

    .product-card .card-text {
        font-size: 0.7rem !important;
        margin-bottom: 2px !important;
    }

    .product-card .card-text strong {
        font-size: 0.8rem !important;
    }

    .product-card .btn {
        font-size: 0.6rem !important;
        padding: 2px 6px !important;
    }

    /* ----- Подкатегории (левая колонка) ----- */
    .col-md-3 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 8px;
    }

    .list-group-item {
        padding: 0 !important;
        margin-bottom: 3px !important;
        border-radius: 16px !important;
    }

    .list-group-item a {
        padding: 3px 10px !important;
        font-size: 0.7rem !important;
    }

    /* ----- Правая колонка (товары) ----- */
    .col-md-9 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* ----- МОДАЛКА: растягиваем на всю ширину, убираем все отступы ----- */
    .modal {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin: 0 !important;
    }

    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .modal-content {
        border-radius: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .modal-body {
        padding: 0.5rem 0.8rem !important;
    }

    .modal-header,
    .modal-footer {
        padding-left: 0.8rem !important;
        padding-right: 0.8rem !important;
    }

    .modal-fullscreen .carousel-item img {
        max-height: 25vh !important;
    }

    .thumbnail-row img {
        width: 35px !important;
        height: 35px !important;
    }

    .modal-fullscreen .col-md-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding: 0 6px !important;
    }

    .modal-fullscreen .col-md-6+.col-md-6 {
        margin-top: 8px;
    }

    .modal-fullscreen .modal-title {
        font-size: 0.9rem;
    }

    .modal-fullscreen .btn {
        font-size: 0.7rem !important;
        padding: 2px 10px !important;
    }

    /* Чтобы текст не вылезал за белый фон */
    .modal-fullscreen .product-info p,
    .modal-fullscreen .modal-body p,
    .modal-fullscreen .comment-item p {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* ----- Горизонтальные кнопки категорий ----- */
    .nav-pills .nav-link {
        font-size: 0.6rem !important;
        padding: 0.1rem 0.4rem !important;
        margin: 0 2px !important;
    }

    /* ----- Общие отступы контейнера ----- */
    .container {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    /* ----- Карточки: убираем лишний отступ между рядами ----- */
    .mb-4 {
        margin-bottom: 10px !important;
    }
}