body {
    background-color: #f5f5f5;
    padding-bottom: 30px;
}

.card {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    margin-bottom: 2rem;
    border-radius: 0.5rem;
    border: none;
}

.card-header {
    background-color: #f8f9fa;
    font-weight: bold;
    border-top-left-radius: 0.5rem !important;
    border-top-right-radius: 0.5rem !important;
    padding: 1rem;
}

table {
    font-size: 0.9rem;
    table-layout: fixed;
    position: relative;
}

.table {
    margin-bottom: 0;
}

/* Контейнер таблицы должен позволять overflow для tooltip'ов */
.table-responsive-adaptive {
    overflow: visible;
}

/* На мобильных возвращаем overflow-x: auto для горизонтальной прокрутки */
@media (max-width: 991.98px) {
    .table-responsive-adaptive {
        overflow-x: auto;
        overflow-y: visible;
    }
}

/* При наведении на строку таблицы поднимаем z-index */
#orders-table tr:hover {
    position: relative;
    z-index: 100;
}

.table td, .table th {
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Фиксированные ширины столбцов */
#orders-table th:nth-child(1),
#orders-table td:nth-child(1) {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
}

#orders-table th:nth-child(2),
#orders-table td:nth-child(2) {
    width: 150px !important;
    min-width: 150px !important;
    max-width: 150px !important;
}

#orders-table th:nth-child(3),
#orders-table td:nth-child(3) {
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
}

/* Столбец "Товар" - увеличенная ширина для лучшего отображения */
#orders-table th:nth-child(4),
#orders-table td:nth-child(4) {
    width: 260px !important;
    min-width: 260px !important;
    max-width: 260px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

/* Центрирование заголовка и ячеек "Статус" для ПК версии */
@media (min-width: 992px) {
    #orders-table th:nth-child(9),
    #orders-table td:nth-child(9) {
        text-align: center !important;
    }
}

/* Tooltip для длинных названий товаров */
#orders-table td:nth-child(4) {
    position: relative;
}

#orders-table td:nth-child(4):hover::after {
    content: attr(data-full-text);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: normal;
    z-index: 9999;
    max-width: 350px;
    word-wrap: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.4;
    pointer-events: none;
}

/* Добавляем стрелку указывающую вверх */
#orders-table td:nth-child(4):hover::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid rgba(0, 0, 0, 0.9);
    z-index: 10000;
    pointer-events: none;
}

/* Скрываем тултипы на мобильных и планшетных устройствах */
@media (max-width: 991.98px) {
    #orders-table td:nth-child(4):hover::after,
    #orders-table td:nth-child(4):hover::before {
        display: none;
    }
}

#orders-table th:nth-child(5),
#orders-table td:nth-child(5) {
    width: 100px !important;
    min-width: 100px !important;
    max-width: 100px !important;
}

#orders-table th:nth-child(6),
#orders-table td:nth-child(6) {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
}

#orders-table th:nth-child(7),
#orders-table td:nth-child(7) {
    width: 130px !important;
    min-width: 130px !important;
    max-width: 130px !important;
}

#orders-table th:nth-child(8),
#orders-table td:nth-child(8) {
    width: 100px !important;
    min-width: 100px !important;
    max-width: 100px !important;
}

/* Фиксированная ширина для колонки статуса */
#orders-table th:nth-child(9),
#orders-table td:nth-child(9) {
    width: 140px !important;
    min-width: 140px !important;
    max-width: 140px !important;
}

#orders-table th:nth-child(10),
#orders-table td:nth-child(10) {
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
}

#orders-table th:nth-child(11),
#orders-table td:nth-child(11) {
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
}

/* Исправляем колонку действий */
#orders-table th:nth-child(12),
#orders-table td:nth-child(12) {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    white-space: nowrap !important;
    overflow: visible !important;
    position: relative !important;
    padding: 0.5rem 0.25rem !important;
}

.actions {
    white-space: nowrap !important;
    padding: 0 !important;
    text-align: center !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.2rem !important;
}

/* Компактные стили для кнопок в столбце действий */
.actions .btn {
    margin: 0 !important;
    font-size: 0.6rem !important;
    padding: 0.15rem 0.25rem !important;
    white-space: nowrap !important;
    min-width: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 0.2rem !important;
    line-height: 1 !important;
    width: 24px !important;
    height: 24px !important;
}

