/**
 * FCNC File Library - CSS Styles
 * Стили для файловой библиотеки
 * 
 * @version 1.0.0
 * @design-system FactoryCNC
 */

/* ================================================
   ПЕРЕМЕННЫЕ (Дизайн-система FactoryCNC)
   ================================================ */

:root {
    --fcnc-primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --fcnc-primary-color: #667eea;
    --fcnc-secondary-color: #764ba2;
    --fcnc-text-primary: #333;
    --fcnc-text-secondary: #666;
    --fcnc-text-light: #999;
    --fcnc-border-color: #e0e0e0;
    --fcnc-bg-light: #f8f9fa;
    --fcnc-bg-white: #fff;
    --fcnc-success-color: #4caf50;
    --fcnc-warning-color: #ffc107;
    --fcnc-danger-color: #dc3545;
    --fcnc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --fcnc-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --fcnc-shadow-lg: 0 10px 40px rgba(102, 126, 234, 0.3);
    --fcnc-radius-sm: 8px;
    --fcnc-radius-md: 12px;
    --fcnc-radius-lg: 16px;
}

/* ================================================
   МЕНЕДЖЕР ФАЙЛОВ
   ================================================ */

.fcnc-file-manager {
    background: var(--fcnc-bg-white);
    border-radius: var(--fcnc-radius-md);
    padding: 30px;
    height: calc(100vh - 120px); /* Высота чата: полный экран минус шапка */
    min-height: 600px;
    max-height: none; /* Убираем ограничение */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Важно: блокируем скролл на контейнере */
}

.fcnc-file-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-shrink: 0; /* Не сжимается при скролле */
}

.fcnc-file-manager-header h3 {
    margin: 0;
    font-size: 24px;
    color: var(--fcnc-text-primary);
    font-weight: 700;
}

.fcnc-btn-upload-file {
    background: var(--fcnc-primary-gradient);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.8);
    padding: 12px 24px;
    border-radius: var(--fcnc-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.fcnc-btn-upload-file:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
    border-color: rgba(255, 255, 255, 1);
}

.fcnc-btn-upload-file .fcnc-icon {
    font-size: 18px;
}

/* ================================================
   ФИЛЬТРЫ И ПОИСК
   ================================================ */

.fcnc-file-filters {
    margin-bottom: 25px;
    flex-shrink: 0; /* Не сжимается при скролле */
}

.fcnc-filter-search {
    margin-bottom: 15px;
}

.fcnc-filter-search input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--fcnc-border-color);
    border-radius: var(--fcnc-radius-sm);
    font-size: 15px;
    transition: border-color 0.2s ease;
}

.fcnc-filter-search input:focus {
    outline: none;
    border-color: var(--fcnc-primary-color);
}

.fcnc-filter-controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.fcnc-filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fcnc-filter-group label {
    font-size: 14px;
    color: var(--fcnc-text-secondary);
    font-weight: 500;
}

.fcnc-filter-group select {
    padding: 10px 14px;
    border: 1px solid var(--fcnc-border-color);
    border-radius: var(--fcnc-radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.fcnc-filter-group select:focus {
    outline: none;
    border-color: var(--fcnc-primary-color);
}

/* ================================================
   СПИСОК ФАЙЛОВ
   ================================================ */

.fcnc-file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    overflow-y: auto; /* ✅ КРИТИЧНО: Скролл для файлов */
    overflow-x: hidden;
    flex: 1; /* Занимает всё доступное пространство */
    padding-right: 10px; /* Отступ для скроллбара */
}

/* Стили для скроллбара */
.fcnc-file-list::-webkit-scrollbar {
    width: 8px;
}

.fcnc-file-list::-webkit-scrollbar-track {
    background: var(--fcnc-bg-light);
    border-radius: 4px;
}

.fcnc-file-list::-webkit-scrollbar-thumb {
    background: var(--fcnc-primary-color);
    border-radius: 4px;
}

.fcnc-file-list::-webkit-scrollbar-thumb:hover {
    background: var(--fcnc-secondary-color);
}

/* ✅ ВАЖНО: Когда внутри empty state - отключаем grid */
.fcnc-file-list:has(.fcnc-empty-state) {
    display: block;
}

/* ================================================
   EMPTY STATE (Нет файлов)
   ================================================ */

.fcnc-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    padding: 60px 40px;
}

