/**
 * Стили для drag & drop интерфейса управления позициями товаров
 * Современный дизайн с поддержкой темной темы WordPress
 */

/* Основной контейнер */
.bsfttune-drag-drop-wrap {
    max-width: 1400px;
    margin: 0;
    padding: 20px 0;
}

.bsfttune-drag-drop-wrap h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 28px;
    font-weight: 600;
}

.bsfttune-drag-drop-wrap h1 .dashicons {
    font-size: 32px;
    color: #0073aa;
}

/* Контролы */
.bsfttune-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
    padding: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.bsfttune-context-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bsfttune-context-selector label {
    font-weight: 600;
    color: #333;
}

.bsfttune-context-selector select {
    min-width: 180px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.bsfttune-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.bsfttune-actions .button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.bsfttune-actions .button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.bsfttune-actions .button .dashicons {
    font-size: 16px;
}

/* Статистика */
.bsfttune-stats {
    display: flex;
    gap: 30px;
    margin: 20px 0;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.stats-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 120px;
}

.stats-item .label {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stats-item .value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

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

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.bsfttune-loading p {
    margin: 0;
    font-size: 16px;
    color: #666;
}

/* Контейнер товаров */
.bsfttune-products-container {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* Заголовок таблицы */
.products-header {
    display: grid;
    grid-template-columns: 80px 80px 1fr 120px 120px 120px 140px;
    gap: 15px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #495057;
}

.header-cell {
    display: flex;
    align-items: center;
}

/* Список товаров */
.sortable-list {
    min-height: 200px;
}

/* Элемент товара */
.product-item {
    display: grid;
    grid-template-columns: 80px 80px 1fr 120px 120px 120px 140px;
    gap: 15px;
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
    transition: all 0.2s ease;
    cursor: move;
    background: #fff;
}

.product-item:nth-child(even) {
    background: #f8f9fa;
}

.product-item:hover {
    background: #e3f2fd;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateX(2px);
}

.product-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg) scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    z-index: 1000;
}

/* Ячейки товара */
.product-cell {
    display: flex;
    align-items: center;
    min-height: 50px;
}

.product-cell.position {
    justify-content: space-between;
}

.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: #999;
    cursor: grab;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.drag-handle:hover {
    background: rgba(0,115,170,0.1);
    color: #0073aa;
}

.drag-handle:active {
    cursor: grabbing;
}

.position-number {
    font-weight: 600;
    font-size: 14px;
    color: #666;
    min-width: 20px;
    text-align: center;
}

/* Изображение товара */
.product-thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
    transition: transform 0.2s ease;
}

.product-thumbnail:hover {
    transform: scale(1.1);
}

/* Название товара */
.product-cell.title {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.product-cell.title strong {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    margin: 0;
}

.product-meta {
    font-size: 12px;
    color: #666;
    font-family: 'Courier New', monospace;
}

/* Цена */
.price-value {
    font-weight: 600;
    color: #28a745;
}

/* Статус наличия */
.stock-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stock-status.stock-instock {
    background: #d4edda;
    color: #155724;
}

.stock-status.stock-outofstock {
    background: #f8d7da;
    color: #721c24;
}

.stock-status.stock-onbackorder {
    background: #fff3cd;
    color: #856404;
}

/* Бейдж типа позиции */
.position-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.position-badge.position-manual {
    background: #cce5ff;
    color: #004085;
}

.position-badge.position-auto {
    background: #e2e3e5;
    color: #383d41;
}

.position-badge.position-rule {
    background: #d1ecf1;
    color: #0c5460;
}

/* Действия */
.product-cell.actions {
    justify-content: center;
}

.remove-position {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    font-size: 12px;
    color: #dc3545;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.remove-position:hover {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
    text-decoration: none;
}

/* Футер товаров */
.products-footer {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.help-text {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

/* Sortable.js классы */
.sortable-ghost {
    opacity: 0.3;
    background: #e3f2fd !important;
}

.sortable-chosen {
    cursor: grabbing;
}

.sortable-drag {
    opacity: 0.8;
    transform: rotate(3deg);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

/* Уведомления */
.notice-container {
    position: fixed;
    top: 32px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
}

.notice-container .notice {
    margin-bottom: 10px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Индикатор изменений */
body.bsfttune-modified .bsfttune-drag-drop-wrap h1::after {
    content: " •";
    color: #dc3545;
    font-weight: 700;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.5; }
}

/* Адаптивность */
@media (max-width: 1200px) {
    .products-header,
    .product-item {
        grid-template-columns: 60px 60px 1fr 100px 100px 100px 120px;
        gap: 10px;
        padding: 12px 15px;
    }
    
    .bsfttune-stats {
        gap: 20px;
    }
    
    .stats-item {
        min-width: 100px;
    }
}

@media (max-width: 768px) {
    .bsfttune-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .bsfttune-context-selector,
    .bsfttune-actions {
        justify-content: center;
    }
    
    .bsfttune-stats {
        flex-wrap: wrap;
        gap: 15px;
        justify-content: center;
    }
    
    .products-header,
    .product-item {
        grid-template-columns: 50px 50px 1fr 80px 80px;
        gap: 8px;
        padding: 10px;
    }
    
    /* Скрываем некоторые колонки на мобильных */
    .products-header .header-cell:nth-child(6),
    .products-header .header-cell:nth-child(7),
    .product-item .product-cell:nth-child(6),
    .product-item .product-cell:nth-child(7) {
        display: none;
    }
    
    .product-thumbnail {
        width: 40px;
        height: 40px;
    }
    
    .notice-container {
        top: 46px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Темная тема WordPress */
.admin-color-midnight .bsfttune-controls,
.admin-color-midnight .bsfttune-products-container {
    background: #1e1e1e;
    border-color: #3c3c3c;
    color: #fff;
}

.admin-color-midnight .products-header {
    background: linear-gradient(135deg, #2c2c2c 0%, #3c3c3c 100%);
    border-color: #4c4c4c;
    color: #ccc;
}

.admin-color-midnight .product-item {
    background: #1e1e1e;
    border-color: #3c3c3c;
    color: #fff;
}

.admin-color-midnight .product-item:nth-child(even) {
    background: #252525;
}

.admin-color-midnight .product-item:hover {
    background: #2c3e50;
}

.admin-color-midnight .product-cell.title strong {
    color: #fff;
}

.admin-color-midnight .product-meta {
    color: #aaa;
}

.admin-color-midnight .drag-handle {
    color: #aaa;
}

.admin-color-midnight .drag-handle:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* Кастомные скроллбары */
.sortable-list {
    scrollbar-width: thin;
    scrollbar-color: #ccc #f1f1f1;
}

.sortable-list::-webkit-scrollbar {
    width: 8px;
}

.sortable-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.sortable-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.sortable-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Печатные стили */
@media print {
    .bsfttune-controls,
    .bsfttune-actions,
    .notice-container {
        display: none !important;
    }
    
    .bsfttune-products-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .product-item {
        break-inside: avoid;
    }
    
    .drag-handle,
    .remove-position {
        display: none;
    }
}
