/* =========================================
   1. БАЗОВЫЕ СТИЛИ МОДАЛЬНОГО ОКНА
   ========================================= */
#config_modal_overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 9998;
}
#config_modal_window {
    display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 95%; max-width: 1400px;
    height: 90vh; background: #fff; z-index: 9999; border-radius: 5px; overflow: hidden;
    display: flex; flex-direction: column;
}
#config_modal_header {
    padding: 15px 20px; background: #f1f1f1; border-bottom: 1px solid #ddd; font-size: 18px; font-weight: bold; position: relative; flex: 0 0 auto;
}
#config_modal_close {
    position: absolute; right: 15px; top: 15px; cursor: pointer; font-size: 24px; line-height: 1; color: #888;
}
#config_modal_body {
    display: flex !important; flex-direction: column !important; flex: 1 1 auto; overflow: hidden !important; width: 100%; position: relative;
}
#config_modal_footer {
    padding: 15px 20px; border-top: 1px solid #ddd; background: #f9f9f9; text-align: right; flex: 0 0 auto;
}
.btn-apply-config {
    display: inline-block; padding: 12px 30px; background: #d03d33; color: #fff !important; text-decoration: none; font-weight: bold; font-size: 16px; border-radius: 3px; cursor: pointer;
}

/* =========================================
   2. КОЛОНКИ (50/50)
   ========================================= */
#config_main_content {
    display: flex !important; flex-direction: row !important; flex: 1 1 auto !important; overflow: hidden !important; width: 100%; height: 100%;
}
.config-col {
    padding: 20px; box-sizing: border-box;
}
#config_col_left {
    flex: 1; /* 50% */
    border-right: 1px solid #eee; background: #fdfdfd; overflow-y: auto;
}
#config_col_right {
    flex: 1; /* 50% */
    background: #fff; overflow-y: auto;
}
.config-col-title {
    font-size: 16px; font-weight: 800; text-transform: uppercase; margin-bottom: 15px; color: #333; border-bottom: 2px solid #f0f0f0; padding-bottom: 10px;
}

/* =========================================
   3. ВЕРХНЯЯ ПАНЕЛЬ (ТКАНИ И КНОПКИ)
   ========================================= */
#config_fabric_mirror {
    flex: 0 0 auto; width: 100%; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; background: #fff; padding: 15px 20px; border-bottom: 1px solid #eee; z-index: 10; margin-bottom: 0 !important;
}
.fabric-controls-left {
    display: flex; align-items: center; gap: 15px;
}