/* Компактные размеры для иконок в кнопках */
.actions .btn i {
    font-size: 0.6rem !important;
    margin: 0 !important;
}

/* Специальные стили для кнопок редактирования - компактные */
.actions .edit-btn {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #212529 !important;
}

.actions .delete-btn {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: white !important;
}

.actions .save-btn {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
    color: white !important;
}

.actions .cancel-btn {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: white !important;
}

/* Мобильная адаптация для действий */
@media (max-width: 768px) {
    #orders-table th:nth-child(12),
    #orders-table td:nth-child(12) {
        width: 60px !important;
        min-width: 60px !important;
        max-width: 60px !important;
    }
    
    .actions .btn {
        font-size: 0.5rem !important;
        padding: 0.1rem 0.2rem !important;
        width: 20px !important;
        height: 20px !important;
    }
    
    .actions .btn i {
        font-size: 0.5rem !important;
    }
}

#search-orders {
    width: 200px;
    border-radius: 1.5rem;
    padding-left: 1rem;
}

.badge {
    padding: 0.5em 0.8em;
    border-radius: 0.5rem;
}

.form-control, .form-select {
    border-radius: 0.375rem;
}

.btn {
    border-radius: 0.375rem;
}

header.bg-primary {
    border-radius: 0 0 1rem 1rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

/* Кастомный стиль для заголовка */
.bg-custom-green {
    background: linear-gradient(135deg, #6cc04a, #28a745) !important;
}

header.bg-custom-green {
    border-radius: 0 0 1rem 1rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

/* Стили для дашборда */
#dashboard .card {
    border-radius: 1rem;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

#dashboard .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.2);
}

#dashboard .card.dashboard-active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-5px);
    box-shadow: 0 0.75rem 1.5rem rgba(102, 126, 234, 0.4);
}

#dashboard .card.dashboard-active .text-muted,
#dashboard .card.dashboard-active .text-dark {
    color: rgba(255, 255, 255, 0.9) !important;
}

#dashboard .card-body {
    padding: 1.5rem;
}

#dashboard h2 {
    font-size: 2rem;
    margin-top: 0.5rem;
    margin-bottom: 0;
}

/* Стили для бейджей статусов */
.status-badge {
    font-size: 0.85rem;
    padding: 0.4em 0.8em;
    border-radius: 0.5rem;
    font-weight: 500;
}

.badge.bg-primary {
    background-color: #0d6efd !important;
}

.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #212529 !important;
}

.badge.bg-info {
    background-color: #0dcaf0 !important;
    color: #212529 !important;
}

.badge.bg-success {
    background-color: #198754 !important;
}

.badge.bg-danger {
    background-color: #dc3545 !important;
}

.badge.bg-secondary {
    background-color: #6c757d !important;
}

/* Стили для inline-редактирования */
.editable-field {
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s ease;
}

.editable-field:hover {
    background-color: #f8f9fa;
}

/* Специальные стили для поля статуса */
.status-cell.editable-field:hover {
    background-color: #e3f2fd;
}

