/**
 * Product Selector Modal Styles
 * Адаптивний дизайн для вибору товарів з ієрархією категорій
 */

/* Основний контейнер модального вікна */
.product-selector-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

.modal-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 1001;
    max-height: 90vh;
    width: 90vw;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
}

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

/* Заголовок модального вікна */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    color: #6b7280;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background-color: #f3f4f6;
    color: #374151;
}

/* Пошук */
.modal-search {
    padding: 1rem 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    background-color: #f9fafb;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Основний контент */
.modal-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-width: 900px !important;
}

/* Desktop Layout */
.modal-layout-desktop {
    display: flex;
    height: 100%;
    min-height: 400px;
}

.categories-sidebar {
    width: 300px;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    background-color: #f9fafb;
    flex-shrink: 0;
}

.categories-tree {
    padding: 0.75rem;
}

.category-item {
    margin-bottom: 0.25rem;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.category-header:hover {
    background-color: #e5e7eb;
}

.category-header.active {
    background-color: #dbeafe;
    color: #1d4ed8;
}

.expand-icon,
.leaf-icon {
    width: 16px;
    text-align: center;
    margin-right: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280;
}

.expand-icon {
    cursor: pointer;
    transition: transform 0.2s;
}

.leaf-icon {
    opacity: 0.5;
}

.category-icon {
    margin-right: 0.5rem;
    font-size: 1rem;
}

.category-name {
    flex: 1;
    font-weight: 500;
    color: #374151;
}

.category-count {
    font-size: 0.75rem;
    color: #6b7280;
    margin-left: auto;
}

.category-children {
    margin-left: 1rem;
}

.products-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.breadcrumbs {
    padding: 0.75rem 1rem 0.5rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}

.breadcrumbs-wrapper {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: #6b7280;
    padding-left: 20px;
}

.breadcrumb-item {
    color: #374151;
    font-weight: 500;
}

.breadcrumb-item.active {
    color: #1d4ed8;
}

.breadcrumb-separator {
    color: #d1d5db;
    margin: 0 0.25rem;
}

.products-grid {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    align-content: start;
}

/* Mobile Layout */
.modal-layout-mobile {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 400px;
}

.mobile-category-selector {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

.mobile-category-selector label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
}

.mobile-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    background-color: white;
    transition: all 0.2s;
    max-height: 200px;
    overflow-y: auto;
}

.mobile-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.mobile-select option {
    padding: 0.5rem 0.75rem;
}

.products-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Товари */
.product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background-color: white;
}

.product-item:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.product-item.selected {
    border-color: #3b82f6;
    background-color: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.product-code {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
}

.product-availability {
    font-size: 0.875rem;
    color: #059669;
    font-weight: 500;
}

.product-availability.low-stock {
    color: #dc2626;
}

.product-details {
    text-align: right;
    font-size: 0.8rem;
    color: #6b7280;
    margin-left: 1rem;
}

.product-weight {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.product-box-info {
    color: #9ca3af;
}

/* Повідомлення */
.no-category-message,
.no-products-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #6b7280;
    font-style: italic;
    text-align: center;
    flex-direction: column;
}

.no-category-message::before,
.no-products-message::before {
    content: '📦';
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Футер модального вікна */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.modal-footer .btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-secondary {
    background-color: #f9fafb;
    color: #374151;
    border-color: #d1d5db;
}

.btn-secondary:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2563eb;
}

.btn-primary:disabled {
    background-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Адаптивність для мобільних */
@media (max-width: 768px) {
    .modal-container {
        width: 95vw;
        max-height: 95vh;
        margin: 2.5vh auto;
    }
    
    .products-list .product-item {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }
    
    .product-details {
        margin-left: 0;
        margin-top: 0.75rem;
        text-align: left;
        display: flex;
        gap: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        padding: 0.75rem;
    }
}

/* Плавна анімація для accordion */
.accordion-content {
    transition: all 0.3s ease;
}

/* Прокрутка */
.categories-sidebar::-webkit-scrollbar,
.categories-accordion::-webkit-scrollbar,
.products-grid::-webkit-scrollbar,
.products-list::-webkit-scrollbar {
    width: 6px;
}

.categories-sidebar::-webkit-scrollbar-track,
.categories-accordion::-webkit-scrollbar-track,
.products-grid::-webkit-scrollbar-track,
.products-list::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.categories-sidebar::-webkit-scrollbar-thumb,
.categories-accordion::-webkit-scrollbar-thumb,
.products-grid::-webkit-scrollbar-thumb,
.products-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.categories-sidebar::-webkit-scrollbar-thumb:hover,
.categories-accordion::-webkit-scrollbar-thumb:hover,
.products-grid::-webkit-scrollbar-thumb:hover,
.products-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}