/* ===== КОНСТРУКТОР СМЕТ - СТИЛИ ===== */

.builder-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

/* === Шаг 1: Выбор типа работ === */
.worktype-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.0rem;
    margin: 2rem 0;
}

.worktype-card {
    border: 0px solid #e5e7eb;
    border-radius: 4px;
    padding: 1rem 1.5rem;
    background: #ffffff;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: pointer;
}

.worktype-card:hover {
    border-color: #92a7f1;
    /*box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);*/
    transform: translateY(-2px);
}

.worktype-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: #1f2937;
}

.worktype-card p {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0 0 1rem 0;
    line-height: 1.5;
}

.btn-select-worktype {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-select-worktype:hover {
    background: #1d4ed8;
}

/* === Шаг 2: Параметры === */
#params-form {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.param-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.param-field label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
}

.param-field input,
.param-field select {
    padding: 0.625rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.param-field input:focus,
.param-field select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* === Кнопки === */
.btn-primary, .btn-secondary, .btn-estimate-primary, .btn-estimate-secondary {
    padding: 0.625rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary, .btn-estimate-primary {
    background: #2563eb;
    color: white;
}
.btn-primary:hover, .btn-estimate-primary:hover {
    background: #1d4ed8;
}
.btn-secondary, .btn-estimate-secondary {
    background: #f3f4f6;
    color: #1f2937;
    border: 1px solid #e5e7eb;
}
.btn-secondary:hover, .btn-estimate-secondary:hover {
    background: #e5e7eb;
}

.btn-estimate-danger {
    background: #ef4444;
    color: white;
}
.btn-estimate-danger:hover {
    background: #dc2626;
}

.result-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* === Секции === */
.builder-section {
    margin-bottom: 2rem;
}

.builder-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

/* === Таблица сметы === */
.estimate-table-wrapper {
    overflow-x: auto;
    margin: 1.5rem 0;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    background: white;
}

.estimate-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.estimate-table th {
    background: #f8fafc;
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
}

.estimate-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.estimate-table tbody tr:hover {
    background: #fefce8;
}

/* === Редактируемые поля === */
.estimate-table input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.813rem;
    font-family: inherit;
    background: white;
    transition: all 0.15s;
}

.estimate-table input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}

.edit-work {
    min-width: 200px;
}
.edit-unit {
    width: 70px;
    text-align: center;
}
.edit-qty, .edit-price {
    width: 100px;
    text-align: right;
}

/* === Сумма строки === */
.row-total {
    font-weight: 600;
    color: #059669;
    text-align: right;
}

/* === Кнопка удаления строки === */
.delete-row-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #9ca3af;
    transition: color 0.15s;
    padding: 0.25rem 0.5rem;
}

.delete-row-btn:hover {
    color: #ef4444;
}

/* === Итоговая строка === */
.estimate-table tfoot td {
    background: #f8fafc;
    font-weight: 600;
    padding: 1rem;
    border-top: 2px solid #e2e8f0;
}

#total-sum {
    font-size: 1.1rem;
    color: #059669;
}

/* === Блок действий === */
.estimate-actions {
    display: flex;
    gap: 0.75rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

/* === Примечание === */
.estimate-note {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #f0fdf4;
    border-left: 4px solid #10b981;
    border-radius: 8px;
    font-size: 0.813rem;
    color: #047857;
}

/* === Ошибки и загрузка === */
.error {
    color: #dc2626;
    background: #fef2f2;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #dc2626;
}

#loading {
    text-align: center;
    padding: 2rem;
    font-size: 1rem;
    color: #2563eb;
}

#loading i {
    margin-right: 0.5rem;
}

/* === Адаптив для мобильных === */
@media (max-width: 768px) {
    .builder-container {
        padding: 1rem;
    }
    
    .worktype-grid {
        grid-template-columns: 1fr;
    }
    
    .estimate-table th,
    .estimate-table td {
        padding: 0.5rem;
    }
    
    .edit-work {
        min-width: 150px;
    }
    
    .param-field input,
    .param-field select {
        font-size: 16px; /* Предотвращает зум на iOS */
    }
}

/* === Печатная версия === */
@media print {
    .worktype-grid,
    .estimate-selector,
    .estimate-actions,
    .result-actions,
    .delete-row-btn,
    #add-new-row,
    button,
    .btn-primary,
    .btn-secondary,
    .btn-estimate-primary,
    .btn-estimate-secondary,
    #btn-back,
    #btn-print,
    #btn-export,
    .estimate-note {
        display: none !important;
    }
    
    .estimate-table input {
        border: none;
        background: transparent;
        padding: 0;
    }
    
    .estimate-table {
        border: 1px solid #000;
    }
    
    .estimate-table th,
    .estimate-table td {
        border: 1px solid #ccc;
    }
}

