/* Стили для отображения Excel таблиц */

.order-excel-table {
    margin-top: 24px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.order-excel-table h4 {
    margin: 0;
    padding: 16px 20px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.excel-table-container {
    min-height: 200px;
    position: relative;
}

/* Индикатор загрузки */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #666;
}

.loading-spinner .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}
.excel-table-header {
    background: linear-gradient(180deg, #f7f7f7 0%, #e8e8e8 100%);
    padding: 12px 16px;
    border-bottom: 1px solid #d4d4d4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.table-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.file-name {
    font-weight: 600;
    color: #1f4e79;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.table-size {
    color: #666666;
    font-size: 11px;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #d0d0d0;
}

.truncated-notice {
    color: #d83b01;
    font-size: 11px;
    font-weight: 500;
    background: #fff4ce;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #ffb900;
}


.excel-table-wrapper {
    overflow: auto;
    max-height: 80vh; /* Используем 80% высоты экрана для показа всех строк */
    border: 1px solid #d4d4d4;
    border-top: none;
    position: relative;
    background: #fff;
}

.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9px;
    font-family: 'Montserrat', 'Segoe UI', 'Calibri', Arial, sans-serif;
    background: white;
}

.excel-table thead th {
    position: sticky;
    top: 0;
    z-index: 15;
}

.excel-table th {
    background: linear-gradient(180deg, #f2f2f2 0%, #e6e6e6 100%);
    color: #323130;
    padding: 3px 5px;
    text-align: left;
    font-weight: 600;
    font-size: 8px;
    font-family: 'Montserrat', 'Segoe UI', 'Calibri', Arial, sans-serif;
    border-right: 1px solid #d4d4d4;
    border-bottom: 1px solid #d4d4d4;
    position: sticky;
    top: 0;
    z-index: 16;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    min-width: 60px;
}

.excel-table thead th::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
}

.excel-table th:first-child {
    background: linear-gradient(180deg, #f8f8f8 0%, #ebebeb 100%);
    text-align: center;
    font-weight: 700;
    color: #605e5c;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
}

.excel-table th:last-child {
    border-right: 1px solid #d4d4d4;
}

.excel-table td {
    padding: 2px 4px;
    border-bottom: 1px solid #e1dfdd;
    border-right: 1px solid #e1dfdd;
    font-size: 8px;
    font-family: 'Montserrat', 'Segoe UI', 'Calibri', Arial, sans-serif;
    line-height: 1.2;
    color: #323130;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    min-width: 60px;
    vertical-align: top;
}

.excel-table td:first-child {
    background: linear-gradient(180deg, #f8f8f8 0%, #f2f2f2 100%);
    text-align: center;
    font-weight: 600;
    color: #605e5c;
    border-right: 1px solid #d4d4d4;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    font-size: 9px;
}

.excel-table td:last-child {
    border-right: 1px solid #e1dfdd;
}

.excel-table tbody tr:hover {
    background-color: #f3f2f1;
    max-width: 400px;
}

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 6px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* Адаптивность */
@media (max-width: 768px) {
    .excel-table-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .table-info {
        justify-content: center;
    }
    
    .sheet-selector {
        justify-content: center;
    }
    
    .excel-table th,
    .excel-table td {
        padding: 6px 4px;
        font-size: 12px;
        min-width: 80px;
    }
    
    .excel-table td {
        max-width: 120px;
    }
}

@media (max-width: 480px) {
    .order-excel-table h4 {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .excel-table-header {
        padding: 8px 16px;
    }
    
    .table-info {
        flex-direction: column;
        gap: 8px;
    }
    
    .excel-table th,
    .excel-table td {
        padding: 4px;
        font-size: 11px;
        min-width: 60px;
    }
    
    .excel-table td {
        max-width: 100px;
    }
}

/* Скроллбар для таблицы */
.excel-table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.excel-table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.excel-table-wrapper::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.excel-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Анимации */
.excel-table-container {
    transition: all 0.3s ease;
}

.excel-table {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Стили для автозамены позиций */
.auto-replace-controls {
    padding: 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 0;
}

.auto-replace-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.auto-replace-buttons .btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.auto-replace-buttons .btn-gray {
    background: #3f3f46;
    border-color: #52525b;
    color: #e5e7eb;
}

.auto-replace-buttons .btn-gray:hover {
    background: #52525b;
    border-color: #71717a;
    color: #f4f4f5;
}

.auto-replace-buttons .btn-secondary {
    background: #6c757d;
    border-color: #6c757d;
    color: white;
}

.auto-replace-buttons .btn-secondary:hover {
    background: #5a6268;
    border-color: #545b62;
}

.auto-replace-buttons .btn-primary {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

.auto-replace-buttons .btn-primary:hover {
    background: #0056b3;
    border-color: #004085;
}

.auto-replace-buttons .btn-warning {
    background: #ffc107;
    border-color: #ffc107;
    color: #212529;
}

.auto-replace-buttons .btn-warning:hover {
    background: #e0a800;
    border-color: #d39e00;
}

.auto-replace-buttons .btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Красная рамка для позиций с лучшим предложением */
.excel-table tbody tr.has-better-offer {
    border: 2px solid #dc3545 !important;
    background-color: rgba(220, 53, 69, 0.05) !important;
}

.excel-table tbody tr.has-better-offer td {
    border-color: #dc3545 !important;
}

/* Анимация для новых данных */
.excel-table tbody tr.auto-replaced {
    animation: highlightReplaced 2s ease;
}

@keyframes highlightReplaced {
    0% {
        background-color: rgba(40, 167, 69, 0.3);
    }
    100% {
        background-color: transparent;
    }
}

/* Стили для темной темы */
[data-theme="dark"] .auto-replace-controls {
    background: #2d3748;
    border-color: #4a5568;
}

[data-theme="dark"] .auto-replace-buttons .btn-secondary {
    background: #4a5568;
    border-color: #4a5568;
}

[data-theme="dark"] .auto-replace-buttons .btn-secondary:hover {
    background: #2d3748;
    border-color: #2d3748;
}

[data-theme="dark"] .excel-table tbody tr.has-better-offer {
    background-color: rgba(220, 53, 69, 0.1) !important;
}
