/*
Файл: static/css/style.css
Назначение: Базовые стили для веб-приложения

Возможности:
1. Определение базовых стилей для body
2. Стилизация блока результатов
3. Обработка ошибок

Используется модулями:
- templates/index.html: для базового оформления
- templates/materials_editor.html: для общего стиля

Стили:
- Отступы и шрифты
- Оформление результатов
- Отображение ошибок
*/

body {
    padding: 20px;
    font-family: Arial, sans-serif;
}

.results {
    margin-top: 20px;
}

.error {
    color: red;
}

/* =============================================================================
   TASK-11-13: Стили для детализированного отчёта о стоимости резки
   ============================================================================= */

.detailed-report-section {
    margin-top: 30px;
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.detailed-report-section h4 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 18px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.detailed-report-section .no-data {
    color: #666;
    font-style: italic;
}

/* Таблица детализации по листам */
.detailed-report-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background-color: #fff;
    font-size: 14px;
}

.detailed-report-table thead {
    background-color: #3498db;
    color: #fff;
}

.detailed-report-table th {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    border: 1px solid #2980b9;
}

.detailed-report-table td {
    padding: 10px 8px;
    text-align: center;
    border: 1px solid #dee2e6;
}

.detailed-report-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.detailed-report-table tbody tr:hover {
    background-color: #e9ecef;
}

/* Чекбокс делового остатка в таблице детализации */
.remainder-usable-checkbox {
    width: 14px;
    height: 14px;
    margin-left: 6px;
    vertical-align: middle;
    cursor: pointer;
    accent-color: #3498db;
}

.remainder-usable-checkbox:hover {
    transform: scale(1.1);
}

/* Сводка по материалу */
.material-totals-summary {
    background-color: #fff;
    padding: 15px 20px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.material-totals-summary h5 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 16px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
}

.totals-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 4px;
    background-color: #f8f9fa;
}

.totals-row:hover {
    background-color: #e9ecef;
}

.totals-label {
    color: #495057;
    font-weight: 500;
}

.totals-value {
    color: #2c3e50;
}

.totals-value strong {
    color: #2c3e50;
}

/* Итоговая строка */
.totals-row.total-final {
    background-color: #3498db;
    color: #fff;
    margin-top: 8px;
}

.totals-row.total-final .totals-label,
.totals-row.total-final .totals-value,
.totals-row.total-final strong {
    color: #fff;
    font-size: 16px;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .detailed-report-section {
        padding: 15px;
    }
    
    .detailed-report-table {
        font-size: 12px;
    }
    
    .detailed-report-table th,
    .detailed-report-table td {
        padding: 6px 4px;
    }
    
    .totals-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* =============================================================================
   TASK-11-15: Стили для редактора материалов - оптовые скидки
   ============================================================================= */

/* Кнопка переключения оптовых скидок */
.discount-toggle-button {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s, border-color 0.2s;
}

.discount-toggle-button:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

/* Строка с оптовыми скидками */
.volume-discount-row {
    background-color: #f0f4f8 !important;
}

.volume-discount-cell {
    padding: 15px 20px !important;
}

.volume-discount-container {
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
}

.volume-discount-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.volume-discount-header strong {
    font-size: 15px;
    color: #2c3e50;
}

.volume-discount-hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #6c757d;
}

.volume-discount-table {
    width: 100%;
    border-collapse: collapse;
}

.volume-discount-table th {
    background-color: #e9ecef;
    padding: 10px 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    border: 1px solid #dee2e6;
}

.volume-discount-table td {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    vertical-align: middle;
}

.volume-discount-input {
    width: 100%;
    max-width: 120px;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
}

.volume-discount-input:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* =============================================================================
   TASK-11-15: Стили для калькулятора - чекбоксы "для всех"
   ============================================================================= */

/* Контейнеры для материала и количества */
.material-container,
.quantity-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}


/* Чекбоксы управления вращением — в одну строку */
.rotation-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-top: 4px;
    padding: 4px 0;
}

.lock-rotation-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6c757d;
    cursor: pointer;
    white-space: nowrap;
}