.status-cell.editable-field:hover .status-badge {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

.editable-field.editing {
    padding: 0;
    background-color: transparent;
    vertical-align: middle;
}

.editable-field.editing input,
.editable-field.editing select {
    margin: 0;
    line-height: 1.4;
    height: 34px;
    display: inline-block;
    vertical-align: middle;
}

.editable-field input,
.editable-field select {
    width: 100%;
    border: 2px solid #007bff;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.9rem;
    background-color: #fff;
    vertical-align: middle;
    box-sizing: border-box;
    height: auto;
    min-height: 34px;
}

/* Специальные стили для селектора статуса */
.status-cell.editing select {
    font-size: 0.8rem;
    padding: 4px 6px;
}

.editable-field input:focus,
.editable-field select:focus {
    outline: none;
    border-color: #0056b3;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Кнопки в режиме редактирования */
/* По умолчанию кнопки сохранить и отмена скрыты */
tr .actions .save-btn,
tr .actions .cancel-btn,
.actions .save-btn,
.actions .cancel-btn {
    display: none !important;
}

/* При редактировании скрываем кнопки редактировать и удалить */
tr.row-editing .actions .edit-btn,
tr.row-editing .actions .delete-btn,
.row-editing .actions .edit-btn,
.row-editing .actions .delete-btn {
    display: none !important;
}

/* При редактировании показываем кнопки сохранить и отмена */
tr.row-editing .actions .save-btn,
tr.row-editing .actions .cancel-btn,
.row-editing .actions .save-btn,
.row-editing .actions .cancel-btn {
    display: inline-block !important;
}

@media (max-width: 768px) {
    .col-md-9, .col-md-3 {
        margin-bottom: 2rem;
    }
    
    #search-orders {
        width: 100%;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .card-header .form-group {
        width: 100%;
        margin-top: 10px;
    }
}

/* Стили для выбора менеджеров */
.manager-selection {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    padding: 0.5rem;
    background-color: #fff;
    max-height: 200px;
    overflow-y: auto;
}

.manager-item {
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    background-color: #f8f9fa;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.manager-item:hover {
    background-color: #e9ecef;
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.manager-item.selected {
    background-color: #007bff;
    color: white;
    border-color: #0056b3;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.manager-item.selected:hover {
    background-color: #0056b3;
    color: white;
    transform: translateY(-1px);
}

.manager-item i {
    font-size: 1.1em;
    min-width: 20px;
}

/* Стили для селектора отгрузки */
.shipment-item {
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #dee2e6;
    background-color: #f8f9fa;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.shipment-item:hover {
    background-color: #e9ecef;
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.shipment-item.selected {
    background-color: #f8f9fa;
    color: #007bff;
    border-color: #007bff;
    border-width: 2px;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.shipment-item.selected:hover {
    background-color: #e9ecef;
    color: #0056b3;
    border-color: #0056b3;
    transform: translateY(-1px);
}

.shipment-item i {
    font-size: 1.1em;
    min-width: 20px;
}

/* Стили для поля комментария */
.comment {
    max-width: 250px;
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    font-size: 0.85rem;
    font-style: italic;
    color: #6c757d;
    padding: 0.5rem !important;
}

.comment:empty::before {
    content: "—";
    color: #dee2e6;
    font-style: italic;
}

.comment.editable-field:hover {
    background-color: #f8f9fa;
    color: #495057;
}

/* Стили для редактирования комментария */
.comment.editing input {
    min-height: 60px;
    resize: vertical;
}

/* Стили для узких колонок */
.price, .quantity, .manager {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem !important;
}

.status-cell {
    padding: 0.25rem 0.5rem !important;
}

.status-badge {
    font-size: 0.75rem;
    padding: 0.3em 0.6em;
}

/* Компактные стили для таблицы */
.table td {
    padding: 0.5rem;
    vertical-align: middle;
}

/* Дополнительные стили для компактности колонок */
.price {
    text-align: center;
    font-weight: 500;
    min-width: 130px;
}

.quantity {
    text-align: center;
    font-weight: 500;
    min-width: 100px;
}

.manager {
    max-width: 100px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-cell {
    min-width: 120px;
    text-align: center;
}

.status-badge {
    display: inline-block;
    width: 100%;
    text-align: center;
}

/* Стили для мобильных устройств */
@media (max-width: 768px) {
    .comment {
        max-width: 200px;
        font-size: 0.8rem;
    }
    
    .price, .quantity, .manager {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem !important;
    }
    
    .status-badge {
        font-size: 0.7rem;
        padding: 0.2em 0.5em;
    }
    
    .status-cell.editing select {
        font-size: 0.75rem;
        padding: 2px 4px;
    }
}

/* Product autocomplete styles */
.product-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.suggestion-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.15s ease-in-out;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background-color: #f8f9fa;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-title {
    font-weight: 500;
    color: #212529;
    margin-bottom: 0.25rem;
}

.suggestion-price {
    font-size: 0.875rem;
    color: #28a745;
    font-weight: 600;
}

.suggestion-brand {
    font-size: 0.75rem;
    color: #6c757d;
}

/* Стили для фиксированных колонок */
.table th:nth-child(2), /* Клиент */
.table td:nth-child(2) {
    width: 150px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table th:nth-child(3), /* Телефон */
.table td:nth-child(3) {
    width: 120px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table th:nth-child(4), /* Товар */
.table td:nth-child(4) {
    width: 200px;
    max-width: 200px;
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    vertical-align: top;
    text-align: left;
    padding: 0.75rem 0.5rem;
    line-height: 1.2;
}

/* Добавляем tooltip для обрезанного текста */
.table td[title] {
    cursor: help;
}

/* Стили для интерактивных карточек дашборда */
#dashboard .card {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#dashboard .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.2);
}

#dashboard .card.dashboard-active {
    transform: translateY(-2px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.25);
    border: 2px solid #fff;
    outline: 2px solid #007bff;
}

/* Карточка общей суммы - она сбрасывает фильтры, но имеет другой стиль активации */
#dashboard .card:last-child:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.2);
}

#dashboard .card:last-child.dashboard-active {
    outline-color: #17a2b8;
}

/* Компактные стили для формы добавления заказа */
.col-md-3 .card {
    font-size: 0.9rem;
}

.col-md-3 .card-header {
    padding: 0.75rem 1rem;
}

.col-md-3 .card-body {
    padding: 1rem;
}

.col-md-3 .mb-3 {
    margin-bottom: 0.75rem !important;
}

.col-md-3 .form-label {
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.col-md-3 .form-control,
.col-md-3 .form-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.col-md-3 .manager-selection {
    padding: 0.5rem;
    max-height: 150px;
}

.col-md-3 .manager-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

.col-md-3 .btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.col-md-3 h4 {
    font-size: 1.1rem;
    margin-bottom: 0;
}

/* Стили для тегов товаров */
.products-tags {
    min-height: 40px;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
}

.products-tags:empty::before {
    content: "Товары не добавлены";
    color: #6c757d;
    font-style: italic;
    font-size: 0.85rem;
}

.product-tag {
    display: inline-flex;
    align-items: center;
    background-color: #007bff;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    gap: 0.25rem;
    max-width: 100%;
    animation: fadeIn 0.3s ease-in-out;
}

.product-tag .product-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.product-tag .product-name {
    font-weight: 600;
    line-height: 1;
}

.product-tag .product-details {
    font-size: 0.6rem;
    opacity: 0.9;
    line-height: 1;
}

.product-tag .remove-product {
    background: none;
    border: none;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
    margin-left: 0.25rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.product-tag .remove-product:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Адаптация для компактной колонки */
.col-md-3 .product-tag {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
}

.col-md-3 .product-tag .product-details {
    font-size: 0.55rem;
}

.col-md-3 .product-tag .remove-product {
    width: 14px;
    height: 14px;
    font-size: 0.7rem;
}

/* Стили для декомпозированных строк заказов */
tr[data-is-decomposed="true"] {
    border-left: 3px solid #007bff;
}

tr[data-is-decomposed="true"]:not([data-product-index="0"]) {
    border-top: 1px dashed #dee2e6;
}

tr[data-is-decomposed="true"]:not([data-product-index="0"]) td {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

tr[data-is-decomposed="true"][data-product-index="0"] {
    border-top: 2px solid #007bff;
}

/* Визуальная группировка строк одного заказа */
tr[data-is-decomposed="true"] td:first-child::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #007bff;
}

/* Стили для скрытых элементов в дополнительных строках товаров */
tr[data-is-decomposed="true"]:not([data-product-index="0"]) .row-number,
tr[data-is-decomposed="true"]:not([data-product-index="0"]) .customer-name,
tr[data-is-decomposed="true"]:not([data-product-index="0"]) .customer-phone,
tr[data-is-decomposed="true"]:not([data-product-index="0"]) .manager,
tr[data-is-decomposed="true"]:not([data-product-index="0"]) .status-badge,
tr[data-is-decomposed="true"]:not([data-product-index="0"]) .comment,
tr[data-is-decomposed="true"]:not([data-product-index="0"]) .created-at,
tr[data-is-decomposed="true"]:not([data-product-index="0"]) .actions {
    visibility: hidden;
}

/* Подсветка при наведении на группу декомпозированных строк */
tr[data-is-decomposed="true"]:hover ~ tr[data-original-order-id],
tr[data-is-decomposed="true"]:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

/* Стили для групповых заказов */
.grouped-order {
    background-color: #f8f9fa;
    border-left: 4px solid #007bff;
}

.grouped-order:hover {
    background-color: #e9ecef;
}

.product-row {
    background-color: #ffffff;
    border-left: 4px solid #28a745;
    margin-left: 20px;
}

.product-row:hover {
    background-color: #f8f9fa;
}

.product-row td:first-child {
    padding-left: 30px;
}

.grouped-order .product-name button {
    border: none;
    background: none;
    padding: 2px 6px;
    margin-right: 8px;
    border-radius: 3px;
    transition: all 0.2s;
}

.grouped-order .product-name button:hover {
    background-color: #007bff;
    color: white;
}

.grouped-order .product-name button i {
    transition: transform 0.2s;
}

/* Анимация для разворачивания */
.product-row {
    animation: slideIn 0.3s ease-out;
}

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

/* Стили для редактирования групповых строк */
.grouped-order.row-editing {
    background-color: #fff3cd;
    border-left-color: #ffc107;
}

.product-row.row-editing {
    background-color: #d1ecf1;
    border-left-color: #17a2b8;
}

/* Стили для быстрых фильтров по дате */
.date-filter {
    transition: all 0.2s ease-in-out;
    font-weight: 500;
}

.date-filter:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.date-filter.active {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: white !important;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.date-filter.active:hover {
    background-color: #0b5ed7 !important;
    border-color: #0a58ca !important;
}

/* Стили для нового блока товаров в форме */
.product-form-row {
    position: relative;
}

.product-form-row .col-6 {
    position: relative;
}

.product-form-row .product-suggestions {
    left: 15px;
    right: 15px;
    top: calc(100% + 5px);
}

/* Улучшенная мобильная адаптивность для формы товаров */
@media (max-width: 768px) {
    .product-form-row .col-6,
    .product-form-row .col-3 {
        margin-bottom: 0.5rem;
    }
    
    .product-form-row .row.g-2 {
        margin-bottom: 0.5rem;
    }
}

/* Респонсивность для мобильных устройств */
@media (max-width: 768px) {
    .date-filter {
        margin-bottom: 0.25rem;
        font-size: 0.75rem;
    }
    
    .date-filter .bi {
        margin-right: 0.25rem;
    }
    
    .btn-group {
        flex-wrap: wrap;
    }
}

/* Стили для кнопки удаления товара */
.product-delete-btn {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: white !important;
}

.product-delete-btn:hover {
    background-color: #c82333 !important;
    border-color: #bd2130 !important;
    color: white !important;
}

/* Стили для автозаполнения клиента */
.customer-autofill-success {
    background-color: #e8f5e8 !important;
    border: 2px solid #28a745 !important;
    transition: all 0.3s ease;
}

.customer-autofill-loading {
    background-color: #f8f9fa !important;
    background-image: linear-gradient(90deg, #f8f9fa 25%, #e9ecef 50%, #f8f9fa 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

.customer-autofill-not-found {
    background-color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    transition: all 0.3s ease;
}

@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Улучшение подсказки */
.form-text.text-muted {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.form-text.text-muted i {
    margin-right: 0.25rem;
    color: #6c757d;
}

/* Мобильные стили для iPad и мобильных устройств */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .card {
        margin-bottom: 1rem;
        border-radius: 0.25rem;
    }
    
    .card-header {
        padding: 0.75rem;
        font-size: 0.95rem;
    }
    
    /* Улучшенные поля ввода для мобильных */
    .form-control {
        font-size: 16px; /* Предотвращает зум на iOS */
        padding: 0.75rem;
        border-radius: 0.5rem;
        touch-action: manipulation;
    }
    
    /* Специальные стили для полей телефона и имени */
    #customer-phone, #customer-name {
        font-size: 16px;
        padding: 0.875rem;
        min-height: 48px; /* Рекомендуемый размер для сенсорных экранов */
        border-radius: 0.5rem;
        border: 2px solid #ced4da;
        transition: all 0.3s ease;
    }
    
    #customer-phone:focus, #customer-name:focus {
        border-color: #007bff;
        box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
        transform: scale(1.02);
    }
    
    /* Улучшенные кнопки для мобильных */
    .btn {
        min-height: 44px;
        font-size: 16px;
        border-radius: 0.5rem;
        touch-action: manipulation;
    }
    
    .btn-sm {
        min-height: 36px;
        font-size: 14px;
        padding: 0.5rem 0.75rem;
    }
    
    /* Таблица товаров - горизонтальная прокрутка */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: 0.8rem;
    }
    
    .table td, .table th {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    /* Модальные окна на мобильных */
    .modal-content {
        border-radius: 0.5rem;
        margin: 10px;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Поля поиска */
    #search-orders {
        width: 100%;
        border-radius: 0.5rem;
        padding: 0.75rem 1rem;
        font-size: 16px;
    }
}

/* Стили специально для iPad */
@media (min-width: 768px) and (max-width: 1024px) {
    .container-fluid {
        padding-left: 20px;
        padding-right: 20px;
    }
    
    /* Увеличенные поля ввода для удобства на iPad */
    #customer-phone, #customer-name {
        font-size: 18px;
        padding: 1rem;
        min-height: 52px;
    }
    
    .btn {
        font-size: 16px;
        padding: 0.75rem 1.5rem;
    }
    
    .table {
        font-size: 0.9rem;
    }
}

/* Улучшения для сенсорных устройств */
@media (hover: none) and (pointer: coarse) {
    /* Увеличиваем зоны касания */
    .btn, .form-control, .table td a {
        touch-action: manipulation;
    }
    
    /* Убираем hover эффекты на сенсорных устройствах */
    .btn:hover {
        transform: none;
    }
    
    /* Улучшенные состояния автозаполнения для сенсорных экранов */
    .customer-autofill-success {
        border-width: 3px !important;
    }
    
    .customer-autofill-not-found {
        border-width: 3px !important;
    }
    
    /* Анимация нажатия для кнопок */
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Ландшафтная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-dialog {
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .card-header {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
}

/* Высокие плотности пикселей (Retina дисплеи) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .btn, .form-control {
        border-width: 1px;
    }
}

/* Дополнительные стили для очень маленьких экранов */
@media (max-width: 576px) {
    /* Заголовок на очень маленьких экранах */
    header .container-fluid .row {
        flex-direction: column;
    }
    
    header h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem !important;
    }
    
    /* Кнопки в заголовке на маленьких экранах */
    header .d-flex {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    header .btn {
        width: 100% !important;
        justify-content: center;
        min-height: 38px;
    }
    
    /* Убираем скрытие текста на очень маленьких экранах */
    header .d-none.d-sm-inline {
        display: inline !important;
    }
}

/* Для экранов между 576px и 768px */
@media (min-width: 577px) and (max-width: 767px) {
    header .d-flex {
        flex-direction: row !important;
        justify-content: center;
    }
    
    header .btn {
        flex: 1;
        max-width: 150px;
    }
}

/* Стили для выравнивания полей товара в модальном окне */
.modal-body .row.g-2 {
    align-items: end;
    margin-bottom: 0;
}

.modal-body .row.g-2 .col-md-6,
.modal-body .row.g-2 .col-md-3 {
    margin-bottom: 0;
}

.modal-body .row.g-2 .form-label {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.modal-body .row.g-2 .form-control {
    height: 38px;
    font-size: 0.875rem;
}

/* Обеспечиваем одинаковую высоту полей ввода */
.modal-body #product-name,
.modal-body #price,
.modal-body #quantity {
    height: 38px !important;
    line-height: 1.5;
}

/* Дополнительные отступы для кнопки добавления товара */
.modal-body .d-grid.mt-2 {
    margin-top: 0.75rem !important;
}

/* Улучшаем выравнивание в строке товаров */
.modal-body .position-relative .row.g-2 {
    --bs-gutter-x: 0.5rem;
}

/* Стили для тегов товаров */
.products-tags {
    min-height: 20px;
}

.products-tags .product-tag {
    display: inline-block;
    margin: 0.125rem;
}

/* Дополнительные стили для выравнивания в режиме редактирования */
tr.row-editing td {
    vertical-align: middle;
}

/* Обеспечиваем одинаковую высоту всех полей в режиме редактирования */
.editable-field.editing input,
.editable-field.editing select {
    height: 34px;
    display: inline-block;
    vertical-align: middle;
}

/* Специальное выравнивание для текстовых полей */
.editable-field.editing {
    position: relative;
    display: table-cell;
    vertical-align: middle;
}

/* Перенос текста для текстовых колонок ТОЛЬКО на десктопе */
@media (min-width: 769px) {
    .table td.customer-phone,
    .table td.customer-name,
    .table td.product-name,
    .table td.comment {
        white-space: normal !important;
        word-wrap: break-word;
        word-break: break-word;
        overflow: visible;
        text-overflow: unset;
        hyphens: auto;
        vertical-align: top;
        line-height: 1.4;
    }

    /* Числовые и короткие поля оставляем без переноса */
    .table td.unit-price,
    .table td.quantity,
    .table td.total-price,
    .table td.created-at,
    .table td.manager,
    .table td.status-cell {
        white-space: nowrap;
        text-align: center;
        vertical-align: middle;
    }

    /* Для колонки действий тоже без переноса */
    .table td.actions {
        white-space: nowrap;
        text-align: center;
        vertical-align: middle;
    }

    /* Дополнительные стили для улучшения читаемости */
    .table td.comment {
        font-style: italic;
        color: #6c757d;
    }

    /* Выравнивание всех ячеек по верхнему краю для лучшего вида */
    .table td {
        vertical-align: top;
        padding: 0.75rem 0.5rem;
    }
}

/* На мобильных устройствах оставляем исходные стили */
@media (max-width: 768px) {
    .table td {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        vertical-align: middle;
    }
}

/* Выравнивание заголовков таблицы по центру только на десктопе */
@media (min-width: 769px) {
    #orders-table thead th {
        text-align: center !important;
        vertical-align: middle !important;
        font-weight: 600;
        background-color: #f8f9fa;
        border-bottom: 2px solid #dee2e6;
        padding: 0.75rem 0.5rem;
    }
    
    /* Центрируем содержимое числовых колонок */
    #orders-table th:nth-child(1),    /* # */
    #orders-table th:nth-child(5),    /* Цена за ед. */
    #orders-table th:nth-child(6),    /* Кол-во */
    #orders-table th:nth-child(7),    /* Общая цена */
    #orders-table th:nth-child(8),    /* Менеджер */
    #orders-table th:nth-child(9),    /* Статус */
    #orders-table th:nth-child(11),   /* Дата создания */
    #orders-table th:nth-child(12) {  /* Действия */
        text-align: center !important;
    }
    
    /* Текстовые колонки тоже центрируем заголовки */
    #orders-table th:nth-child(2),    /* Клиент */
    #orders-table th:nth-child(3),    /* Телефон */
    #orders-table th:nth-child(4),    /* Товар */
    #orders-table th:nth-child(10) {  /* Комментарий */
        text-align: center !important;
    }
}

/* Принудительное центрирование заголовка "Общая цена" */
@media (min-width: 769px) {
    #orders-table thead tr th:nth-child(7) {
        text-align: center !important;
        text-align-last: center !important;
    }

    /* Принудительное центрирование содержимого колонки "Статус" */
    #orders-table td.status-cell, 
    #orders-table td:nth-child(9) {
        text-align: center !important;
    }
    
    /* Убедимся, что бейджи статусов тоже центрированы */
    #orders-table td.status-cell .status-badge {
        display: inline-block;
        margin: 0 auto;
    }
}

/* На мобильных оставляем как есть */
@media (max-width: 768px) {
    #orders-table thead th {
        text-align: left;
        font-size: 0.875rem;
    }
}

