/**
 * Стилі публічної сторінки «База даних цін на будівельну продукцію (аналітика)».
 *
 * Використовується шаблоном price-database-analytic1
 * і покриває: випадайку вибору розрахунку (.calc-picker), дерево кодифікатора,
 * специфікацію, слайдер діапазону цін (.price-range-*) та зону результату (.result-card).
 *
 * Розмітка аналітики всередині .result приходить з іншого шаблону
 * і має власні стилі — тут лише те, що стосується самої сторінки.
 *
 * Структура файлу:
 *   1. Базове (reset, .layout, .card)
 *   2. Дерево та специфікація (.tree, .spec-*)
 *   3. Вкладки (.data-tabs)
 *   4. Списки шифрів/цін (.shifr-*)
 *   5. Вибір розрахунку (.calc-picker, .calc-empty)
 *   6. Зона результату (.result-card, .result-empty-state)
 *   7. Слайдер діапазону цін (.price-range-*)
 *   8. Адаптивність (1200 / 768 / 480)
 *
 * Класи-стани, якими керує JS: .is-hidden, .is-visible, .is-open, .is-active, .is-loading
 *
 * @see price-calc-picker.js — випадайка вибору розрахунку
 * @see price-data-base.js — дерево, специфікація, діапазон цін
 */

* {
    box-sizing: border-box;
}

body {
    font-family: system-ui, sans-serif;
}

.page-title2 {
    font-size: 24px;
    margin-bottom: 24px;
}

.layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
    width: 100%;
    margin: 0 auto;
    /*height: calc(100vh - 200px);
    min-height: 420px;*/
    align-items: stretch;
}

.page-container {
    max-width: 93.5%;
    margin: 0 auto;
    padding: 0 24px;
}

.card {
    background: #fff;
    border-radius: 16px;
    padding: 10px;
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    max-height: 500px;
    min-height: 0;
   
}

.card-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin-top: 8px;
    padding-right: 6px;
}

.card-scroll .dynamic-tree-wrapper .tree-scroll-wrapper {
    height: auto !important;
    overflow: visible !important;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}


.search,
.filter input {
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-bottom: 1px solid #ccc;
    margin-bottom: 12px;
    font-size: 14px;
}

.search-clearable {
    position: relative;
}

.search-clearable .search {
    padding-right: 28px;
}

.search-clear {
    position: absolute;
    right: 6px;
    top: 6px;
    cursor: pointer;
    color: #999;
    font-size: 18px;
    line-height: 1;
    user-select: none;
    display: none;
    padding: 0 4px;
}

.search-clear:hover {
    color: #333;
}

.search-clear.is-visible {
    display: inline;
}

.tree,
.spec-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.tree ul {
    list-style: none;
    padding-left: 20px;
}

.tree li {
    margin-bottom: 8px;
    cursor: pointer;
}

.toggle {
    cursor: pointer;
    display: inline-block;
    width: 16px;
    /*text-align: center;*/
    font-weight: bold;
    user-select: none;
}


.tabs-container .active {
    /*background: #e5e5e5;
    padding: 4px 6px;*/
    border-radius: 6px;
}

.filter {
    margin-bottom: 12px;
}

.filter label {
    font-size: 13px;
    color: #666;
}

.spec-list li {
    padding: 8px 6px;
    border-bottom: 1px solid #eee;
}

.info-block {
    margin-bottom: 16px;
}

.info-block h4 {
    font-size: 14px;
    margin-bottom: 6px;
}

.info-block p {
    margin: 4px 0;
    font-size: 13px;
}

.layout .btn {
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    border-radius: 20px;
    border: none;
    background: #000;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.dynamic-tree-wrapper {
    width: 100%;
    flex-shrink: 0;
    padding: 0px;
}

.spec-state-message {
    font-size: 14px;
    color: #666;
}

.spec-form-wrapper {
    display: none;
}

.card:has(.spec-title) {
    margin-top: 8px !important;
    padding: 8px;
}

.card:has(.spec-title) .card-scroll {
    margin-top: 4px;
}

.spec-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    padding-bottom: 6px;
}

.spec-filter-toggle {
    border: 1px solid #dce1ea;
    background: #fff;
    color: #6b7280;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background .15s, color .15s, border-color .15s;
}

.spec-filter-toggle:hover {
    background: #f5f6f8;
    color: #2d5fdb;
}

.spec-filter-toggle[aria-expanded="true"] {
    background: #4c78e5;
    border-color: #4c78e5;
    color: #fff;
}