.fcnc-empty-icon {
    font-size: 120px;
    margin-bottom: 30px;
    opacity: 0.3;
}

.fcnc-empty-state h4 {
    font-size: 24px;
    font-weight: 600;
    color: var(--fcnc-text-primary);
    margin: 0 0 15px 0;
}

.fcnc-empty-state p {
    font-size: 16px;
    color: var(--fcnc-text-secondary);
    margin: 0 0 30px 0;
    max-width: 400px;
    line-height: 1.6;
}

.fcnc-empty-state .fcnc-btn {
    padding: 14px 32px;
    font-size: 16px;
}

/* ================================================
   КАРТОЧКА ФАЙЛА
   ================================================ */

.fcnc-file-card {
    background: var(--fcnc-bg-white);
    border: 1px solid var(--fcnc-border-color);
    border-radius: var(--fcnc-radius-md);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.fcnc-file-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--fcnc-shadow-md);
}

.fcnc-file-preview {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    background: var(--fcnc-primary-gradient);
    border-radius: var(--fcnc-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fcnc-file-icon {
    font-size: 32px;
}

.fcnc-file-info {
    flex: 1;
    min-width: 0;
}

.fcnc-file-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--fcnc-text-primary);
    margin-bottom: 8px;
    word-break: break-word;
}

.fcnc-file-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    color: var(--fcnc-text-secondary);
    margin-bottom: 6px;
}

.fcnc-file-usage {
    font-size: 12px;
    color: var(--fcnc-text-light);
}

