/* === LIBRARY.CSS ===
   assets/css/library.css
   НАЗНАЧЕНИЕ: Стили для раздела "Библиотека документов"
   СВЯЗИ: library.js
   РАЗМЕР: ~200 строк */

/* Шапка */
.tf-lib-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.tf-lib-title {
    font-family: var(--font-display); font-size: 14px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
    color: var(--text-primary); margin: 0;
}
.tf-lib-header-right {
    display: flex; align-items: center; gap: 10px;
}
.tf-lib-stats {
    display: flex; gap: 10px;
    font-size: 11px; color: var(--text-secondary);
    font-family: var(--font-display);
}
.tf-lib-stats b { color: var(--text-primary); font-weight: 600; }

/* Тулбар фильтров */
.tf-lib-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; gap: 10px;
}
.tf-lib-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.tf-lib-filter-btn {
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 11px; padding: 4px 10px;
    border-radius: 3px; cursor: pointer; transition: all 0.15s;
    font-family: var(--font-body); white-space: nowrap;
}
.tf-lib-filter-btn:hover { border-color: var(--color-primary); color: var(--text-primary); }
.tf-lib-filter-btn.active {
    background: var(--color-primary); border-color: var(--color-primary); color: #fff;
}
.tf-lib-search { max-width: 200px; font-size: 12px; padding: 4px 8px; }

/* Двухпанельный layout */
.tf-lib-split {
    display: flex; gap: 10px;
    height: calc(100vh - 160px);
}

/* Левая панель — список */
.tf-lib-list {
    width: 380px; min-width: 280px; flex: 0 0 380px;
    overflow-y: auto;
    border: 1px solid var(--border); border-radius: 3px;
    background: var(--bg-card);
}

/* Элемент списка */
.tf-lib-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.tf-lib-item:hover { background: var(--bg-hover); }
.tf-lib-item.active { background: var(--bg-hover); border-left: 3px solid var(--color-primary); }
.tf-lib-item:last-child { border-bottom: none; }

.tf-lib-item-icon {
    flex: 0 0 auto; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-primary); border-radius: 3px;
}
.tf-lib-item-info { flex: 1; min-width: 0; }
.tf-lib-item-name {
    font-size: 12px; font-weight: 500; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tf-lib-item-meta {
    display: flex; gap: 8px; margin-top: 2px;
    font-size: 10px; color: var(--text-muted);
    font-family: var(--font-display);
}
.tf-lib-item-cat {
    background: var(--bg-primary); padding: 1px 5px;
    border-radius: 2px; font-size: 9px; text-transform: uppercase;
}
.tf-lib-item-badge {
    flex: 0 0 auto; font-size: 9px; color: var(--text-muted);
    font-family: var(--font-display); white-space: nowrap;
}

/* Правая панель — детали */
.tf-lib-detail {
    flex: 1; overflow-y: auto;
    border: 1px solid var(--border); border-radius: 3px;
    background: var(--bg-card); padding: 10px;
}

/* Шапка деталей */
.tf-lib-det-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.tf-lib-det-header h3 { margin: 0; }
.tf-lib-det-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* Превью изображения */
.tf-lib-det-preview {
    margin-bottom: 10px; text-align: center;
    background: var(--bg-primary); border-radius: 3px;
    padding: 10px;
}
.tf-lib-det-preview img {
    max-width: 100%; max-height: 300px; border-radius: 3px;
}

/* Мета-данные */
.tf-lib-det-meta { display: flex; flex-direction: column; gap: 6px; }
.tf-lib-det-row {
    display: flex; gap: 10px; font-size: 12px;
}
.tf-lib-det-row > span:first-child {
    flex: 0 0 100px; color: var(--text-muted);
    font-family: var(--font-display); font-size: 11px;
}
.tf-lib-det-row > span:last-child { flex: 1; color: var(--text-primary); }
.tf-lib-det-row a { color: var(--color-primary); text-decoration: none; }
.tf-lib-det-row a:hover { text-decoration: underline; }
.tf-lib-det-url { word-break: break-all; }
.tf-lib-det-url code {
    font-size: 10px;
    background: var(--bg-primary); padding: 2px 6px;
    border-radius: 2px; color: var(--text-secondary);
}

/* Инлайн-редактирование названия */
.tf-lib-det-title-wrap {
    display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0;
}
.tf-lib-det-title {
    cursor: pointer; margin: 0;
    font-family: var(--font-display); font-size: 14px; font-weight: 600;
    word-break: break-word; transition: color 0.15s;
}
.tf-lib-det-title:hover { color: var(--color-primary); }
.tf-lib-det-edit-btn {
    flex: 0 0 auto; background: none; border: none;
    color: var(--text-muted); cursor: pointer; padding: 2px;
    opacity: 0; transition: opacity 0.15s;
    display: flex; align-items: center;
}
.tf-lib-det-title-wrap:hover .tf-lib-det-edit-btn { opacity: 0.6; }
.tf-lib-det-edit-btn:hover { opacity: 1 !important; color: var(--color-primary); }
.tf-lib-edit-input {
    font-size: 14px !important; font-weight: 600;
    font-family: var(--font-display) !important;
    padding: 4px 8px !important; width: 100%;
    border-color: var(--color-primary) !important;
}
.tf-lib-edit-textarea {
    font-size: 12px !important; width: 100%;
    padding: 4px 8px !important; resize: vertical;
    border-color: var(--color-primary) !important;
}

/* Редактируемое описание */
.tf-lib-det-desc-val { cursor: pointer; transition: color 0.15s; }
.tf-lib-det-desc-val:hover { color: var(--color-primary); }
.tf-lib-det-placeholder {
    color: var(--text-muted); font-style: italic; opacity: 0.6;
}

/* Пустое состояние */
.tf-lib-empty {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 40px 20px; color: var(--text-muted);
}
.tf-lib-empty p { margin: 4px 0; font-size: 13px; }
.tf-lib-empty-hint { font-size: 11px !important; }

.tf-lib-det-empty {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%; color: var(--text-muted);
    font-size: 13px;
}

/* Модальное окно добавления ссылки */
.tf-lib-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.tf-lib-modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 6px; width: 420px; max-width: 90vw;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.tf-lib-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px; border-bottom: 1px solid var(--border);
    font-family: var(--font-display); font-size: 13px; font-weight: 600;
}
.tf-lib-modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 18px; cursor: pointer; line-height: 1;
}
.tf-lib-modal-close:hover { color: var(--text-primary); }
.tf-lib-modal-body {
    padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.tf-lib-modal-footer {
    display: flex; justify-content: flex-end; gap: 6px;
    padding: 10px; border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 900px) {
    .tf-lib-split { flex-direction: column; height: auto; }
    .tf-lib-list { width: 100% !important; flex: none; max-height: 40vh; }
    .tf-lib-toolbar { flex-direction: column; align-items: flex-start; }
    .tf-lib-search { max-width: 100%; }
}
