/* ===== ОБЩИЕ СТИЛИ ДЛЯ ПОИСКА И ФИЛЬТРОВ ===== */
.search-container {
    margin-bottom: 20px;
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-result-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.search-result-item:hover,
.search-result-item.active {
    background-color: #f8f9fa;
}

.table-responsive {
    margin-top: 20px;
}

.search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.mobile-search-icon {
    display: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: url('/static/purchases/icons/search.png') no-repeat center center;
    background-size: contain;
    border: none;
    cursor: pointer;
    z-index: 5;
}

/* Стили для фильтра статусов и типов */
.filter-container {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    background-color: #f8f9fa;
}

.filter-container .form-check {
    margin-right: 15px;
    display: inline-flex;
    align-items: center;
}

.filter-container .form-check-input {
    margin-right: 5px;
}

/* Стили для кнопки очистки фильтра */
.clear-filter-btn {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
    transition: all 0.3s ease;
    background-color: #f8f9fa;
    border-color: #6c757d;
}

.clear-filter-btn:hover {
    background-color: #e2e6ea;
    border-color: #545b62;
}

/* Иконки в кнопке */
.clear-filter-btn i.fas {
    font-size: 0.875em;
}

.clear-filter-btn i.fa-filter {
    margin-right: 4px;
}

.clear-filter-btn i.fa-times {
    margin-left: 4px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .mobile-search-icon {
        display: block;
    }

    .search-input {
        padding-right: 40px;
    }

    .filter-container .form-check {
        display: block;
        margin-bottom: 5px;
    }

    .clear-filter-btn {
        max-width: 200px;
        font-size: 0.875rem;
        padding: 0.25rem 0.5rem;
    }
}

/* ===== ОБЩИЕ СТИЛИ ДЛЯ ОКНА ПРЕДПРОСМОТРА ===== */
.preview-container {
    position: fixed;
    right: 5px;
    top: 5px;
    bottom: 5px;
    z-index: 9999;
    background: white;
    border: 1px solid #ccc;
    border-radius: 12px;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
    width: 600px;
    max-width: 600px;
    display: none;
    flex-direction: column;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.preview-container.show {
    opacity: 1;
    transform: translateX(0);
    display: flex;
}

.preview-header {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    padding: 12px 20px;
    border-bottom: 1px solid #dee2e6;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.preview-header h6 {
    margin: 0;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.preview-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.preview-content {
    flex: 1;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.preview-info {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.preview-info-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.875rem;
}

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

.preview-info-item i {
    width: 16px;
    margin-right: 8px;
    text-align: center;
    color: #6c757d;
}

.preview-table-container {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.preview-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 20px;
}

.preview-table th {
    background-color: #f8f9fa;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
    top: 0;
    z-index: 10;
}

.preview-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.preview-table tr:hover td {
    background-color: #f5f7fa;
}

.preview-table .quantity-col {
    text-align: center;
    white-space: nowrap;
    width: 80px;
}

.preview-table .unit-col {
    text-align: center;
    white-space: nowrap;
    width: 60px;
    color: #6c757d;
}

.preview-table .name-col {
    min-width: 200px;
}

/* Стили для сервисных работ */
.service-row {
    background-color: #f8f9fa;
    font-weight: 600;
}

.service-item-row {
    background-color: #fff;
}

.service-item-name {
    padding-left: 30px !important;
    position: relative;
}

.service-item-name::before {
    content: "↳";
    position: absolute;
    left: 15px;
    color: #6c757d;
}

/* Иконка для услуг в списке */
.service-icon {
    margin-left: 8px;
    color: #17a2b8;
    font-size: 1.1em;
}

/* Стили для ссылок */
.preview-links {
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
    background-color: #f8f9fa;
    flex-shrink: 0;
}

.preview-links h6 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #495057;
}

.comprop-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.comprop-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    font-size: 0.8rem;
    text-decoration: none;
    color: #495057;
    transition: all 0.2s;
}

.comprop-badge:hover {
    background-color: #007bff;
    color: white;
    text-decoration: none;
}

.comprop-badge.valid {
    background-color: #d4edda;
    color: #155724;
}

.comprop-badge.valid:hover {
    background-color: #28a745;
    color: white;
}

.comprop-badge i {
    margin-right: 4px;
}

.detail-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background-color: #007bff;
    color: white;
    border-radius: 4px;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background-color 0.2s;
}

.detail-link:hover {
    background-color: #0056b3;
    color: white;
    text-decoration: none;
}

.detail-link i {
    margin-right: 6px;
}

.external-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background-color: #6c757d;
    color: white;
    border-radius: 4px;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background-color 0.2s;
    margin-left: 8px;
}

.external-link:hover {
    background-color: #545b62;
    color: white;
    text-decoration: none;
}

.external-link i {
    margin-right: 6px;
}

/* Стили состояния предпросмотра */
.preview-loading,
.preview-error,
.preview-empty {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
}

.preview-error {
    color: #dc3545;
}

.preview-loading i,
.preview-error i,
.preview-empty i {
    font-size: 2rem;
    margin-bottom: 15px;
    display: block;
}

/* Эффект при наведении на строки таблицы */
.hover-trigger-row {
    position: relative;
}

.hover-trigger-row:hover {
    background-color: #f5f7fa;
    cursor: alias;
}

/* Кастомные полосы прокрутки */
.preview-table-container::-webkit-scrollbar {
    width: 6px;
}

