/* =========================================
   1. Z-INDEX И БАЗОВЫЕ СТИЛИ ОКНА
   ========================================= */
#config_modal_overlay {
    display: none; 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.7); 
    z-index: 9000 !important;
}

#config_modal_window {
    display: none; 
    position: fixed; 
    top: 50%; left: 50%; 
    transform: translate(-50%, -50%); 
    width: 95% !important; 
    max-width: 1400px !important; 
    height: 90vh !important;
    background: #fff; 
    z-index: 9001 !important; 
    border-radius: 5px; 
    overflow: hidden; 
    flex-direction: column;
}

#popup_cloth, .popup_window, #fancybox-wrap, #fancybox-overlay {
    z-index: 10000 !important;
}

#config_modal_body {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto;
    overflow: hidden !important;
}

/* =========================================
   2. ЕДИНЫЙ СТИЛЬ КНОПОК ЗАПУСКА (ДИВАН И ШКАФ)
   ========================================= */
.start_configurator_divan,
.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_divan:hover,
.start_configurator_shkaf:hover {
    background-color: #d76a19 !important;
    color: #fff !important;
}

/* =========================================
   3. ШАПКА И ПОДВАЛ МОДАЛЬНОГО ОКНА
   ========================================= */
#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; color: #888;
}
#config_modal_footer {
    padding: 15px 20px; border-top: 1px solid #ddd; background: #f9f9f9; text-align: right; display: flex; justify-content: flex-end; align-items: center; flex: 0 0 auto;
}
.total-price-block { font-size: 20px; font-weight: bold; margin-right: 20px; }
.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;
}

/* =========================================
   4. ОСНОВНОЙ КОНТЕНТ (РАЗМЕТКА КОЛОНОК)
   ========================================= */
#config_main_content {
    display: flex !important; flex-direction: row !important; flex: 1 1 auto !important; overflow: hidden !important; width: 100%;
}
#config_col_left {
    flex: 0 0 320px !important; border-right: 1px solid #eee; background: #fdfdfd; overflow-y: auto; padding: 20px;
}
#config_col_right {
    flex: 1 !important; background: #fff; overflow-y: auto; padding: 20px;
}
.config-col-title {
    font-size: 16px; font-weight: bold; margin-bottom: 15px; text-transform: uppercase; color: #333; border-bottom: 2px solid #ddd; padding-bottom: 5px;
}

/* =========================================
   5. ВЕРХНЯЯ ПАНЕЛЬ "ВЫБОР ТКАНИ И ЦВЕТ ПО ФОТО"
   ========================================= */
#config_fabric_mirror {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Разносим по краям */
    background: #fff;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
    flex: 0 0 auto;
}

/* Группа кнопок слева */
.fabric-controls-left {
    display: flex;
    align-items: center;
    gap: 15px; /* Отступ между кнопкой ткани и "по фото" */
}

/* Кнопка "Выбрать ткань" */
.btn-config-select-fabric {
    background: #333;
    color: #fff;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background 0.2s;
}
.btn-config-select-fabric:hover { background: #555; }

/* Кнопка "Цвет по фото" (Стиль Мегафон) */
#color_by_photo_wrapper {
    cursor: pointer;
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 30px; /* Овальная форма */
    background: #fff;
    color: #666;
    font-size: 13px;
    font-weight: 500;
    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: #4fa3af;     /* Зеленый */
    border-color: #4fa3af;
    color: #fff;
    box-shadow: 0 3px 10px rgba(0, 185, 86, 0.3);
}

/* Инфо справа (Выбранные ткани) */
#config_fabric_info_mirror {
    display: flex;
    gap: 15px;
    font-size: 11px;
    text-align: right;
}

/* Стили элементов внутри зеркала */
#config_fabric_info_mirror li, 
#config_fabric_info_mirror td,
#config_fabric_info_mirror .mirror-stub {
    list-style: none; background: #f9f9f9; border: 1px solid #ddd; 
    padding: 5px 10px; border-radius: 4px; display: flex; align-items: center; 
    gap: 10px; margin: 0; min-height: 40px;
}

/* Картинка ткани */
#config_fabric_info_mirror img { 
    max-height: 50px !important; 
    width: auto !important; 
    border-radius: 3px; 
    display: block; 
}

