/* =========================================
   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: 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); }
#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; }

/* Контейнер для плашек справа */
#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. СТИЛИ 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; }

/* ================================================================ */
/* === СКРЫВАЕМ ЛИШНИЕ ТЕКСТЫ И КАТЕГОРИИ В ВЫБОРЕ ЦВЕТА (ШКАФЫ) === */
/* ================================================================ */
.clothes_category .heading2, #factory_choice_popup .heading2, #factory_choice_popup .clothes_category .heading2 { display: none !important; }
.clothes_category .tkanp, #factory_choice_popup .tkanp, #factory_choice_popup .clothes_category .tkanp { display: none !important; }
.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; }

/* ================================================================= */
/* === ФИКС ВЫСОТЫ КАРТОЧЕК ТКАНЕЙ (Одинаковый размер оверлея) === */
/* ================================================================= */
#factory_choice_popup .list li {
    height: 120px !important;       
    vertical-align: top !important; 
    display: inline-block !important;
    float: none !important;
    margin-bottom: 0px !important;
    overflow: hidden !important;    
}
#factory_choice_popup .list li a {
    display: block !important; width: 100% !important; height: 100% !important; position: relative !important; text-decoration: none !important;
}
#factory_choice_popup .list li a:before { height: 100% !important; bottom: 0 !important; top: 0 !important; }
#factory_choice_popup .list li img { max-height: 100px !important; object-fit: contain !important; margin-bottom: 5px !important; }


/* =========================================
   6. АДАПТИВ И ФИКС ОКНА ДЛЯ ТЕЛЕФОНОВ
   ========================================= */
@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; padding: 15px; }

    /* ЖЕСТКАЯ ФИКСАЦИЯ ОКНА КОНФИГУРАТОРА СТРОГО ПОД ШАПКОЙ */
    #config_modal_window {
        position: fixed !important;
        top: 60px !important; /* Упирается ровно в низ мобильной шапки */
        left: 0 !important;
        transform: none !important; /* Отменяем центрирование по осям */
        width: 100% !important;
        max-width: 100% !important;
        height: calc(100% - 60px) !important;
        max-height: calc(100% - 60px) !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    #config_modal_body {
        padding-bottom: 75px !important; /* Даем место под подвал, чтобы опции не прятались за кнопкой */
    }

    /* ПОДВАЛ ВСЕГДА ВНИЗУ ЭКРАНА */
    #config_modal_footer {
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        z-index: 10;
        box-shadow: 0 -4px 10px rgba(0,0,0,0.1); /* Легкая тень сверху */
    }
}