.lock-rotation-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    width: 14px;
    height: 14px;
}


/* Заблокированные элементы */
.material-select:disabled,
.quantity-input:disabled {
    background-color: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

/* Селект материала */
.material-select {
    min-width: 250px;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
}

/* Поле количества */
.quantity-input {
    width: 70px;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

/* =============================================================================
   TASK-11-15: Стили для подсказок в редакторе материалов
   ============================================================================= */

.inline-input[title]:hover::after {
    content: attr(title);
    position: absolute;
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
}

/* =============================================================================
   TASK-UI-01: Стили для структурированных сообщений об ошибках нестинга
   ============================================================================= */

.error-container {
    margin: 20px 0;
    padding: 20px;
    background-color: #fff3cd;
    border-radius: 8px;
    border-left: 4px solid #ffc107;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.error-container h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: #856404;
    font-size: 18px;
}

.error-item {
    margin-bottom: 20px;
    padding: 16px;
    background-color: #fff;
    border-radius: 6px;
    border-left: 3px solid #dc3545;
}

.error-item:last-child {
    margin-bottom: 0;
}

.error-title {
    margin: 0 0 8px 0;
    color: #d63384;
    font-size: 16px;
    font-weight: 600;
}

.error-message {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
}

.error-help-list {
    margin: 0;
    padding-left: 20px;
    color: #666;
    font-size: 13px;
}

.error-help-list li {
    margin-bottom: 4px;
}

/* Типы ошибок - цветовое кодирование */
.error-type-PART_TOO_LARGE {
    border-left-color: #fd7e14;
}

.error-type-INVALID_GEOMETRY {
    border-left-color: #dc3545;
}

.error-type-EMPTY_PARTS {
    border-left-color: #6c757d;
}

.error-type-INVALID_SHEET {
    border-left-color: #17a2b8;
}

.error-type-NO_VALID_PARTS {
    border-left-color: #6c757d;
}

.error-type-ALGORITHM_ERROR {
    border-left-color: #6610f2;
}

.error-type-COST_CALCULATION_ERROR {
    border-left-color: #20c997;
}

.error-type-VISUALIZATION_ERROR {
    border-left-color: #007bff;
}

/* =============================================
 * TASK-11-51: Plan limit error styles
 * =============================================
 */

/* План лимит ошибка - специальный стиль */
.error-container.plan-limit-error {
    background-color: #fff3e0;
    border-left-color: #ff9800;
}

.error-container.plan-limit-error h3 {
    color: #e65100;
}

.error-container.feature-not-available {
    background-color: #fce4ec;
    border-left-color: #e91e63;
}

.error-container.feature-not-available h3 {
    color: #c2185b;
}

/* Информация о лимите */
.limit-info {
    margin: 12px 0;
    padding: 10px 16px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    font-size: 14px;
    color: #555;
}

.limit-info strong {
    color: #333;
}

/* Кнопки действий для апгрейда */
.plan-upgrade-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.plan-upgrade-actions .btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.plan-upgrade-actions .btn-primary {
    background-color: #2196f3;
    color: white;
    border: none;
}

.plan-upgrade-actions .btn-primary:hover {
    background-color: #1976d2;
}

.plan-upgrade-actions .btn-secondary {
    background-color: white;
    color: #666;
    border: 1px solid #ddd;
}

.plan-upgrade-actions .btn-secondary:hover {
    background-color: #f5f5f5;
    border-color: #ccc;
}

/* Модальное окно лимита */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content.plan-limit-modal {
    background: white;
    border-radius: 12px;
    padding: 0;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.plan-limit-modal .modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.plan-limit-modal .modal-close:hover {
    color: #333;
}

.plan-limit-modal .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.plan-limit-modal .modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.plan-limit-modal .modal-body {
    padding: 20px 24px;
}

.plan-limit-modal .modal-body p {
    margin: 0 0 12px 0;
    color: #555;
    line-height: 1.5;
}

.plan-limit-modal .modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.plan-limit-modal .modal-footer .btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.plan-limit-modal .modal-footer .btn-primary {
    background-color: #2196f3;
    color: white;
    border: none;
    text-decoration: none;
}

.plan-limit-modal .modal-footer .btn-primary:hover {
    background-color: #1976d2;
}

.plan-limit-modal .modal-footer .btn-secondary {
    background-color: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
}

.plan-limit-modal .modal-footer .btn-secondary:hover {
    background-color: #eee;
}

/* Информация об отсутствии данных */
.no-data-info {
    padding: 16px;
    background-color: #e9ecef;
    border-radius: 6px;
    text-align: center;
}

.no-data {
    margin: 0 0 8px 0;
    color: #6c757d;
    font-size: 14px;
}

.no-data-hint {
    margin: 0;
    color: #868e96;
    font-size: 12px;
    font-style: italic;
}

/* Информация об отсутствии диаграммы */
.no-diagram-info {
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    text-align: center;
}

.no-diagram-info h4 {
    margin: 0 0 12px 0;
    color: #495057;
}

.no-diagram-message {
    margin: 0 0 8px 0;
    color: #6c757d;
    font-size: 14px;
}

.no-diagram-hint {
    margin: 0;
    color: #868e96;
    font-size: 12px;
    font-style: italic;
}

/* =============================================================================
   TASK-13-07: Feedback report button & modal
   ============================================================================= */

/* Trigger button — subtle but noticeable */
.feedback-report-trigger {
    margin: 12px 0;
    text-align: left;
}

.feedback-report-btn {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
}

.feedback-report-btn:hover {
    border-color: #f59e0b;
    color: #f59e0b;
    background: #fffbeb;
}

/* Feedback overlay — extends .modal-overlay base (z-index override for stacking) */
.feedback-modal-overlay {
    z-index: 1001;
}

/* Modal content */
.feedback-modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 460px;
    width: 90%;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: modalSlideIn 0.3s ease;
}

.feedback-modal h4 {
    margin: 0 0 4px 0;
    font-size: 18px;
    color: #333;
}

.feedback-subtitle {
    margin: 0 0 16px 0;
    font-size: 13px;
    color: #888;
}

/* Close button */
.feedback-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.feedback-close:hover {
    color: #333;
}

/* Reason chips */
.feedback-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.feedback-reason-chip {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
    user-select: none;
}

.feedback-reason-chip:hover {
    border-color: #f59e0b;
    color: #f59e0b;
    background: #fffbeb;
}

.feedback-reason-chip.selected {
    border-color: #f59e0b;
    background: #f59e0b;
    color: white;
}

/* Comment section */
.feedback-comment-section {
    margin-bottom: 16px;
}

.feedback-comment-section label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}

.feedback-comment-section textarea {
    width: 100%;
    min-height: 70px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}

.feedback-comment-section textarea:focus {
    border-color: #f59e0b;
    outline: none;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

/* Actions */
.feedback-actions {
    margin-bottom: 12px;
}

.feedback-submit-btn {
    width: 100%;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: #f59e0b;
    color: white;
    transition: all 0.2s;
}

.feedback-submit-btn:hover:not(:disabled) {
    background: #d97706;
}

.feedback-submit-btn:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

.feedback-submit-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Note */
.feedback-note {
    margin: 0;
    font-size: 11px;
    color: #aaa;
    text-align: center;
}

/* Success state */
.feedback-success {
    text-align: center;
    padding: 12px 0;
}

.feedback-success h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #16a34a;
}

.feedback-success p {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: #666;
}

.feedback-telegram-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #0088cc 0%, #0077b5 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 12px;
}

.feedback-telegram-btn:hover {
    background: linear-gradient(135deg, #0077b5 0%, #006699 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
}

.feedback-close-btn {
    display: block;
    margin: 8px auto 0;
    background: none;
    border: none;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
}

.feedback-close-btn:hover {
    color: #333;
}

/* Responsive */
@media (max-width: 768px) {
    .feedback-modal {
        max-width: 95%;
        padding: 16px;
    }

    .feedback-reason-chip {
        font-size: 12px;
        padding: 6px 10px;
    }
}