.spec-form-wrapper.filters-collapsed .autocomplete-filters {
    display: none;
}


.spec-form-wrapper button:not(.autocomplete-generate-button),
.spec-form-wrapper input[type="submit"] {
    display: none;
}

.spec-loader {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #d9d9d9;
    border-top-color: #000;
    border-radius: 50%;
    animation: spec-spin 0.8s linear infinite;
}

@keyframes spec-spin {
    to {
        transform: rotate(360deg);
    }
}

.tree-layer-template li:not(:last-child) {
    display: flex;

}

.tree-layer-template {
    margin-top: 6px;
}

.dynamic-tree-search {
    margin-bottom: 4px;
}

.bold-text {
    font-size: 15px;
    font-weight: bold;
    color: black;
}

.spec-form-wrapper .form-group {
    margin-bottom: 0;
}

.spec-form-wrapper .ibox-content {
    padding: 4px !important;
    margin: 0 !important;
}

.spec-form-wrapper .autocomplete-options,
.spec-form-wrapper .autocomplete-list {
    margin: 0 !important;
    padding: 0 !important;
}

/* Кнопка генерації коду в адмінці */
.autocomplete-empty-text {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
    margin-bottom: 10px;
}

.autocomplete-generate-button {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    background: #000;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.autocomplete-generate-button[disabled] {
    opacity: 0.6;
    cursor: default;
}

.spec-form-wrapper.is-no-results .autocomplete-list,
.spec-form-wrapper.is-no-results .autocomplete-actions,
.spec-form-wrapper.is-no-results .autocomplete-template {
    display: none;
}

.spec-no-results {
    display: none;
    margin-top: 6px;
    border: 1px solid #ddd;
    padding: 10px 12px;
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

.spec-no-results.is-visible {
    display: block;
}

.spec-no-results p {
    margin: 0 0 4px 0;
}

.spec-no-results p:first-child {
    font-size: 15px;
    font-weight: bold;
    color: #000;
}

.spec-no-results p:last-child {
    margin-bottom: 0;
}

.spec-no-results a {
    color: #000;
    text-decoration: underline;
}

.data-tabs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.data-tab {
    padding: 8px 18px;
    border: 1px solid #000;
    border-radius: 20px;
    background: #fff;
    color: #000;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.data-tab:hover {
    background: #f0f0f0;
}

.data-tab.is-active {
    background: #000;
    color: #fff;
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.dstu-filter {
    margin-bottom: 12px;
}

.dstu-filter label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
}

.dstu-hidden-search {
    display: none;
}

.dstu-autocomplete {
    position: relative;
}

.dstu-ac-input {
    width: 100%;
    padding: 8px 26px 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.dstu-ac-input:focus {
    border-color: #888;
}

.dstu-ac-clear {
    position: absolute;
    right: 8px;
    top: 8px;
    cursor: pointer;
    color: #999;
    font-size: 18px;
    line-height: 1;
    user-select: none;
    display: none;
}

.dstu-ac-clear.is-visible {
    display: inline;
}

.dstu-ac-list {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    z-index: 20;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
}

.dstu-ac-list.is-open {
    display: block;
}

.dstu-ac-option {
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.dstu-ac-option:last-child {
    border-bottom: none;
}

.dstu-ac-option:hover,
.dstu-ac-option.is-active {
    background: #f0f0f0;
}

.dstu-ac-empty {
    padding: 8px 10px;
    font-size: 13px;
    color: #888;
}

.shifr-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.shifr-list.is-loading {
    opacity: .45;
    pointer-events: none;
    transition: opacity .12s ease;
}

.shifr-item {
    padding: 8px 6px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.shifr-item:hover {
    background: #f5f5f5;
}

.shifr-item.is-active {
    background: #e5e5e5;
    border-radius: 6px;
}

.shifr-item-code {
    font-weight: 600;
    font-size: 14px;
}

.shifr-item-unit {
    color: #888;
    font-size: 12px;
    margin-left: 6px;
}

.shifr-item-name {
    display: block;
    font-size: 13px;
    color: #333;
    margin-top: 2px;
}


#price_list .shifr-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}


#price_list .shifr-item-name {
    order: 1;
    margin-top: 0;
    min-width: 0;
    flex: 1 1 auto;
}


#price_list .shifr-item-code {
    order: 2;
    flex: 0 0 auto;
    white-space: nowrap;
    text-align: right;
    margin-left: auto;
    padding: 0 10px 0 16px;
}

.shifr-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.shifr-pager:empty {
    margin-top: 0;
}

.price-spec-card {
    height: 500px;
}


#price_pager {
    min-height: 32px;
}

#price_pager:empty {
    margin-top: 12px;
}

