/* Страница калькулятора сметы (строительство) */
/* calculators/smeta-build/smeta-build-calculator.css */

.smeta-build-page {
    background-color: #f3f4f6;
    color: #111827;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Подзаголовок страницы */
.page-subtitle {
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    margin: -8px 0 12px;
}

/* Контент */

.smeta-build-calculator {
    padding-bottom: 32px;
}

.smeta-build-card {
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    margin-top: 8px;
}

/* Секции */

.smeta-build-section + .smeta-build-section {
    margin-top: 16px;
}

.smeta-build-section__title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 8px;
    color: #111827;
}

/* Шапка заказа */

.smeta-build-header-grid {
    display: grid;
    gap: 8px;
}

@media (min-width: 768px) {
    .smeta-build-header-grid {
        grid-template-columns: 2fr 1.2fr;
    }
}

/* Поля */

.smeta-build-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.smeta-build-field__label {
    font-size: 13px;
    color: #4b5563;
}

.smeta-build-field__input {
    border-radius: 10px;
    border: 1px solid #d1d5db;
    padding: 8px 10px;
    font-size: 14px;
    background-color: #ffffff;
    outline: none;
    width: 100%;
}

.smeta-build-field__input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

.smeta-build-field__input--select {
    padding-right: 28px;
}

/* Список работ */

.work-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

.work-row {
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background-color: #ffffff;
    padding: 10px 10px 8px;
}

.work-row__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.work-row__index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background-color: #dbeafe;
    font-size: 12px;
    font-weight: 600;
    color: #1d4ed8;
}

.work-row__remove {
    border: none;
    background: transparent;
    color: #9ca3af;
    font-size: 18px;
    line-height: 1;
    padding: 2px 4px;
    cursor: pointer;
}

.work-row__remove:hover {
    color: #ef4444;
}

.work-row:first-child .work-row__remove {
    display: none; /* первую строку удалить нельзя */
}

.work-row__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.work-row__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.work-row__label {
    font-size: 13px;
    color: #4b5563;
}

.work-row__select {
    border-radius: 10px;
    border: 1px solid #d1d5db;
    padding: 7px 9px;
    font-size: 13px;
    background-color: #ffffff;
    outline: none;
    width: 100%;
}

.work-row__select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

/* Сетка параметров строки */

.work-row__grid {
    display: grid;
    gap: 6px;
    grid-template-columns: minmax(60px, 0.8fr) minmax(70px, 1fr);
}

@media (min-width: 480px) {
    .work-row__grid {
        grid-template-columns: minmax(60px, 0.7fr) minmax(70px, 0.9fr) minmax(80px, 1fr) minmax(90px, 1.1fr);
    }
}

@media (max-width: 360px) {
    .work-row__grid {
        gap: 4px;
        grid-template-columns: minmax(50px, 0.75fr) minmax(60px, 1fr);
    }
    
    .work-row__input {
        padding: 4px 5px;
        font-size: 12px;
    }
}

.work-row__cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.work-row__cell-label {
    font-size: 12px;
    color: #6b7280;
}

.work-row__cell-value {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
}

.work-row__cell-value--sum {
    color: #1d4ed8;
    padding-top: -2px;
    height: 28px;
    line-height: 28px;
}

.work-row__input {
    border-radius: 8px;
    border: 1px solid #d1d5db;
    padding: 5px 7px;
    font-size: 13px;
    text-align: right;
    background-color: #ffffff;
    outline: none;
    min-width: 0;
    width: 100%;
}

.work-row__input.work-row__search {
    text-align: left;
}

.work-row__input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

/* Кнопка "Добавить работу" */

.smeta-build-add-row-btn {
    width: 100%;
    border-radius: 999px;
    border: none;
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 500;
    background: #1d4ed8;
    color: #ffffff;
    cursor: pointer;
    margin-top: 4px;
}

.smeta-build-add-row-btn:active {
    transform: translateY(1px);
}

/* Коэффициенты */

.smeta-build-coefs-grid {
    display: grid;
    gap: 6px;
    grid-template-columns: 1fr;
}

@media (min-width: 480px) {
    .smeta-build-coefs-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
}

.smeta-build-coefs-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.smeta-build-coefs-total {
    margin: 8px 0 0;
    font-size: 13px;
    color: #4b5563;
}