.fcnc-file-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.fcnc-btn-action {
    width: 36px;
    height: 36px;
    border: 1px solid var(--fcnc-border-color);
    background: var(--fcnc-bg-white);
    border-radius: var(--fcnc-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.fcnc-btn-action:hover {
    background: var(--fcnc-bg-light);
    transform: scale(1.1);
}

.fcnc-btn-delete:hover {
    background: #fee;
    border-color: var(--fcnc-danger-color);
}

/* ================================================
   СТАТИСТИКА
   ================================================ */

.fcnc-file-stats {
    background: var(--fcnc-bg-light);
    border-radius: var(--fcnc-radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    flex-shrink: 0; /* Не сжимается при скролле */
    margin-top: auto; /* Прижимается к низу */
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.fcnc-stats-item {
    display: flex;
    gap: 10px;
    align-items: center;
}

.fcnc-stats-label {
    font-size: 14px;
    color: var(--fcnc-text-secondary);
}

.fcnc-stats-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--fcnc-text-primary);
}

.fcnc-stats-max {
    font-size: 14px;
    color: var(--fcnc-text-light);
}

.fcnc-stats-progress {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.fcnc-progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.fcnc-progress-fill {
    height: 100%;
    background: var(--fcnc-primary-gradient);
    transition: width 0.3s ease;
}

.fcnc-progress-fill.fcnc-progress-low {
    background: var(--fcnc-success-color);
}

.fcnc-progress-fill.fcnc-progress-medium {
    background: var(--fcnc-warning-color);
}

.fcnc-progress-fill.fcnc-progress-high {
    background: var(--fcnc-danger-color);
}

.fcnc-progress-percent {
    font-size: 14px;
    font-weight: 600;
    color: var(--fcnc-text-secondary);
    min-width: 45px;
    text-align: right;
}

/* ================================================
   ПУСТОЕ СОСТОЯНИЕ
   ================================================ */

.fcnc-empty-state {
    text-align: center;
    padding: 80px 20px;
}

.fcnc-empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.fcnc-empty-state h4 {
    font-size: 20px;
    color: var(--fcnc-text-primary);
    margin-bottom: 10px;
}

.fcnc-empty-state p {
    font-size: 15px;
    color: var(--fcnc-text-secondary);
    margin-bottom: 25px;
}

/* ================================================
   КНОПКИ
   ================================================ */

.fcnc-btn {
    padding: 12px 24px;
    border-radius: var(--fcnc-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.fcnc-btn-primary {
    background: var(--fcnc-primary-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.fcnc-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.fcnc-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.fcnc-btn-secondary {
    background: var(--fcnc-bg-light);
    color: var(--fcnc-text-primary);
    border: 1px solid var(--fcnc-border-color);
}

.fcnc-btn-secondary:hover {
    background: #e0e0e0;
}

/* ================================================
   АДАПТИВНОСТЬ
   ================================================ */

@media (max-width: 768px) {
    .fcnc-file-manager {
        padding: 20px;
    }
    
    .fcnc-file-manager-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .fcnc-file-list {
        grid-template-columns: 1fr;
    }
    
    .fcnc-file-stats {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .fcnc-stats-progress {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .fcnc-file-card {
        flex-direction: column;
    }
    
    .fcnc-file-actions {
        width: 100%;
        justify-content: center;
    }
}

/* ================================================
   МОДАЛЬНОЕ ОКНО НАСТРОЕК ФАЙЛА
   ================================================ */

.fcnc-file-settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fcncFadeIn 0.2s ease;
}

.fcnc-file-settings-dialog {
    background: var(--fcnc-bg-white);
    border-radius: var(--fcnc-radius-md);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fcncSlideUp 0.3s ease;
}

.fcnc-file-settings-dialog h4 {
    margin: 0 0 25px 0;
    color: var(--fcnc-text-primary);
    font-size: 22px;
    font-weight: 600;
}

.fcnc-file-settings-dialog label {
    display: block;
    margin-bottom: 20px;
}

.fcnc-file-settings-dialog label span {
    display: block;
    margin-bottom: 8px;
    color: var(--fcnc-text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.fcnc-file-settings-dialog input[type="text"],
.fcnc-file-settings-dialog select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--fcnc-border-color);
    border-radius: var(--fcnc-radius-sm);
    font-size: 15px;
    color: var(--fcnc-text-primary);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.fcnc-file-settings-dialog input[type="text"]:focus,
.fcnc-file-settings-dialog select:focus {
    outline: none;
    border-color: var(--fcnc-primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.fcnc-file-settings-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 25px;
}

.fcnc-file-settings-actions .fcnc-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--fcnc-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.fcnc-file-settings-actions .fcnc-btn-secondary {
    background: var(--fcnc-bg-light);
    color: var(--fcnc-text-secondary);
}

.fcnc-file-settings-actions .fcnc-btn-secondary:hover {
    background: var(--fcnc-border-color);
}

.fcnc-file-settings-actions .fcnc-btn-primary {
    background: var(--fcnc-primary-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.fcnc-file-settings-actions .fcnc-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

@keyframes fcncFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fcncSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .fcnc-file-settings-dialog {
        padding: 20px;
        width: 95%;
    }
    
    .fcnc-file-settings-actions {
        flex-direction: column;
    }
    
    .fcnc-file-settings-actions .fcnc-btn {
        width: 100%;
    }
}

/* ================================================
   НОВЫЙ ДИЗАЙН КАРТОЧЕК V2
   ================================================ */

.fcnc-file-card-v2 {
    background: var(--fcnc-bg-white);
    border: 1px solid var(--fcnc-border-color);
    border-radius: var(--fcnc-radius-md);
    padding: 20px;
    transition: all 0.3s ease;
    box-shadow: var(--fcnc-shadow-sm);
}

.fcnc-file-card-v2:hover {
    box-shadow: var(--fcnc-shadow-md);
    transform: translateY(-4px);
}

/* 1. Заголовок с названием */
.fcnc-file-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--fcnc-bg-light);
}

.fcnc-file-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--fcnc-text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 10px;
}

.fcnc-btn-edit-name {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 6px;
    opacity: 0.6;
    transition: all 0.2s ease;
    border-radius: 6px;
    position: relative;
    z-index: 10;
    pointer-events: auto !important;
}

.fcnc-btn-edit-name:hover {
    opacity: 1;
    background: var(--fcnc-bg-light);
    transform: scale(1.1);
}

.fcnc-btn-edit-name:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.fcnc-btn-edit-name span,
.fcnc-btn-edit-setting span {
    pointer-events: none;
    display: inline-block;
}

/* 2. Превью файла */
.fcnc-file-preview-large {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--fcnc-bg-light);
    border-radius: var(--fcnc-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    overflow: hidden;
}

.fcnc-file-icon-large {
    font-size: 64px;
    opacity: 0.4;
}

.fcnc-file-preview-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 3. Настройки доступа */
.fcnc-file-settings {
    margin-bottom: 16px;
}

.fcnc-setting-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--fcnc-bg-light);
    border-radius: var(--fcnc-radius-sm);
    margin-bottom: 8px;
    transition: background 0.2s ease;
    position: relative;
}

.fcnc-setting-row:hover {
    background: #ebebeb;
}

.fcnc-setting-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.fcnc-setting-label {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--fcnc-text-secondary);
}

.fcnc-btn-edit-setting {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    opacity: 0.5;
    transition: all 0.2s ease;
    border-radius: 4px;
    position: relative;
    z-index: 10;
    pointer-events: auto !important;
}

.fcnc-btn-edit-setting:hover {
    opacity: 1;
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.fcnc-btn-edit-setting:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* 4. Метаданные */
.fcnc-file-footer {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--fcnc-border-color);
}

.fcnc-file-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--fcnc-text-light);
}

.fcnc-meta-icon {
    font-size: 16px;
    opacity: 0.7;
}

/* Кнопки действий */
.fcnc-file-actions-footer {
    display: flex;
    gap: 10px;
}

.fcnc-file-actions-footer button {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: var(--fcnc-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.fcnc-btn-download {
    background: var(--fcnc-primary-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.fcnc-btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.fcnc-btn-delete {
    background: var(--fcnc-bg-light);
    color: var(--fcnc-danger-color);
}

.fcnc-btn-delete:hover {
    background: var(--fcnc-danger-color);
    color: #fff;
}

/* Dropdown меню для быстрого выбора */
.fcnc-dropdown-menu {
    background: #fff;
    border-radius: var(--fcnc-radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--fcnc-border-color);
    min-width: 280px;
    overflow: hidden;
    animation: fcncDropdownFadeIn 0.2s ease;
}

@keyframes fcncDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fcnc-dropdown-item {
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--fcnc-bg-light);
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.fcnc-dropdown-item:last-child {
    border-bottom: none;
}

.fcnc-dropdown-item:hover {
    background: var(--fcnc-bg-light);
}

.fcnc-dropdown-item.active {
    background: rgba(102, 126, 234, 0.08);
}

.fcnc-dropdown-item.active:hover {
    background: rgba(102, 126, 234, 0.12);
}

.fcnc-dropdown-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--fcnc-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.fcnc-dropdown-desc {
    font-size: 13px;
    color: var(--fcnc-text-light);
    line-height: 1.4;
}

.fcnc-dropdown-check {
    position: absolute;
    top: 14px;
    right: 18px;
    color: var(--fcnc-primary-color);
    font-size: 18px;
    font-weight: bold;
}

/* Адаптив для карточек V2 */
@media (max-width: 768px) {
    .fcnc-file-list {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .fcnc-file-footer {
        flex-wrap: wrap;
    }
    
    .fcnc-dropdown-menu {
        min-width: 250px;
    }
}

@media (max-width: 480px) {
    .fcnc-file-list {
        grid-template-columns: 1fr;
    }
    
    .fcnc-file-actions-footer {
        flex-direction: column;
    }
    
    .fcnc-dropdown-menu {
        min-width: 220px;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
    }
}