/* Кнопка "Выбрать цвет" */
.btn-config-select-fabric {
    background: #bd4832; color: #fff !important; padding: 10px 20px; border-radius: 4px; cursor: pointer; font-weight: bold; display: flex; align-items: center; gap: 10px; font-size: 15px; transition: background 0.2s; border: none; text-decoration: none !important;
}
.btn-config-select-fabric:hover { background: #a53b27; }
.btn-config-select-fabric .btn-text { color: #fff !important; }

/* Состояние "Выбрано" (Серая с галочкой) */
.btn-config-select-fabric.selected { background: #333333; }
.btn-config-select-fabric.selected .icon-palette { display: none; }
.btn-config-select-fabric.selected .icon-check { display: inline-block !important; color: #4fa3af; font-size: 18px; }

/* Кнопка "Цвет по фото" */
#color_by_photo_wrapper {
    cursor: pointer; padding: 9px 20px; border: 1px solid #ddd; border-radius: 30px; background: #fff; color: #666; font-size: 14px; font-weight: 400; transition: all 0.3s ease; user-select: none; display: flex; align-items: center;
}
#color_by_photo_wrapper:hover { border-color: #999; color: #333; }
#color_by_photo_wrapper.active { background: #fff; border: 1px solid #ddd; color: #333; }

/* Контейнер для плашек справа */
#config_fabric_info_mirror { display: flex; gap: 10px; }


/* =========================================
   4. ПЛАШКИ ВЫБРАННЫХ ТКАНЕЙ (ФИНАЛЬНЫЙ ВАРИАНТ)
   ========================================= */

/* Скрываем старый мусор от сайта */
#mirror_main, #mirror_companion { font-size: 0 !important; line-height: 0 !important; }
#mirror_main .del_cloth, #mirror_companion .del_cloth,
#mirror_main a, #mirror_companion a, #mirror_main i, #mirror_companion i { display: none !important; }

/* Сброс контейнера .val */
#mirror_main .val, #mirror_companion .val {
    padding: 0 !important; margin: 0 !important; border: none !important;
    background: none !important; width: 100% !important; box-sizing: border-box !important;
}

/* --- ВЕРСТКА ЗАПОЛНЕННОЙ ПЛАШКИ --- */
.conf-fabric-row {
    display: flex !important;
    align-items: flex-start !important;
    width: auto !important; 
    max-width: 170px !important; /* Общее ограничение ширины всей плашки */
    padding: 2px 0;
    overflow: hidden;
}

/* Картинка */
.conf-fabric-row img {
    width: 42px !important;
    height: 42px !important;
    object-fit: cover !important;
    border: 1px solid #ccc;
    border-radius: 3px;
    margin-right: 8px !important;
    flex-shrink: 0;
    display: block !important;
    margin-top: 2px; /* Чуть опустим для выравнивания */
}

/* Блок описания (ЖЕСТКО 4 СТРОКИ, БЕЗ ТРОЕТОЧИЙ) */
.conf-fabric-desc {
    flex: none !important;       
    width: 110px !important;     /* Жесткая ширина текста */
    
    font-size: 10px !important;
    line-height: 1.1 !important;
    color: #333;
    text-align: left;
    
    /* Ограничиваем высоту ровно под 4 строки */
    max-height: 46px;            
    overflow: hidden;            /* Просто режем всё, что ниже */
    
    white-space: normal !important;
}

/* Заголовки (Основной/Компаньон) */
.conf-fabric-label {
    color: #999;
    font-size: 9px !important;
    display: block;
    margin-bottom: 2px;
    line-height: 1 !important;
    text-transform: uppercase;
}

/* Название ткани */
.conf-fabric-name {
    font-weight: bold;
    display: inline; /* Чтобы текст шел потоком */
}

/* --- ВЕРСТКА ПУСТОЙ ПЛАШКИ (КАК В ДИВАНАХ) --- */
.conf-fabric-empty {
    text-align: left; 
    padding: 5px 0; 
    color: #999; 
    font-size: 11px !important;
    line-height: 1.3 !important;
    width: 110px !important; /* Такая же ширина */
}
.conf-fabric-empty span { 
    display: block; 
    color: #333; 
    font-weight: bold; 
    font-size: 11px !important;
}


/* =========================================
   5. СТИЛИ SIMPLA И АДАПТИВ
   ========================================= */
.start_configurator_shkaf {
    display: block; width: 100%; padding: 15px 0; margin-top: 10px; margin-bottom: 10px; box-sizing: border-box;
    background-color: #fef5ec !important; border: 2px solid #d76a19 !important; color: #a74310 !important;
    font-size: 13px; font-weight: 800; text-transform: uppercase; text-align: center; cursor: pointer; border-radius: 4px; text-decoration: none; transition: all 0.2s ease;
}
.start_configurator_shkaf:hover { background-color: #d76a19 !important; color: #fff !important; }

#config_modal_body .razmselect { float: none !important; width: 100% !important; margin: 0 !important; padding: 0 !important; background: none !important; }
#config_modal_body .razmselect .sel { display: block !important; width: 100% !important; margin-bottom: 10px; }
#config_modal_body .razmselect select { width: 100% !important; height: 35px; border: 1px solid #ccc; }
#config_modal_body .clothes_list { display: block !important; width: 100% !important; border: none !important; }
#config_modal_body dt { text-align: left !important; width: auto !important; float: none !important; margin-top: 15px; font-weight: bold; }
#config_modal_body dd { margin-left: 0 !important; padding-left: 0 !important; border: none !important; }

@media (max-width: 1023px) {
    #config_fabric_mirror { flex-direction: column; align-items: stretch; gap: 10px; }
    .fabric-controls-left { flex-direction: column; width: 100%; }
    .btn-config-select-fabric, #color_by_photo_wrapper { justify-content: center; width: 100%; }
    #config_fabric_info_mirror { flex-direction: column; }
    #config_main_content { flex-direction: column !important; overflow-y: auto !important; }
    #config_col_left, #config_col_right { width: 100%; flex: none; height: auto; border-right: none; border-bottom: 5px solid #eee; }
}

/* --- СТИЛИ ДЛЯ КНОПКИ "ЦВЕТ ПО ФОТО" --- */

#color_by_photo_wrapper {
    cursor: pointer; 
    padding: 10px 20px; 
    border: 1px solid #ddd; 
    border-radius: 4px; /* Делаем квадратнее, как соседняя кнопка */
    background: #fff; 
    color: #666; 
    font-size: 14px; 
    font-weight: bold; 
    transition: all 0.2s ease; 
    user-select: none; 
    display: flex; 
    align-items: center;
    gap: 8px;
    height: 40px; /* Фикс высота, чтобы ровно с соседней */
    box-sizing: border-box;
}

#color_by_photo_wrapper:hover { 
    border-color: #999; 
    color: #333; 
}

/* АКТИВНОЕ СОСТОЯНИЕ (Как в диванах: темный фон, белый текст) */
#color_by_photo_wrapper.active {
    background: #333 !important; 
    border-color: #333 !important;
    color: #fff !important;
}