/* ===== СОВРЕМЕННАЯ ПЕЧАТНАЯ ВЕРСИЯ ===== */
/* Скрываем всё лишнее при печати */
@media print {
    /* Скрываем попап cookie */
    .cookie-notice,
    .cookie-popup,
    .cookie-consent,
    [class*="cookie"],
    [id*="cookie"] {
        display: none !important;
    }

    /* Скрываем поиск */
    .srh-form-main,
    .search-form,
    [class*="search"],
    [id*="search"] {
        display: none !important;
    }

    /* Скрываем хлебные крошки */
    .shell-breadcrumb,
    .breadcrumb,
    [class*="breadcrumb"] {
        display: none !important;
    }

    /* Скрываем шапку и футер */
    .shell-header,
    .shell-footer,
    header, footer,
    [class*="header"]:not(.print-header),
    [class*="footer"] {
        display: none !important;
    }

    /* Скрываем фильтры, статистику, навигацию */
    .categories-filter-tabs,
    .categories-hub-stats,
    .quick-nav,
    .hub-stats,
    .filter-tabs {
        display: none !important;
    }

    /* Скрываем рекламу */
    .ad-block,
    #ad-block-top,
    #ad-block-bottom,
    [class*="ad-"] {
        display: none !important;
    }

    /* Скрываем кнопки и формы */
    button, .btn, .btn-primary, .btn-secondary,
    .estimate-selector, .estimate-actions, .result-actions,
    #add-new-row, .delete-row-btn {
        display: none !important;
    }

    /* Скрываем всё лишнее в конструкторе */
    .worktype-grid,
    .builder-section:first-child,
    .builder-section:nth-child(2) {
        display: none !important;
    }

    /* Показываем только результат */
    #step-result {
        display: block !important;
    }

    /* Сбрасываем фон и отступы */
    body {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .builder-container {
        padding: 0 !important;
        margin: 0 !important;
    }
}

@media print {
    /* Скрываем всё лишнее */
    .worktype-grid,
    .estimate-selector,
    .estimate-actions,
    .result-actions,
    .builder-section:first-child,
    .builder-section:nth-child(2),
    .delete-row-btn,
    #add-new-row,
    button,
    .btn-primary,
    .btn-secondary,
    .btn-estimate-primary,
    .btn-estimate-secondary,
    #btn-back,
    #btn-print,
    #btn-export,
    .estimate-note,
    .builder-container > .estimate-selector,
    .builder-container > .estimate-actions,
    .builder-container > .result-actions,
    .builder-container > .estimate-note,
    header, footer, nav, .shell-breadcrumb, .shell-header, .shell-footer,
    .categories-filter-tabs, .categories-hub-stats, .quick-nav,
    .search-form, .srh-form-main, .ad-block, #ad-block-top, #ad-block-bottom {
        display: none !important;
    }

    /* Основной контейнер */
    .builder-container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }

    /* Заголовок сметы */
    #estimate-header {
        text-align: center;
        margin-bottom: 20px;
        padding-bottom: 10px;
        border-bottom: 2px solid #000;
    }

    #estimate-title {
        font-size: 20pt;
        font-weight: bold;
        margin: 0 0 5px 0;
        color: #000;
    }

    #estimate-description {
        font-size: 11pt;
        color: #555;
        margin: 0;
    }

    /* Таблица */
    .estimate-table-wrapper {
        overflow: visible !important;
        border: none !important;
        margin: 0 !important;
    }

    .estimate-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 9pt;
        page-break-inside: avoid;
    }

    .estimate-table th {
        background: #f0f0f0 !important;
        padding: 8px 6px;
        border: 1px solid #000;
        font-weight: bold;
        text-align: left;
    }

    .estimate-table td {
        padding: 6px;
        border: 1px solid #999;
        vertical-align: top;
    }

    /* Заменяем input поля на текст */
    .estimate-table input {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        width: auto !important;
        font-family: inherit !important;
        font-size: inherit !important;
        font-weight: inherit !important;
        color: #000 !important;
        box-shadow: none !important;
    }

    /* Скрываем кнопки в таблице */
    .delete-row-btn {
        display: none !important;
    }

    /* Итоговая строка */
    .estimate-table tfoot td {
        background: #f8f8f8 !important;
        font-weight: bold;
        border-top: 2px solid #000;
    }

    #total-sum {
        font-size: 12pt;
        color: #000;
    }

    /* Блок "Результаты" */
    #step-result {
        display: block !important;
    }

    /* Принудительно показываем результат */
    .builder-section {
        display: block !important;
    }

    /* Страница */
    body {
        background: white !important;
        color: black !important;
    }

    /* Ссылки */
    a {
        text-decoration: none !important;
        color: #000 !important;
    }
}