/* =============================================================
   COMPONENT / FILES-MANAGER
   
   Файловый менеджер: сетка файлов, загрузчик, корзина, DnD.
   Используется на страницах товара и юнита.
   ============================================================= */

/* ---------------------------------------------------------
   КОНТЕЙНЕР ПРОДУКТА
   --------------------------------------------------------- */

.product-container {
    display: grid;
    gap: var(--space-5);
}

.product-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-surface);
}

div.product-model {
    font-weight: var(--fw-medium);
    text-align: center;
    padding: var(--space-3);
    background-color: var(--gray-100);
    border-radius: var(--radius-md);
}

/* ---------------------------------------------------------
   СЕТКА ФАЙЛОВ
   --------------------------------------------------------- */

.files-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    min-height: 100px;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    transition:
        background-color var(--duration-fast) var(--ease-default),
        border-color var(--duration-fast) var(--ease-default);
    align-content: flex-start;
}

.files-grid.drop-zone-active {
    background-color: rgba(52, 152, 219, .05);
    border: 2px dashed var(--blue-500);
}

/* ---------------------------------------------------------
   ЭЛЕМЕНТ ФАЙЛА
   --------------------------------------------------------- */

.file-item {
    width: 150px;
    height: 150px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background-color: var(--bg-surface);
    box-shadow: var(--shadow-surface);
    cursor: grab;
    touch-action: none;
    user-select: none;
    transition:
        transform var(--duration-base) var(--ease-default),
        opacity var(--duration-base) var(--ease-default);
}

.file-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.file-item.dragging {
    opacity: .4;
    transform: scale(.95);
    cursor: grabbing;
}

.file-item.drag-source {
    opacity: .3;
}

.file-item.drop-after {
    border-bottom: 3px solid var(--blue-500);
}

.file-item.drop-before {
    border-top: 3px solid var(--blue-500);
}

/* ---------------------------------------------------------
   ЗАГРУЗЧИК
   --------------------------------------------------------- */

.uploader {
    border: 2px dashed var(--gray-200);
    padding: var(--space-5);
    text-align: center;
    background-color: var(--bg-surface);
    border-radius: var(--radius-sm);
    transition:
        border-color var(--duration-slow) var(--ease-default),
        background-color var(--duration-slow) var(--ease-default);
}

.uploader.dragover {
    border-color: var(--blue-500);
    background-color: var(--blue-100);
}

.upload-area {
    padding: var(--space-5);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--duration-slow) var(--ease-default);
}

.upload-area:hover {
    background-color: var(--bg-surface-alt);
}

.upload-area:focus-within {
    outline: 2px solid var(--blue-500);
    outline-offset: 2px;
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: var(--space-2);
    color: var(--blue-500);
}

.upload-text {
    font-weight: var(--fw-bold);
    margin-bottom: var(--space-1);
}

.upload-subtext {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.file-input {
    display: none;
}

.upload-requirements {
    margin-top: var(--space-3);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.requirement {
    padding: var(--space-1) var(--space-2);
    background: var(--gray-100);
    border-radius: var(--radius-xs);
}

/* Прогресс загрузки */
.progress-bar {
    height: 4px;
    background: var(--gray-100);
    border-radius: var(--radius-xs);
    margin-top: var(--space-3);
    overflow: hidden;
    display: none;
}

.progress-fill {
    height: 100%;
    background: var(--blue-500);
    width: 0;
    transition: width var(--duration-slow) var(--ease-default);
}

/* Ошибка загрузки */
.upload-error {
    background-color: var(--red-300);
    color: var(--red-900);
    border: 1px solid var(--red-900);
    padding: var(--space-3);
    margin: var(--space-3) 0;
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
}

/* ---------------------------------------------------------
   КОРЗИНА УДАЛЕНИЯ
   --------------------------------------------------------- */

.trash-zone {
    position: fixed;
    bottom: var(--space-7);
    right: var(--space-7);
    width: 100px;
    height: 100px;
    background-color: var(--red-300);
    border: 2px dashed var(--red-700);
    border-radius: var(--radius-3xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--red-900);
    font-size: 1rem;
    font-weight: var(--fw-bold);
    z-index: var(--z-toast);
    opacity: 0;
    transform: scale(.8);
    transition: all var(--duration-slow) var(--ease-default);
    pointer-events: none;
}

.trash-zone.drag-over,
.trash-zone.touch-over {
    background-color: var(--red-500);
    color: white;
    transform: scale(1.1);
    border-color: white;
    box-shadow: 0 8px 25px rgba(255, 0, 0, .4);
}

.trash-zone.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* ---------------------------------------------------------
   АДАПТИВ
   --------------------------------------------------------- */

@media (max-width: 767px) {
    .file-item {
        width: 120px;
        height: 120px;
    }

    .trash-zone {
        width: 80px;
        height: 80px;
        font-size: var(--fs-sm);
    }
}

@media (max-width: 480px) {
    .file-item {
        width: 100px;
        height: 100px;
    }
}