/* frontend/css/documents.css */

.documents-actions {
    margin-bottom: 2rem;
}

.documents-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* Увеличим минимальную ширину */
    gap: 1rem;
    padding: 1rem 0;
}

/* Унифицировано через .card */
.card.document-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    /* Убираем aspect-ratio, чтобы карточка растягивалась по содержимому, но была компактной */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    transition: all 0.2s ease;
    position: relative; /* Для позиционирования кнопки удаления */
    overflow: visible; /* Позволяем кнопке удаления выйти за границы контента */
    text-align: center;
    min-height: 140px; /* Минимальная высота для равномерности */
}

.card.document-card:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-sm);
}

/* Иконка документа */
.doc-icon {
    width: 48px; /* Вернём прежний размер или чуть меньше */
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
    margin: auto;
    margin-bottom: 10px;
}

.doc-icon.pdf { background: #ef4444; }
.doc-icon.docx { background: #2b579a; }
.doc-icon.txt { background: #6b7280; }

/* Контент карточки */
.doc-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Центрируем по вертикали */
    width: 100%;
    overflow: hidden; /* Обрезаем переполнение внутри контента */
}

/* Заголовок документа */
.doc-content h4 {
    margin: 0;
    font-size: 0.85rem; /* Уменьшенный, но читаемый размер */
    color: var(--text-primary);
    /* white-space: nowrap; */ /* Пока не переносим строки */
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    max-width: 100%; /* Убедимся, что не выходит за границы */
}

/* Мета-информация (дата) */
.doc-meta {
    color: var(--text-muted);
    font-size: 0.7rem; /* Уменьшенный размер */
    margin-top: 0.25rem;
    white-space: nowrap; /* Пока не переносим строки */
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%; /* Убедимся, что не выходит за границы */
}

/* Кнопка удаления */
.doc-actions {
    position: absolute; /* Позиционируем абсолютно */
    top: 0; /* Отступ от верха */
    right: 0; /* Отступ от правого края */
    margin: 0; /* Убираем стандартные отступы */
    padding: 0; /* Убираем внутренние отступы */
    background: transparent;
    border: none;
    display: flex; /* Используем flex для размещения кнопки */
    justify-content: flex-end; /* Кнопка прижата к правому краю */
    align-items: flex-start; /* Кнопка прижата к верху */
    z-index: 1; /* Повышаем z-index, чтобы кнопка была поверх карточки */
}

.action-btn {
    padding: 1.2rem; /* Умеренные внутренние отступы */
    border: none;
    background: rgb(255 1 1 / 10%); /* Легкий полупрозрачный фон для кнопки */
    /* backdrop-filter: blur(4px); */ /* Эффект стекла */
    color: var(--text-secondary); /* Цвет иконки */
    border-radius: 0 15px; /* Круглая кнопка */
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px; /* Фиксированная ширина */
    height: 22px; /* Фиксированная высота */
    flex-shrink: 0;
    border: 1px solid transparent; /* Временная граница */
}

.action-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--error);
    border-color: var(--error); /* Граница при наведении */
}

/* Сброс стилей для других элементов карточки */
.card.document-card .card-header,
.card.document-card .card-status,
.card.document-card .card-actions {
    display: none;
}

.documents-list .card {
    min-width: calc(100% - 0.75rem);
    text-align: center;
}

/* Зона перетаскивания */
.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    background: var(--bg-secondary); /* Светлый фон внутри */
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 1.5rem; /* Отступ снизу */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem; /* Равномерный отступ между элементами */
}

.upload-zone:hover {
    border-color: var(--accent-primary);
    background: var(--bg-glass-hover);
}

.upload-zone.has-files {
    border-color: var(--accent-primary);
    background: var(--bg-glass-hover);
}

.upload-zone i {
    font-size: 3rem; /* Большая иконка */
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.upload-zone h4 {
    color: var(--text-primary);
    margin: 0 0 0.5rem 0; /* Отступ только снизу */
    font-size: 1.25rem;
}

.upload-zone p {
    color: var(--text-secondary);
    margin: 0 0 1rem 0; /* Отступ только снизу */
}

/* Кнопка выбора файлов */
#browseFiles {
    margin-top: 0.5rem; /* Небольшой отступ сверху от текста */
}

/* Превью загруженных файлов */
.upload-preview {
    margin-bottom: 1.5rem; /* Отступ снизу перед поддерживаемыми форматами */
}

.upload-preview h5 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 500;
}

.file-previews {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* Отступ между превью файлов */
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.file-preview:hover {
    border-color: var(--border-medium);
    background: var(--bg-glass-hover);
}

.file-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    flex-shrink: 0; /* Не даем иконке сжиматься */
}

.file-icon.pdf { background: #ef4444; }
.file-icon.word { background: #2b579a; }
.file-icon.txt { background: #6b7280; }

.file-info {
    flex-grow: 1; /* Информация о файле занимает оставшееся место */
    min-width: 0; /* Позволяет сжиматься, если текст длинный */
}

.file-name {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.file-remove {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    padding: 0.25rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0; /* Не даем кнопке сжиматься */
}

.file-remove:hover {
    background: var(--bg-glass-hover);
    color: var(--error);
}

/* Поддерживаемые форматы */
.supported-formats {
    text-align: center;
    padding-top: 0.5rem; /* Небольшой отступ сверху */
    border-top: 1px solid var(--border-light); /* Легкая граница сверху */
}

.supported-formats p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}