/* Галочка внутри кнопки (изначально скрыта) */
#color_by_photo_wrapper .icon-check {
    display: none;
    color: #81c784; /* Зеленый цвет галочки */
    font-size: 16px;
}

#color_by_photo_wrapper.active .icon-check {
    display: inline-block;
}

#color_by_photo_wrapper.active .icon-camera {
    display: none; /* Скрываем иконку камеры, когда выбрано */
}

/* =========================================
   1. БАЗОВЫЕ СТИЛИ МОДАЛЬНОГО ОКНА
   ========================================= */
#config_modal_overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 9998;
}
#config_modal_window {
    display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 95%; max-width: 1400px;
    height: 90vh; background: #fff; z-index: 9999; border-radius: 5px; overflow: hidden;
    display: flex; flex-direction: column;
}
#config_modal_header {
    padding: 15px 20px; background: #f1f1f1; border-bottom: 1px solid #ddd; font-size: 18px; font-weight: bold; position: relative; flex: 0 0 auto;
}
#config_modal_close {
    position: absolute; right: 15px; top: 15px; cursor: pointer; font-size: 24px; line-height: 1; color: #888;
}
#config_modal_body {
    display: flex !important; flex-direction: column !important; flex: 1 1 auto; overflow: hidden !important; width: 100%; position: relative;
}
#config_modal_footer {
    padding: 15px 20px; border-top: 1px solid #ddd; background: #f9f9f9; text-align: right; flex: 0 0 auto;
}
.btn-apply-config {
    display: inline-block; padding: 12px 30px; background: #d03d33; color: #fff !important; text-decoration: none; font-weight: bold; font-size: 16px; border-radius: 3px; cursor: pointer;
}

/* =========================================
   2. КОЛОНКИ (50/50)
   ========================================= */
#config_main_content {
    display: flex !important; flex-direction: row !important; flex: 1 1 auto !important; overflow: hidden !important; width: 100%; height: 100%;
}
.config-col {
    padding: 20px; box-sizing: border-box;
}
#config_col_left {
    flex: 1; border-right: 1px solid #eee; background: #fdfdfd; overflow-y: auto;
}
#config_col_right {
    flex: 1; background: #fff; overflow-y: auto;
}
.config-col-title {
    font-size: 16px; font-weight: 800; text-transform: uppercase; margin-bottom: 15px; color: #333; border-bottom: 2px solid #f0f0f0; padding-bottom: 10px;
}

/* =========================================
   3. ВЕРХНЯЯ ПАНЕЛЬ (ТКАНИ И КНОПКИ)
   ========================================= */