.preview-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.preview-table-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.preview-table-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.search-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Адаптивность для окна предпросмотра */
@media (max-width: 768px) {
    .preview-container {
        width: 95%;
        max-width: 95%;
        left: 2.5%;
        right: 2.5%;
        top: 2.5%;
        bottom: 2.5%;
    }

    .preview-table .name-col {
        min-width: 150px;
    }
}

@media (max-width: 576px) {
    .preview-header {
        padding: 10px 15px;
    }

    .preview-table-container {
        padding: 15px;
    }

    .preview-table th,
    .preview-table td {
        padding: 8px 10px;
    }
}

/* Стили для предпросмотра КП */
.service-header {
    background-color: #f8f9fa;
    font-weight: 600;
}

.service-group {
    background-color: #fff3cd;
}

.comprop-row .fa-tools {
    font-size: 0.9em;
}

/* Стили для иконок статуса КП */
.fa-check-circle.text-success,
.fa-times-circle.text-danger {
    font-size: 1.1em;
}


/* ===== ОКНО КОРЗИНЫ (слева) ===== */
.cart-container {
    position: fixed;
    left: 5px;
    top: 5px;
    bottom: 5px;
    z-index: 9999;
    background: white;
    border: 1px solid #ccc;
    border-radius: 12px;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
    width: 450px;
    max-width: calc(100% - 10px);
    height: 600px;
    max-height: calc(100% - 20px);
    display: none;
    flex-direction: column;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.cart-container.show {
    opacity: 1;
    transform: translateX(0);
    display: flex;
}

.cart-header {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.cart-header h6 {
    margin: 0;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.cart-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.cart-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    min-height: 0;
}

.department-cart {
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.department-header {
    background-color: #f8f9fa;
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s;
}

.department-header:hover {
    background-color: #e9ecef;
}

.department-header .badge {
    background-color: #28a745;
    color: white;
    border-radius: 20px;
    padding: 3px 8px;
    font-size: 0.75rem;
}

.department-items {
    padding: 10px;
    background: white;
}

.cart-table {
    width: 100%;
    font-size: 0.85rem;
}

.cart-table th {
    text-align: left;
    padding: 8px 5px;
    border-bottom: 1px solid #dee2e6;
    color: #495057;
}

.cart-table td {
    padding: 8px 5px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.cart-item-name a {
    color: #007bff;
    text-decoration: none;
}

.cart-item-name a:hover {
    text-decoration: underline;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.quantity-control input {
    width: 50px;
    text-align: center;
    padding: 3px;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

.quantity-control button {
    background: #f8f9fa;
    border: 1px solid #ced4da;
    border-radius: 4px;
    width: 26px;
    cursor: pointer;
    transition: all 0.2s;
}

.quantity-control button:hover {
    background: #e2e6ea;
}

.remove-item {
    color: #dc3545;
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.remove-item:hover {
    transform: scale(1.1);
}

.cart-actions {
    margin-top: 15px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-clear-cart {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-clear-cart:hover {
    background-color: #c82333;
}

.empty-cart-message {
    text-align: center;
    padding: 30px;
    color: #6c757d;
}

@media (max-width: 576px) {
    .cart-container {
        width: 95%;
        left: 2.5%;
        right: 2.5%;
    }
    .cart-table th, .cart-table td {
        font-size: 0.75rem;
        padding: 5px 3px;
    }
    .quantity-control input {
        width: 40px;
    }
}

/* ===== БЛОК СОЗДАНИЯ ДОКУМЕНТА ИЗ КОРЗИНЫ ===== */
.cart-doc-creation {
    margin-top: 15px;
    padding: 12px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Призыв к действию */
.cart-action-hint {
    font-size: 0.875rem;
    color: #495057;
    text-align: center;
    line-height: 1.4;
}

/* Название отделения — акцент в зелёной теме корзины */
.cart-action-dept {
    font-weight: 600;
    color: #28a745;
}

/* Ряд с элементами управления */
.cart-action-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Современный кастомный select */
#doc-type-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2328a745' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 6px 34px 6px 12px;
    font-size: 0.875rem;
    color: #495057;
    cursor: pointer;
    min-width: 180px;
    flex: 1;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    outline: none;
}

#doc-type-select:hover {
    border-color: #28a745;
    background-color: #f8fff8;
}

#doc-type-select:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.18);
    background-color: #ffffff;
}

/* Кнопка создания документа */
.btn-create-doc {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.25);
}

.btn-create-doc:hover:not(:disabled) {
    filter: brightness(1.08);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.35);
    transform: translateY(-1px);
}

.btn-create-doc:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(40, 167, 69, 0.25);
}

.btn-create-doc:disabled {
    background: linear-gradient(135deg, #adb5bd 0%, #868e96 100%);
    cursor: not-allowed;
    box-shadow: none;
}

/* ===== БЛОК ДЕЙСТВИЙ С КОРЗИНОЙ (ВСЕГДА ВИДИМ) ===== */
.cart-footer-actions {
    margin-top: 20px;
    display: flex;
    justify-content: left;
}

/* Адаптивность */
@media (max-width: 576px) {
    .cart-action-controls {
        flex-direction: column;
        align-items: stretch;
    }
    #doc-type-select,
    .btn-create-doc {
        width: 100%;
        min-width: 0;
    }
}