.smeta-build-coefs-total__value {
    font-weight: 600;
    color: #1d4ed8;
}

/* Доп. расходы */

.smeta-build-extras-grid {
    display: grid;
    gap: 6px;
    grid-template-columns: 1fr;
}

@media (min-width: 420px) {
    .smeta-build-extras-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
}

.smeta-build-extras-item input {
    max-width: 200px;
}

.smeta-build-extras-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.smeta-build-extras-total {
    margin-top: 8px;
    font-size: 13px;
    color: #4b5563;
}

.smeta-build-extras-total__value {
    font-weight: 600;
}

/* Итоги */

.smeta-build-totals {
    border-radius: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.smeta-build-totals__row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: baseline;
    gap: 4px;
    font-size: 14px;
}

.smeta-build-totals__label {
    color: #374151;
}

.smeta-build-totals__value {
    font-weight: 600;
    text-align: right;
}

.smeta-build-totals__value--accent {
    font-size: 18px;
    color: #1d4ed8;
}

.smeta-build-totals__suffix {
    font-size: 13px;
    color: #4b5563;
}

.smeta-build-totals__suffix--accent {
    font-weight: 500;
}

/* Кнопки действий */

.smeta-build-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

@media (min-width: 480px) {
    .smeta-build-actions {
        flex-direction: row;
    }
}

.smeta-build-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.smeta-build-btn--primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
}

.smeta-build-btn--primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

.smeta-build-btn--primary:active {
    transform: translateY(1px);
}

.smeta-build-btn--secondary {
    background: #ffffff;
    color: #1d4ed8;
    border: 2px solid #1d4ed8;
}

.smeta-build-btn--secondary:hover {
    background: #eff6ff;
}

.smeta-build-btn--secondary:active {
    transform: translateY(1px);
}

.smeta-build-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Кнопка очистки */

.smeta-build-reset-btn {
    margin-top: 12px;
    padding: 8px 20px;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background-color: #ffffff;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.smeta-build-reset-btn:hover {
    background-color: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

.smeta-build-reset-btn:active {
    transform: translateY(1px);
}

.smeta-build-note {
    margin-top: 12px;
    font-size: 12px;
    color: #6b7280;
    text-align: center;
}

/* ========================================
   КАСТОМНЫЙ DROPDOWN ДЛЯ ПОИСКА РАБОТ
   ======================================== */

.smeta-build-dropdown-container {
    position: relative;
    width: 100%;
}

.smeta-build-dropdown-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
}

.smeta-build-dropdown-list {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    margin-top: 4px;
    max-height: 300px;
    -webkit-overflow-scrolling: touch;
}

.smeta-build-dropdown-empty {
    padding: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

.smeta-build-dropdown-category {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1;
}

.smeta-build-dropdown-category:first-child {
    border-top: none;
}

.smeta-build-dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.15s ease;
}

.smeta-build-dropdown-item:last-child {
    border-bottom: none;
}

.smeta-build-dropdown-item:hover,
.smeta-build-dropdown-item.selected {
    background-color: #eff6ff;
}

.smeta-build-dropdown-item.selected {
    border-left: 3px solid #2563eb;
    padding-left: 9px;
}

.smeta-build-dropdown-item-name {
    font-size: 13px;
    color: #111827;
    margin-bottom: 4px;
    line-height: 1.3;
}

.smeta-build-dropdown-item-name mark {
    background-color: #fef08a;
    color: inherit;
    font-weight: 600;
    padding: 0;
}

.smeta-build-dropdown-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.smeta-build-dropdown-item-unit {
    color: #6b7280;
}

.smeta-build-dropdown-item-category {
    color: #9ca3af;
    font-size: 11px;
}

/* ========================================
   DROPDOWN ЕДИНИЦ ИЗМЕРЕНИЯ
   ======================================== */

.work-row__unit-cell {
    position: relative;
}

.work-row__unit-trigger {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    transition: background-color 0.15s ease;
    user-select: none;
}

.work-row__unit-trigger::after {
    content: ' ▾';
    font-size: 10px;
    color: #9ca3af;
}

.work-row__unit-trigger:hover {
    background-color: #eff6ff;
}

