/* Переменные цветов */
:root {
    --primary: #FF5A00 !important;
    --primary-light: #FF7933 !important;
    --primary-lightest: #FFE5D9 !important;
    --neutral: #C1CCD3 !important;
    --neutral-light: #F5F7FA !important;
    --neutral-dark: #6C757D !important;
    --text-dark: #333333 !important;
    --text-light: #FFFFFF !important;
    --accent-green: #14AA3C !important;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1) !important;
    --shadow-md: 0 4px 6px rgba(0,0,0,0.15) !important;
    --border-radius: 8px !important;
}

/* Основные стили */
.tech-connection-calculator {
    max-width: 1600px;
    margin: 10px auto !important;
    padding: 12px !important;
    font-size: 15px !important;
    line-height: 1.4 !important;
    color: var(--text-dark);
    background: var(--neutral-light);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

/* Контейнеры таблиц */
#vls, #kls, #tps {
    position: relative;
    min-height: 100px;
    overflow: visible !important;
    z-index: 1;
}

/* Исправление для выпадающих списков Choices.js */
.choices__list--dropdown {
    z-index: 1000 !important;
    position: absolute !important;
    transform: none !important;
    max-height: 300px !important;
    overflow-y: auto !important;
}

.calc-section .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(550px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.input-group {
    padding: 15px;
    background: var(--text-light);
    border-radius: var(--border-radius);
    border: 1px solid var(--neutral);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

.input-group:hover {
    box-shadow: var(--shadow-md);
}

/* Кастомные радио-карточки */
.radio-group.card-radio {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.radio-card {
    flex: 1;
    min-width: 150px;
    border: 2px solid var(--neutral);
    border-radius: var(--border-radius);
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--text-light);
    position: relative;
}

.radio-card input[type="radio"] {
    display: none;
}

.radio-card .radio-content {
    text-align: center;
    position: relative;
    font-weight: 500;
}

.radio-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.radio-card.active {
    border-color: var(--primary);
    background-color: var(--primary);
    color: var(--text-light);
    box-shadow: var(--shadow-md);
    font-weight: 600;
}

/* Стиль для категории I */
.category-1-option.active {
    padding-bottom: 100px;
}

.category-1-input {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.radio-card.active .category-1-input {
    opacity: 1;
}

.category-1-input label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-light);
}

.category-1-input input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--neutral);
    border-radius: 4px;
    font-size: 15px;
    background: var(--text-light);
}

/* Ползунки */
.range-group {
    margin-bottom: 25px;
}

.range-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 8px;
    background: var(--neutral);
    border-radius: 4px;
    outline: none;
}

/* Трек */
input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    background: var(--neutral);
    border-radius: 4px;
}

input[type="range"]::-moz-range-track {
    height: 8px;
    background: var(--neutral);
    border-radius: 4px;
}

/* Бегунок */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    margin-top: -8px;
    border: 3px solid var(--text-light);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s;
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid var(--text-light);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

input[type="number"] {
    width: 100px;
    padding: 8px 10px;
    border: 2px solid var(--neutral);
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 500;
    background: var(--text-light);
}

/* Переключатель */
.switch {
    position: relative;
    display: inline-block;
    width: 80px;
    height: 40px;
    margin-top: 10px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--neutral);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 30px;
    width: 30px;
    left: 5px;
    bottom: 5px;
    background-color: var(--text-light);
    transition: .4s;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.labels {
    position: absolute;
    width: 100%;
    height: 100%;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    box-sizing: border-box;
    color: var(--text-light);
    font-size: 14px;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(40px);
}

/* Таблицы */
.builds-section table {
    width: 100%;
    border-collapse: separate;
    overflow: visible !important;
    border-spacing: 0;
    margin: 15px 0;
    background: var(--text-light);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.builds-section {
    position: relative;
    z-index: 10 !important;
}

/* Улучшение видимости строк таблицы */
.builds-section tr {
    position: relative;
    z-index: 5 !important;
}

.builds-section th {
    background: var(--primary);
    color: var(--text-light);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
}

.builds-section td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--neutral-light);
}

.builds-section tr:last-child td {
    border-bottom: none;
}

.builds-section input[type="number"] {
    width: 100px;
    padding: 6px 8px;
    border: 1px solid var(--neutral);
    border-radius: 4px;
}

button[data-action="add-row"] {
    padding: 8px 15px;
    font-size: 15px;
    margin: 10px 0;
    background-color: var(--primary) !important; 
    color: var(--text-light) !important;
    border: none !important;
    border-radius: var(--border-radius) !important;
    cursor: pointer;
    transition: all 0.3s !important;
    box-shadow: var(--shadow-sm) !important;
    font-weight: 600 !important;
}

button[data-action="add-row"]:hover {
    background-color: var(--primary-light) !important; 
    transform: translateY(-2px) !important;
    box-shadow: var(--shadow-md) !important;
}

button[data-action="remove-row"] {
    padding: 4px 10px;
    font-size: 15px;
    background-color: #e74c3c;
    color: var(--text-light);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Результирующая таблица */
#result_table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 20px 0;
    background: var(--text-light);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

#result_table th {
    background: var(--primary);
    color: var(--text-light);
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

#result_table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--neutral-light);
}

#result_table tr:last-child td {
    background: var(--primary-lightest);
    font-weight: 700;
}

#result_table tr:nth-child(even) {
    background-color: var(--neutral-light);
}

