/* CRM Enhancements CSS */

/* Стили для сортируемых заголовков */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s ease;
}

.sortable:hover {
    background-color: #f8f9fa;
}

.sortable i {
    margin-left: 5px;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.sortable:hover i {
    opacity: 1;
}

/* Стили для бейджей статусов */
.badge {
    font-size: 0.75em;
    padding: 0.25em 0.5em;
    border-radius: 0.25rem;
}

.badge-primary {
    background-color: #007bff;
    color: white;
}

.badge-warning {
    background-color: #ffc107;
    color: #212529;
}

.badge-success {
    background-color: #28a745;
    color: white;
}

.badge-danger {
    background-color: #dc3545;
    color: white;
}

/* Улучшенные фильтры */
.filters {
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.filters .form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
}

.filters .form-control-sm {
    font-size: 0.875rem;
}

/* Компактная карточка заявки */
.lead-detail-card .form-control-sm {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

.lead-detail-card .form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.lead-detail-card .btn-sm {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

/* Улучшенная таблица */
.table-container {
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: white;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    width: 100%;
    max-width: 100%;
    position: relative;
}

.table {
    margin-bottom: 0;
    min-width: 1400px; /* Увеличиваем минимальную ширину для всех колонок */
    width: max-content;
    table-layout: auto;
}

.table th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #212529;
    white-space: nowrap;
    position: relative;
    padding: 0.75rem 0.5rem;
    min-width: 80px;
    text-shadow: none;
}

.table th i {
    color: #6c757d;
    margin-left: 5px;
}

.table td {
    vertical-align: middle;
    white-space: nowrap;
    padding: 0.5rem;
    border-bottom: 1px solid #dee2e6;
    color: #212529;
    background-color: white;
}

.table td:first-child {
    font-weight: 600;
    color: #007bff;
}

/* Улучшенная видимость текста */
.table td a {
    color: #007bff;
    text-decoration: none;
    font-weight: 600;
}

.table td a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Контрастность для всех ячеек */
.table tbody tr {
    background-color: white;
}

.table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.table tbody tr:hover {
    background-color: #e3f2fd;
}

/* Фиксированные ячейки */
.table td.fixed-left {
    background-color: white !important;
    border-right: 2px solid #dee2e6;
}

.table tbody tr:nth-child(even) .table td.fixed-left {
    background-color: #f8f9fa !important;
}

.table tbody tr:hover .table td.fixed-left {
    background-color: #e3f2fd !important;
}

/* Изменение размера колонок */
.table th.resizable {
    position: relative;
}

.table th.resizable::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    cursor: col-resize;
    border-right: 2px solid transparent;
}

.table th.resizable:hover::after {
    background: #007bff;
    border-right: 2px solid #007bff;
}

/* Перетаскивание колонок */
.table th.draggable {
    cursor: move;
    user-select: none;
}

.table th.dragging {
    opacity: 0.5;
    background-color: #e3f2fd;
}

.table th.drag-over {
    border-left: 3px solid #007bff;
}

/* Фиксированные колонки */
.table th.fixed-left {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: #e9ecef !important;
    border-right: 2px solid #dee2e6;
    color: #212529;
    font-weight: 700;
}

.table td.fixed-left {
    position: sticky;
    left: 0;
    z-index: 9;
    background-color: white !important;
    border-right: 2px solid #dee2e6;
    color: #007bff;
    font-weight: 600;
}

/* Индикатор прокрутки */
.scroll-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.table-container:hover .scroll-indicator {
    opacity: 1;
}

/* Стили для полосы прокрутки */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Принудительная видимость прокрутки */
.table-container {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* Ссылки на ID заявок */
.lead-id-link {
    color: #007bff;
    text-decoration: none;
    font-weight: 600;
}

.lead-id-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Адаптивность */
@media (max-width: 768px) {
    .filters .col-md-2,
    .filters .col-md-3 {
        margin-bottom: 0.5rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .lead-detail-card .col-md-2,
    .lead-detail-card .col-md-4,
    .lead-detail-card .col-md-6 {
        margin-bottom: 0.5rem;
    }
}

/* Анимации */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Уведомления */
.alert {
    border: none;
    border-radius: 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Модальные окна */
.modal-content {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
    border-radius: 0.5rem 0.5rem 0 0;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
    border-radius: 0 0 0.5rem 0.5rem;
}