/* === АГРЕССИВНОЕ СКРЫТИЕ КРЕСТИКА === */
#config_fabric_info_mirror .delete,
#config_fabric_info_mirror .delete_cloth,
#config_fabric_info_mirror a.delete,
#config_fabric_info_mirror img[src*="delete"], /* Скрывает любую картинку с "delete" в имени */
#config_fabric_info_mirror img[src*="cross"],  /* Скрывает картинку с "cross" */
#config_fabric_info_mirror img[src*="remove"] { 
    display: none !important; 
}

/* Убираем любые границы/подчеркивания у ссылок */
#config_fabric_info_mirror a {
    border: none !important;
    text-decoration: none !important;
}


/* =========================================
   6. МОДУЛИ (УВЕЛИЧЕННЫЙ КОМПАКТНЫЙ ДИЗАЙН)
   ========================================= */
.modules-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Две колонки */
    gap: 12px;
    padding-bottom: 20px;
}

/* Карточка модуля */
.module-card {
    display: flex;              
    align-items: stretch;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    height: 115px;              /* УВЕЛИЧЕННАЯ высота */
    overflow: hidden;
    transition: all 0.2s;
}

.module-card:hover {
    border-color: #bbb;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.module-card.active {
    border: 2px solid #4fa3af; 
    background: #f4fcf7;
}

/* Фото слева (Квадрат) */
.mc-img {
    width: 110px;               /* УВЕЛИЧЕННАЯ ширина */
    min-width: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-right: 1px solid #f0f0f0;
}
.mc-img img {
    max-width: 90%;             
    max-height: 90%;
    object-fit: contain;
}

/* Инфо по центру */
.mc-info {
    flex-grow: 1;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}
.mc-name {
    font-weight: 700;
    font-size: 15px;            /* УВЕЛИЧЕННЫЙ шрифт */
    color: #000;
    margin-bottom: 6px;
    line-height: 1.2;
    white-space: normal; 
    max-height: 36px;
    overflow: hidden;
}
.mc-price {
    font-weight: 800;
    font-size: 17px;            /* УВЕЛИЧЕННАЯ цена */
    margin-bottom: 6px;
    color: #333;
}
.mc-dims {
    font-size: 12px;            /* УВЕЛИЧЕННЫЕ габариты */
    color: #555;
    line-height: 1.3;
}
.dim-group {
    margin-bottom: 2px;
}

/* Кнопка справа (Квадрат) */
.mc-btn {
    width: 70px; 
    min-width: 70px;
    background: #f8f8f8;
    color: #777;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: bold;
    border-left: 1px solid #eee;
    transition: all 0.2s;
    text-align: center;
}

.module-card:hover .mc-btn {
    background: #eee;
    color: #333;
}

/* Активная кнопка (Галочка) */
.module-card.active .mc-btn {
    background: #4fa3af;
    color: #fff;
    font-size: 0; /* ВАЖНО: Скрываем текст "Выбрать", чтобы не распирал кнопку */
}
.module-card.active .mc-btn::after { 
    content: "✔"; 
    font-size: 28px; /* Большая галочка */
    display: block;
    line-height: 1;
}
/* Скрываем span внутри активной кнопки на всякий случай */
.module-card.active .mc-btn span { display: none; }


/* =========================================
   7. МОБИЛЬНАЯ АДАПТАЦИЯ
   ========================================= */
@media (max-width: 1023px) {
    #config_modal_window { width: 100% !important; height: 100% !important; max-width: none; border-radius: 0; }
    
    /* Шапка на мобильном */
    #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%; box-sizing: border-box; }
    #config_fabric_info_mirror { justify-content: space-between; }
    
    /* Контент в одну колонку */
    #config_main_content { flex-direction: column !important; }
    #config_col_left { flex: 0 0 auto !important; max-height: 200px; border-bottom: 5px solid #eee; border-right: none; }
    
    /* Модули в одну колонку */
    .modules-grid { grid-template-columns: 1fr; }
}

/* ================================================================= */
/* === ФИКС ВЫСОТЫ КАРТОЧЕК ТКАНЕЙ (Одинаковый размер оверлея) === */
/* ================================================================= */

/* 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;
}