.work-row__unit-trigger:active {
    background-color: #dbeafe;
}

.work-row__unit-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    margin-top: 4px;
    max-height: 200px;
    min-width: 100px;
    -webkit-overflow-scrolling: touch;
}

.work-row__unit-dropdown.open {
    display: block;
}

.work-row__unit-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: #111827;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.15s ease;
}

.work-row__unit-option:last-child {
    border-bottom: none;
}

.work-row__unit-option:hover {
    background-color: #eff6ff;
}

.work-row__unit-option:active {
    background-color: #dbeafe;
}


/* ========================================
   AI-ОЦЕНКА ЦЕНЫ
   ======================================== */

/* Обёртка: цена + кнопка ⚡ */
.work-row__price-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.work-row__price-wrapper .work-row__input {
    flex: 1;
    min-width: 0;
    height: 28px;
    padding: 2px 7px 0;
    line-height: 28px;
    vertical-align: middle;
}

/* Кнопка ⚡ */
.work-row__ai-btn {
    width: 36px;
    height: 28px;
    min-width: 36px;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    box-shadow: 0 1px 2px rgba(37,99,235,0.08);
}

.work-row__ai-btn:hover {
    background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #2563eb;
    box-shadow: 0 2px 4px rgba(37,99,235,0.15);
}

.work-row__ai-btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.work-row__ai-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

/* Price-info блок под строкой */
.work-row__price-info {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 6px;
    padding: 4px 0 0;
    min-height: 0;
    font-size: 11px;
    line-height: 1.3;
}

.work-row__price-info:empty {
    display: none;
}

.price-info__badge {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.price-info__source {
    color: #9ca3af;
    font-size: 10px;
    white-space: nowrap;
}

.price-info__refresh {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 12px;
    padding: 0 2px;
    opacity: 0.5;
    transition: opacity 0.2s;
    line-height: 1;
}

.price-info__refresh:hover {
    opacity: 1;
}

/* Состояния loading */
.work-row__price-info--loading .price-info__badge {
    color: #6b7280;
    font-style: italic;
}

.work-row__price-info--loading .price-info__refresh {
    display: none;
}

/* High confidence — зелёный */
.work-row__price-info--high .price-info__badge {
    color: #16a34a;
}

/* Medium confidence — серый */
.work-row__price-info--medium .price-info__badge {
    color: #6b7280;
}

/* Low confidence — оранжевый */
.work-row__price-info--low .price-info__badge {
    color: #d97706;
}

/* Not found — красноватый */
.work-row__price-info--not-found .price-info__badge {
    color: #dc2626;
    font-style: italic;
}

/* Error */
.work-row__price-info--error .price-info__badge {
    color: #dc2626;
}

/* Manual — нейтральный */
.work-row__price-info--manual .price-info__badge {
    color: #9ca3af;
    font-style: italic;
}

.work-row__price-info--manual .price-info__refresh {
    display: none;
}

/* ========================================
   ВАЛИДАЦИЯ ГОРОДА
   ======================================== */

.smeta-build-field__error {
    display: none;
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
}

.smeta-build-field__region-hint {
    color: #6b7280;
    font-size: 12px;
    margin-top: 4px;
    min-height: 16px;
}

.smeta-build-field__input--error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.3) !important;
    animation: shake-field 0.4s ease;
}

@keyframes shake-field {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}


/* ========================================
   МОДАЛЬНОЕ ОКНО
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}

.modal-content {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 8px;
}

.modal-text {
    font-size: 14px;
    color: #4b5563;
    margin: 0 0 16px;
    line-height: 1.5;
}

.modal-text a {
    color: #2563eb;
    text-decoration: none;
}

.modal-text a:hover {
    text-decoration: underline;
}

.modal-btn {
    width: 100%;
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    background: #2563eb;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 8px;
}

.modal-btn:active {
    transform: translateY(1px);
}

.modal-link {
    display: block;
    padding: 10px 16px;
    border-radius: 10px;
    background: #eff6ff;
    color: #1d4ed8;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    margin-top: 8px;
}

.modal-link:hover {
    background: #dbeafe;
}

@media (min-width: 780px) {
    .smeta-build-card {
        max-width: 780px;
        margin-left: auto;
        margin-right: auto;
    }
}