/* Убираем текст из кнопок действий, оставляем только иконки на ПК */
@media (min-width: 769px) {
    .actions .btn .btn-text,
    .actions .btn-sm .btn-text,
    .actions .save-btn .btn-text,
    .actions .cancel-btn .btn-text,
    .actions .edit-btn .btn-text,
    .actions .delete-btn .btn-text {
        display: none !important;
    }
    
    /* Убираем любой текстовый контент из кнопок, кроме иконок */
    .actions .btn {
        font-size: 0 !important; /* Скрываем весь текст */
    }
    
    .actions .btn i {
        font-size: 0.6rem !important; /* Возвращаем размер иконок */
    }
    
    /* Альтернативный способ - если используются spans или другие элементы с текстом */
    .actions .btn span:not(.icon):not([class*="bi"]):not([class*="fa"]) {
        display: none !important;
    }
    
    /* Компактные размеры кнопок только с иконками */
    .actions .btn {
        width: 28px !important;
        height: 28px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* На мобильных можно оставить текст или тоже убрать */
@media (max-width: 768px) {
    .actions .btn {
        width: 24px !important;
        height: 24px !important;
        font-size: 0 !important;
    }
    
    .actions .btn i {
        font-size: 0.5rem !important;
    }
    
    .actions .btn .btn-text {
        display: none !important;
    }
}