#config_fabric_mirror {
    flex: 0 0 auto; width: 100%; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; background: #fff; padding: 15px 20px; border-bottom: 1px solid #eee; z-index: 10; margin-bottom: 0 !important;
}
.fabric-controls-left {
    display: flex; align-items: center; gap: 15px;
}

/* Кнопка "Выбрать цвет" */
.btn-config-select-fabric {
    background: #bd4832; color: #fff !important; padding: 10px 20px; border-radius: 4px; cursor: pointer; font-weight: bold; display: flex; align-items: center; gap: 10px; font-size: 15px; transition: background 0.2s; border: none; text-decoration: none !important;
}
.btn-config-select-fabric:hover { background: #a53b27; }
.btn-config-select-fabric .btn-text { color: #fff !important; }

.btn-config-select-fabric.selected { background: #333333; }
.btn-config-select-fabric.selected .icon-palette { display: none; }
.btn-config-select-fabric.selected .icon-check { display: inline-block !important; color: #4fa3af; font-size: 18px; }

/* --- КНОПКА "ЦВЕТ ПО ФОТО" (ТОЧНО КАК В ДИВАНАХ) --- */
#color_by_photo_wrapper {
    cursor: pointer; 
    padding: 10px 25px; 
    border: 1px solid #ccc; 
    border-radius: 30px; /* Овальная */
    background: #fff; 
    color: #666; 
    font-size: 14px; 
    font-weight: 500; 
    transition: all 0.2s ease; 
    user-select: none; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    height: 42px; 
    box-sizing: border-box;
    white-space: nowrap;
}

#color_by_photo_wrapper:hover { 
    border-color: #999; 
    color: #333; 
}

/* Активное состояние (Зеленая) */
#color_by_photo_wrapper.active {
    background: #4fa3af !important;
    border-color: #4fa3af !important;
    color: #fff !important;
    box-shadow: 0 2px 5px rgba(0,185,86, 0.3);
}

/* Контейнер плашек справа */
#config_fabric_info_mirror { display: flex; gap: 10px; }


/* =========================================
   4. ПЛАШКИ ВЫБРАННЫХ ТКАНЕЙ
   ========================================= */
#mirror_main, #mirror_companion { font-size: 0 !important; line-height: 0 !important; }
#mirror_main .del_cloth, #mirror_companion .del_cloth,
#mirror_main a, #mirror_companion a, #mirror_main i, #mirror_companion i { display: none !important; }

#mirror_main .val, #mirror_companion .val {
    padding: 0 !important; margin: 0 !important; border: none !important;
    background: none !important; width: 100% !important; box-sizing: border-box !important;
}

.conf-fabric-row {
    display: flex !important; align-items: flex-start !important; width: auto !important; max-width: 170px !important; padding: 2px 0; overflow: hidden;
}

.conf-fabric-row img {
    width: 42px !important; height: 42px !important; object-fit: cover !important; border: 1px solid #ccc; border-radius: 3px; margin-right: 8px !important; flex-shrink: 0; display: block !important; margin-top: 2px;
}

.conf-fabric-desc {
    flex: none !important; width: 110px !important; font-size: 10px !important; line-height: 1.1 !important; color: #333; text-align: left; max-height: 46px; overflow: hidden; white-space: normal !important;
}

.conf-fabric-label {
    color: #999; font-size: 9px !important; display: block; margin-bottom: 2px; line-height: 1 !important; text-transform: uppercase;
}

.conf-fabric-name { font-weight: bold; display: inline; }