.card > .search {
    flex-shrink: 0;
}

.shifr-pager button {
    padding: 4px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
}

.shifr-pager button:disabled {
    opacity: .5;
    cursor: default;
}

.shifr-pager-info {
    font-size: 13px;
    color: #666;
}

.search:not(.result .search) {
    border: none;
    padding: 0;
    margin: 0;
    width: auto;
    font-size: inherit;
}


#shifr_search,
#shifr_codifiers_search,
#price_search {
    width: 100%;
    padding: 8px 28px 8px 10px;
    border: none;
    border-bottom: 1px solid #ccc;
    margin-bottom: 12px;
    font-size: 14px;
}

/* Рівний вертикальний ритм 15px між блоками у верхній частині сторінки:
   заголовок → випадайка → вкладки → перша картка. Заголовок лежить у
   .page-layout вище за .page-container, тож гасимо його нижній відступ тут. */
.page-layout .page-title {
    margin-bottom: 0;
}

.calc-picker {
    margin-top: 15px;
    margin-bottom: 15px;
    max-width: 620px;
}

.calc-picker__control {
    position: relative;
}

.calc-picker__input {
    width: 100%;
    min-width: 0;
    padding: 10px 54px 10px 12px;
    border: 1px solid #d5d9e0;
    border-radius: 8px;
    font-size: 14px;
    color: rgb(47, 64, 80);
    background: #fff;
    outline: none;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}

.calc-picker__input:focus {
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .06);
}

.calc-picker__caret {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 12px;
    pointer-events: none;
}

.calc-picker__clear {
    display: none;
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #999;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    transition: background .15s, color .15s;
}

.calc-picker__clear.is-visible {
    display: inline-flex;
}

.calc-picker__clear:hover {
    background: #f0f0f0;
    color: #333;
}

/* Список приклеєний до поля: сідає впритул (top:100%), верхня межа спільна
   з нижньою межею поля (margin-top:-1px), верхні кути прямі — разом вони
   читаються як один елемент, а не як поле і окрема картка під ним. */
.calc-picker__list {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: -1px;
    z-index: 30;
    max-height: 300px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #d5d9e0;
    border-top-color: #eceef1;
    border-radius: 0 0 8px 8px;
    /* Тінь лише вниз і вбоки — зверху вона відсікла б список від поля */
    box-shadow: 0 6px 14px -4px rgba(0, 0, 0, .18);
}

.calc-picker__list.is-open {
    display: block;
}

/* Поки список відкритий, поле «зростається» з ним: нижні кути прямі,
   підсвітка фокуса зайва — інакше вона обвела б поле окремою рамкою.
   Орієнтуємось на aria-expanded, який виставляє скрипт. */
.calc-picker__input[aria-expanded="true"] {
    border-radius: 8px 8px 0 0;
    border-color: #d5d9e0;
    box-shadow: none;
}

.calc-picker__option {
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.calc-picker__option:last-child {
    border-bottom: none;
}

.calc-picker__option:hover,
.calc-picker__option.is-active {
    background: #f0f0f0;
}

.calc-picker__empty {
    padding: 10px 12px;
    font-size: 13px;
    color: #888;
}

#calc_content.is-loading {
    opacity: .5;
    pointer-events: none;
    transition: opacity .12s ease;
}

.calc-empty {
    border: 1px dashed #d5d9e0;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    color: #9ca3af;
}

.calc-empty__hint {
    font-size: 13px;
    margin-top: 6px;
}


.page-container,
.page-container a {
    color: rgb(47, 64, 80);
}

.page-container a {
    text-decoration: none;
}


@media (max-width: 1200px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .page-container {
        max-width: 100%;
    }
}