/* Подсказки */
.tooltip-text {
    cursor: help;
    display: inline-block;
    width: 24px;
    height: 24px;
    color: var(--primary);
    border-radius: 50%;
    text-align: center;
    margin-left: 5px;
    font-weight: bold;
    border: 1px solid var(--primary);
    line-height: 22px;
}

.tooltip-container {
    min-width: 600px;
    display: none;
    position: fixed;
    background: var(--text-light);
    border: 1px solid var(--neutral);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    max-width: 800px;
    max-height: 400px;
    overflow-y: auto;
    font-size: 15px;
    line-height: 1.5;
}

.tooltip-container.show {
    display: block;
}

/* Чекбоксы строительства */
.builds-section [type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.builds-section .checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 15px;
    border-radius: var(--border-radius);
    transition: all 0.3s;
    background: var(--text-light);
    border: 1px solid var(--neutral);
    box-shadow: var(--shadow-sm);
    margin-bottom: 10px;
}

.builds-section .checkbox-label:hover {
    border-color: var(--primary);
}

.builds-section .checkbox-custom {
    position: relative;
    width: 22px;
    height: 22px;
    border: 2px solid var(--primary);
    border-radius: 4px;
    transition: all 0.3s;
}

.builds-section .checkbox-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    width: 12px;
    height: 8px;
    border-left: 3px solid var(--text-light);
    border-bottom: 3px solid var(--text-light);
    opacity: 0;
}

.builds-section [type="checkbox"]:checked + .checkbox-label .checkbox-custom {
    background: var(--primary);
}

.builds-section [type="checkbox"]:checked + .checkbox-label .checkbox-custom::after {
    opacity: 1;
}

/* Адаптивность: общие стили */
/* Больше для нового сайта, на текущем не особо полезны */
@media (max-width: 768px) {
    .calc-section .form-row {
        grid-template-columns: 1fr;
    }
    
    .radio-group.card-radio {
        flex-direction: column;
    }
    
    .radio-card {
        min-width: 100%;
    }
    
    .tooltip-container {
        min-width: 300px;
        max-width: 90vw;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}

/* Адаптивные таблицы строительства */
@media (max-width: 700px) {
    #vls_table, #kls_table, #tps_table,
    #vls_table thead, #kls_table thead, #tps_table thead,
    #vls_table tbody, #kls_table tbody, #tps_table tbody,
    #vls_table tr, #kls_table tr, #tps_table tr,
    #vls_table td, #kls_table td, #tps_table td {
        display: block;
        width: 100%;
    }
    
    #vls_table thead, #kls_table thead, #tps_table thead {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    #vls_table tr, #kls_table tr, #tps_table tr {
        margin-bottom: 20px;
        border: 1px solid var(--neutral);
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-sm);
        background: var(--text-light);
        padding: 10px;
        position: relative;
    }
    
    #vls_table td, #kls_table td, #tps_table td {
        padding: 10px 15px 10px 50%;
        text-align: right;
        position: relative;
        border-bottom: 1px solid var(--neutral-light);
    }
    
    #vls_table td:last-child, #kls_table td:last-child, #tps_table td:last-child {
        border-bottom: none;
    }
    
    #vls_table td::before, #kls_table td::before, #tps_table td::before {
        content: attr(data-label);
        position: absolute;
        left: 15px;
        top: 50%;
        transform: translateY(-50%);
        font-weight: bold;
        text-align: left;
        width: 45%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Кнопки действий */
    #vls_table td:last-child, #kls_table td:last-child, #tps_table td:last-child {
        text-align: center;
        padding: 15px;
    }
    
    #vls_table td:last-child::before, 
    #kls_table td:last-child::before, 
    #tps_table td:last-child::before {
        display: none;
    }
}

/* Адаптивная таблица результатов */
@media (max-width: 550px) {
    #result_table, #result_table tbody, #result_table tr, #result_table td {
        display: block;
        width: 100%;
    }
    
    #result_table thead {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    #result_table tr {
        margin-bottom: 25px;
        border: 1px solid var(--neutral);
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-sm);
        background: var(--text-light);
        padding: 15px;
    }
    
    #result_table td {
        padding: 12px 15px 12px 50%;
        text-align: right;
        position: relative;
        border-bottom: 1px solid var(--neutral-light);
    }
    
    #result_table td::before {
        content: attr(data-label);
        position: absolute;
        left: 15px;
        top: 50%;
        transform: translateY(-50%);
        font-weight: bold;
        text-align: left;
        width: 45%;
    }
    
    /* Особый стиль для итоговой строки */
    #result_table tr:last-child td {
        background: var(--primary-lightest);
        font-weight: 700;
        padding: 15px;
        text-align: center;
    }
    
    #result_table tr:last-child td::before {
        display: none;
    }
}

@media (max-width: 480px) {
    .tech-connection-calculator {
        padding: 8px !important;
    }
    
    .input-group {
        padding: 12px;
    }
    
    .range-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    input[type="number"] {
        width: 100%;
    }
    
    .category-1-option.active {
        padding-bottom: 80px;
    }
    
    .category-1-input {
        bottom: 5px;
    }
    
    /* Улучшения для очень узких экранов */
    #vls_table td, #kls_table td, #tps_table td,
    #result_table td {
        padding: 10px 15px 10px 40%;
        font-size: 14px;
    }
    
    #vls_table td::before, #kls_table td::before, #tps_table td::before,
    #result_table td::before {
        width: 35%;
        font-size: 14px;
    }
}