.conf-fabric-empty {
    text-align: left; padding: 5px 0; color: #999; font-size: 11px !important; line-height: 1.3 !important; width: 110px !important;
}
.conf-fabric-empty span { display: block; color: #333; font-weight: bold; font-size: 11px !important; }


/* =========================================
   5. АДАПТИВ
   ========================================= */
.start_configurator_shkaf {
    display: block; width: 100%; padding: 15px 0; margin-top: 10px; margin-bottom: 10px; box-sizing: border-box; background-color: #fef5ec !important; border: 2px solid #d76a19 !important; color: #a74310 !important; font-size: 13px; font-weight: 800; text-transform: uppercase; text-align: center; cursor: pointer; border-radius: 4px; text-decoration: none; transition: all 0.2s ease;
}
.start_configurator_shkaf:hover { background-color: #d76a19 !important; color: #fff !important; }

#config_modal_body .razmselect { float: none !important; width: 100% !important; margin: 0 !important; padding: 0 !important; background: none !important; }
#config_modal_body .razmselect .sel { display: block !important; width: 100% !important; margin-bottom: 10px; }
#config_modal_body .razmselect select { width: 100% !important; height: 35px; border: 1px solid #ccc; }
#config_modal_body .clothes_list { display: block !important; width: 100% !important; border: none !important; }
#config_modal_body dt { text-align: left !important; width: auto !important; float: none !important; margin-top: 15px; font-weight: bold; }
#config_modal_body dd { margin-left: 0 !important; padding-left: 0 !important; border: none !important; }

@media (max-width: 1023px) {
    #config_fabric_mirror { flex-direction: column; align-items: stretch; gap: 10px; }
    .fabric-controls-left { flex-direction: column; width: 100%; }
    .btn-config-select-fabric, #color_by_photo_wrapper { justify-content: center; width: 100%; }
    #config_fabric_info_mirror { flex-direction: column; }
    #config_main_content { flex-direction: column !important; overflow-y: auto !important; }
    #config_col_left, #config_col_right { width: 100%; flex: none; height: auto; border-right: none; border-bottom: 5px solid #eee; }
}

/* ================================================================ */
/* === СКРЫВАЕМ ЛИШНИЕ ТЕКСТЫ И КАТЕГОРИИ В ВЫБОРЕ ЦВЕТА (ШКАФЫ) === */
/* ================================================================ */

/* 1. Скрываем заголовок "Цены по категориям расцветок" (на странице и в окне) */
.clothes_category .heading2,
#factory_choice_popup .heading2,
#factory_choice_popup .clothes_category .heading2 {
    display: none !important;
}

/* 2. Скрываем текст-подсказку "Для выбора расцветки нажмите..." */
.clothes_category .tkanp,
#factory_choice_popup .tkanp,
#factory_choice_popup .clothes_category .tkanp {
    display: none !important;
}

/* 3. Скрываем саму строку со словом "Категория:" и кнопками (1, 2, 3...) */
/* На основной странице (подстраховка) */
.clothes_category_heading .tablecategory {
    display: none !important;
}

/* В самом всплывающем окне выбора тканей */
#factory_choice_popup .clothes_category table.clothes_category_heading tr:first-child,
#factory_choice_popup .clothes_category table.clothes_category_content tr:first-child {
    display: none !important;
}

/* ================================================================= */
/* === ФИКС ВЫСОТЫ КАРТОЧЕК ТКАНЕЙ (Одинаковый размер оверлея) === */
/* ================================================================= */

/* 1. Фиксируем высоту самой карточки (li) */
#factory_choice_popup .list li {
    /* Высота карточки: фото + 2 строки текста + отступы.
       Если оверлей слишком короткий - увеличьте это число (например, до 220px) */
    height: 120px !important;       
    
    vertical-align: top !important; /* Прижимаем к верху */
    display: inline-block !important;
    float: none !important;
    margin-bottom: 0px !important;
    overflow: hidden !important;    /* Обрезаем, если что-то торчит */
}

/* 2. Растягиваем ссылку (активную область) на всю высоту карточки */
#factory_choice_popup .list li a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;        /* Растягиваем на 210px */
    position: relative !important;  /* Чтобы оверлей позиционировался отсюда */
    text-decoration: none !important;
}

/* 3. Гарантируем, что затемнение (оверлей) покрывает 100% высоты */
#factory_choice_popup .list li a:before {
    height: 100% !important;
    bottom: 0 !important;
    top: 0 !important;
}

/* 4. Настройка картинки (чтобы она не прыгала) */
#factory_choice_popup .list li img {
    /* Если картинки разного размера, можно их унифицировать */
    max-height: 100px !important; 
    object-fit: contain !important;
    margin-bottom: 5px !important;
}