/* ===== Калькулятор раскроя - трёхколоночная структура как в чертежах ===== */

.calculator-wrapper {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    align-items: flex-start;
}

/* Левая колонка - входные данные (как фильтры) */
.calculator-input-sidebar {
    width: 100%;
}

.input-card {
    width: 100%;
}

.input-head {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #000000;
    color: #000000;
}

/* Центральная колонка - результат */
.calculator-result {
    width: 100%;
    background-color: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow-x: auto;
}

.result-card {
    width: 100%;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #000000;
}

.result-head {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: #000000;
}

/* .download-result-btn {
    padding: 6px 14px;
    background-color: #000000;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.3s;
} */

.download-result-btn:hover {
    background-color: #333333;
}

/* Правая колонка - информация */
.calculator-info-sidebar {
    width: 100%;
}

.info-card {
    background-color: #f8f9fa;
    border-radius: 12px;
    padding: 1.25rem;
}

.info-head {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #000000;
    color: #000000;
}

.info-text p {
    font-size: 0.8rem;
    color: #495057;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.info-text strong {
    color: #000000;
}

/* ===== ГОСТ селектор ===== */
.gost-selector {
    margin-bottom: 20px;
}

.gost-selector h6 {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: #000000;
}

.selector-row {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.selector-row label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #495057;
}

.selector-row select,
.selector-row input {
    padding: 8px 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.8125rem;
    background-color: white;
    transition: border-color 0.2s;
}

.selector-row select:focus,
.selector-row input:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.selector-row select:disabled,
.selector-row input:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

.price-row {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #dee2e6;
}

.loader {
    font-size: 0.6875rem;
    color: #000000;
    margin-top: 4px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ===== Форма ввода ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.8125rem;
    color: #000000;
}

textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.75rem;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

/* Счетчик заготовок */
.pieces-counter {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.pieces-counter.normal {
    border-color: #28a745;
    background: #e8f5e9;
}

.pieces-counter.warning {
    border-color: #dc3545;
    background: #ffebee;
}

.counter-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.counter-label {
    font-weight: 600;
    font-size: 0.75rem;
    color: #495057;
}

.counter-value {
    font-size: 18px;
    font-weight: bold;
    color: #000000;
}

.counter-limit {
    color: #6c757d;
    font-size: 0.75rem;
}

.total-length {
    margin-top: 6px;
    color: #6c757d;
    font-size: 0.6875rem;
}

.limit-warning {
    margin-top: 6px;
    padding: 6px;
    background: #dc3545;
    color: white;
    border-radius: 4px;
    font-weight: bold;
    text-align: center;
    font-size: 0.6875rem;
}

/* Параметры */
.params-group {
    margin-bottom: 20px;
}

.param-row {
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.param-row label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #000000;
    margin: 0;
}

.param-row input {
    width: 120px;
    padding: 8px 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.8125rem;
    text-align: right;
}

.param-row input:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

/* Кнопки */
/* .calculate-button {
    width: 100%;
    padding: 12px;
    background: #000000;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-bottom: 12px;
} */

.calculate-button:hover {
    background: #333333;
}

.calculate-button:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

.precise-container {
    margin-top: 12px;
}

.precise-button {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.precise-button.inactive {
    background: #6c757d;
    color: white;
    opacity: 0.7;
    cursor: not-allowed;
}

.precise-button.active {
    background: #dc3545;
    color: white;
    font-weight: bold;
}

.precise-button.active:hover {
    background: #c82333;
}

.button-main {
    font-weight: bold;
    font-size: 0.8125rem;
}

.button-timer {
    font-size: 0.6875rem;
    opacity: 0.9;
}

/* Сводка */
.summary {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
}

.stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.8125rem;
}

.stat:last-child {
    border-bottom: none;
}

.stat-label {
    color: #495057;
    font-weight: 500;
}

.stat-value {
    font-weight: 600;
    color: #000000;
}

.price-stat {
    border-left: 3px solid #28a745;
    padding-left: 10px;
    margin-left: 5px;
    background: linear-gradient(90deg, rgba(40, 167, 69, 0.05), transparent);
}

.price-value {
    color: #28a745 !important;
}

/* Визуализация */
#visualizationContainer {
    margin-top: 20px;
}

.visualization-container h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #000000;
    margin-bottom: 16px;
}

.visualization-container svg {
    display: block;
    margin: 0 auto;
    background: #fafafa;
    border-radius: 8px;
    width: 100%;
    height: auto;
}

/* Ошибки */
.error-message {
    margin-top: 12px;
    padding: 10px;
    background: #f8d7da;
    color: #721c24;
    border-radius: 8px;
    text-align: center;
    font-size: 0.75rem;
}

/* Адаптивность */
@media (max-width: 992px) {
    .calculator-wrapper {
        flex-wrap: wrap;
    }
    
    .calculator-input-sidebar {
        width: 100%;
        order: 1;
        margin-bottom: 1rem;
    }
    
    .calculator-result {
        margin-top: 1rem;
    }
    
    .calculator-info-sidebar {
        width: 100%;
        order: 2;
        margin-bottom: 1rem;
        display: flex;
        gap: 1rem;
        flex-wrap: wrap;
    }
    
    .calculator-info-sidebar .info-card {
        flex: 1;
        min-width: 200px;
    }
}

@media (max-width: 768px) {
    .calculator-info-sidebar {
        flex-direction: column;
    }
    
    .param-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .param-row input {
        width: 100%;
    }
    
    .result-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .download-result-btn {
        justify-content: center;
    }
}

/* Гарантируем правильное отображение суммы в трубе */
#svgContainer svg {
    min-width: 650px;
}

.visualization-container {
    overflow-x: auto;
}

.download-result-btn.red-btn {
    background-color: #dc3545;
    color: white;
}

.download-result-btn.red-btn:hover {
    background-color: #c82333;
}


/* ===== История расчётов ===== */
/* История расчётов */
.history-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e9ecef;
}

.history-head {
    font-size: 1rem;
    font-weight: 600;
    color: #000000;
    margin-bottom: 15px;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid #dee2e6;
    position: relative !important;  /* Добавлено !important */
}

.history-item:hover {
    background: #e9ecef;
    border-left-color: #000000;
}

.history-date {
    font-size: 0.6875rem;
    color: #6c757d;
    margin-bottom: 6px;
}

.history-profile-line {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #000000;
    margin-bottom: 4px;
    padding-right: 30px;
}

.history-stats-line {
    font-size: 0.75rem;
    color: #495057;
    padding-right: 30px;
    margin-bottom: 0;
}

.history-delete {
    position: absolute !important;  /* Добавлено !important */
    right: 12px !important;
    bottom: 12px !important;
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    z-index: 10;
    align-self: flex-end;  /* Добавить */
    margin-top: 8px;       /* Добавить */
}

.history-delete:hover {
    background: #dc3545;
    color: white;
}

.history-empty {
    text-align: center;
    padding: 30px;
    color: #6c757d;
    font-size: 0.8125rem;
}

.history-loading {
    text-align: center;
    padding: 30px;
    color: #6c757d;
    font-size: 0.8125rem;
}

/* Индикатор загрузки при восстановлении истории */
.history-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 12px;
}

.history-loading-spinner {
    background: #000000;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}