@media (max-width: 768px) {

    .layout {
        gap: 16px;
    }

    .page-container {
        padding: 0 12px;
    }

    .page-title2 {
        font-size: 20px;
        margin-bottom: 16px;
    }

    .card {
        padding: 14px;
        border-radius: 12px;
    }

    .card-title {
        font-size: 14px;
        margin-bottom: 10px;
    }


    .card-scroll {
        max-height: 320px;
    }

    .price-spec-card {
        height: auto;
        max-height: none;
    }


    .result-card {
        max-height: none;
        overflow: visible;
    }

    .result-card-scroll {
        overflow-y: visible;
    }


    .data-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        margin-bottom: 16px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .data-tabs::-webkit-scrollbar {
        display: none;
    }

    .data-tab {
        flex: 0 0 auto;
        padding: 8px 14px;
        font-size: 13px;
    }

    .btn {
        padding: 12px;
        font-size: 15px;
    }

    .tree li {
        margin-bottom: 6px;
        font-size: 14px;
    }

    .toggle {
        width: 14px;
    }

    #price_search,
    #shifr_search,
    #shifr_codifiers_search,
    .dstu-ac-input,
    .price-range-num {
        font-size: 16px;
    }

    .price-range-slider {
        --thumb: 24px;
    }

    .price-range-fields {
        gap: 10px;
        margin-bottom: 20px;
    }

 
    .price-range-num {
        padding-right: 34px;
    }

    .price-range-suffix {
        right: 8px;
    }


    #price_list .shifr-item-code {
        padding: 0 0 0 10px;
    }


    .result-card pre {
        max-width: 100%;
        overflow-x: auto;
    }

    .result-card img,
    .result-card svg {
        max-width: 100%;
        height: auto;
    }
}

@media (max-width: 480px) {

    .page-title2 {
        font-size: 18px;
    }

    .page-container {
        padding: 0 10px;
    }

    .card {
        padding: 12px;
    }

    .card-scroll {
        max-height: 280px;
    }

    .tree ul {
        padding-left: 14px;
    }


    .price-range-fields {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .price-range-field {
        width: 100%;
    }


    #price_list .shifr-item {
        flex-wrap: wrap;
        gap: 4px;
    }

    #price_list .shifr-item-name {
        flex: 1 1 100%;
    }

    #price_list .shifr-item-code {
        padding: 0;
        margin-left: 0;
    }
}


.result-card {
    background: #fff;
    display: flex;
    flex-direction: column;
    max-height: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.result-card-scroll {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
}


.layout > * {
    min-width: 0;
}


.result-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: #9ca3af;
    text-align: center;
}

.result-empty-state__icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.result-empty-state__title {
    font-size: 15px;
    font-weight: 500;
}

.result-empty-state__hint {
    font-size: 13px;
    margin-top: 6px;
}


.is-hidden {
    display: none;
}

.price-range-box {
    padding: 10px 4px 4px;
}


.price-range-fields {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 22px;
}

.price-range-field {
    flex: 1 1 0;
    min-width: 0;
}

.price-range-field label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
    font-weight: 500;
}

.price-range-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}


.price-range-num {
    width: 100%;
    min-width: 0;
    padding: 8px 40px 8px 10px;
    border: 1px solid #d5d9e0;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: rgb(47, 64, 80);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    -moz-appearance: textfield;
    appearance: textfield;
}

.price-range-num::-webkit-outer-spin-button,
.price-range-num::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.price-range-num:focus {
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .06);
}

.price-range-suffix {
    position: absolute;
    right: 10px;
    font-size: 12px;
    color: #999;
    pointer-events: none;
}


.price-range-slider {
    --thumb: 18px;
    --track: 4px;
    position: relative;
    height: var(--thumb);
}

.price-range-track,
.price-range-fill {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: var(--track);
    border-radius: 999px;
}

.price-range-track {
    left: 0;
    right: 0;
    background: #e6e8ec;
}

.price-range-fill {
    background: #000;
}


.price-range-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--thumb);
    margin: 0;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

.price-range-input::-webkit-slider-runnable-track {
    background: transparent;
    height: var(--thumb);
    border: none;
}

.price-range-input::-moz-range-track {
    background: transparent;
    height: var(--thumb);
    border: none;
}

.price-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: auto;
    width: var(--thumb);
    height: var(--thumb);
    border-radius: 50%;
    background: #fff;
    border: 2px solid #000;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
    cursor: pointer;
    margin-top: 0;
}

.price-range-input::-moz-range-thumb {
    pointer-events: auto;
    width: var(--thumb);
    height: var(--thumb);
    border-radius: 50%;
    background: #fff;
    border: 2px solid #000;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
    cursor: pointer;
}

.price-range-input:focus {
    outline: none;
}

.price-range-input:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgba(0, 0, 0, .12), 0 1px 4px rgba(0, 0, 0, .25);
}

.price-range-count {
    margin-top: 16px;
    font-size: 13px;
    color: #666;
}
