/* ============================================================
   Documents View Layout
   ============================================================ */

.documents-view {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height));
    margin-top: var(--header-height);
    background: var(--bg-color);
}

.doc-layout {
    display: flex;
    height: 100%;
}

/* ============================================================
   Folder Sidebar
   ============================================================ */

.doc-sidebar {
    width: 220px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

.folder-tree {
    list-style: none;
    padding: 4px 0;
}

.folder-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-color);
    transition: background 0.15s;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 6px;
}

.folder-item:hover {
    background: var(--bg-color);
}

.folder-item.active {
    background: #eff6ff;
    border-left-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 500;
}

/* ============================================================
   Document Main Content
   ============================================================ */

.doc-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.doc-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
    flex-wrap: wrap;
}

.doc-breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.breadcrumb-item {
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 500;
}

.breadcrumb-item:last-child {
    color: var(--text-color);
    cursor: default;
}

.breadcrumb-separator {
    color: var(--text-muted);
    margin: 0 2px;
}

.doc-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.doc-search-input {
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    outline: none;
    width: 180px;
    transition: border-color 0.2s;
}

.doc-search-input:focus {
    border-color: var(--primary-color);
}

.doc-status-filter {
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    outline: none;
    background: var(--surface-color);
}

.doc-file-list-container {
    flex: 1;
    overflow-y: auto;
}

/* Folder rows in the file table */
.doc-file-table .folder-row {
    cursor: pointer;
}

.doc-file-table .folder-row:hover {
    background: #f0f9ff;
}

.doc-file-table .folder-row td {
    color: var(--text-muted);
}

.doc-file-table .folder-row .file-name-text {
    color: var(--text-color);
    font-weight: 500;
}

.file-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.file-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-label {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* Drag-over state */
.doc-file-list-container.drag-over {
    background: #eff6ff;
    outline: 2px dashed var(--primary-color);
    outline-offset: -4px;
}

/* ============================================================
   Document Status Badges
   ============================================================ */

.status-badge.draft { background: #f1f5f9; color: #475569; }
.status-badge.inreview { background: #fef3c7; color: #92400e; }
.status-badge.published { background: #dbeafe; color: #1e40af; }
.status-badge.archived { background: #f1f5f9; color: #94a3b8; }

/* ============================================================
   Preview Panel
   ============================================================ */

.doc-preview-panel {
    width: 380px;
    background: var(--surface-color);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 0.2s;
}

.doc-preview-panel.expanded {
    width: 60%;
}

.doc-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.doc-preview-header h4 {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
}

.doc-preview-content {
    height: 200px;
    min-height: 200px;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
}

.doc-preview-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.doc-preview-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.preview-placeholder {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px;
}

.doc-preview-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Info Tabs */
.doc-info-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
}

.doc-info-tab {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.doc-info-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.doc-info-content {
    flex: 1;
    overflow-y: auto;
}

.doc-info-grid {
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.doc-info-grid .info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.doc-info-grid .info-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.doc-info-grid .info-value {
    font-size: 13px;
    color: var(--text-color);
}

/* Comments */
.doc-comments-list {
    padding: 8px 12px;
}

.doc-comment-item {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
}

.doc-comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.doc-comment-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
}

.doc-comment-date {
    font-size: 11px;
    color: var(--text-muted);
}

.doc-comment-content {
    font-size: 13px;
    color: var(--text-color);
    line-height: 1.4;
}

.doc-comment-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.doc-comment-input-section {
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
}

.doc-comment-input-section textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
    outline: none;
}

.doc-comment-input-section textarea:focus {
    border-color: var(--primary-color);
}

/* Versions */
.doc-versions-list {
    padding: 8px 12px;
}

.doc-version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.doc-version-badge {
    display: inline-flex;
    padding: 1px 6px;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 6px;
}

/* Logs */
.doc-logs-list {
    padding: 8px 12px;
}

.doc-log-item {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
}

.doc-log-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.doc-log-content {
    flex: 1;
}

.doc-log-action {
    color: var(--text-color);
}

.doc-log-time {
    color: var(--text-muted);
    font-size: 11px;
}

/* Groups */
.doc-groups-list {
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.doc-group-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: #eff6ff;
    color: var(--primary-color);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* ============================================================
   Upload Queue
   ============================================================ */

.doc-upload-queue {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 360px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    max-height: 400px;
}

.doc-upload-queue.minimized .doc-upload-queue-list,
.doc-upload-queue.minimized .doc-upload-queue-progress {
    display: none;
}

.doc-upload-queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 500;
}

.doc-upload-queue-header span {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 6px;
}

.doc-upload-queue-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: width 0.3s;
}

.doc-upload-queue-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.doc-upload-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 12px;
}

.doc-upload-item-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.doc-upload-item-info {
    flex: 1;
    min-width: 0;
}

.doc-upload-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.doc-upload-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.doc-upload-item-progress {
    width: 60px;
}

.doc-upload-item-status {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.doc-upload-item.completed .doc-upload-item-status { color: var(--success-color); }
.doc-upload-item.error .doc-upload-item-status { color: var(--danger-color); }
.doc-upload-item.uploading .doc-upload-item-status { color: var(--primary-color); }

/* ============================================================
   Upload Modal Group Selection
   ============================================================ */

.doc-upload-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.doc-upload-groups-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.doc-group-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.1s;
}

.doc-group-checkbox:hover {
    background: var(--bg-color);
}

.doc-group-checkbox input[type="checkbox"] {
    flex-shrink: 0;
}

.doc-group-checkbox .group-name {
    font-size: 13px;
    font-weight: 500;
}

/* ============================================================
   Context Document Picker
   ============================================================ */

.ctx-doc-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.ctx-doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.1s;
}

.ctx-doc-item:hover {
    background: var(--bg-color);
}

.ctx-doc-item:last-child {
    border-bottom: none;
}

.ctx-doc-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.ctx-doc-item-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ctx-doc-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

/* Asset detail context documents */
.ctx-doc-linked-list {
    padding: 8px 0;
}

.ctx-doc-linked-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.ctx-doc-linked-item:last-child {
    border-bottom: none;
}

.ctx-doc-linked-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.ctx-doc-linked-name {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Breadcrumb navigation in document picker */
.ctx-doc-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 12px;
    margin-bottom: 8px;
    align-items: center;
}

.ctx-doc-breadcrumb {
    cursor: pointer;
    color: var(--primary-color);
    background: none;
    border: none;
    font-size: 12px;
    padding: 0;
    font-family: inherit;
}

.ctx-doc-breadcrumb:hover {
    text-decoration: underline;
}

.ctx-doc-separator {
    color: var(--text-muted);
    font-size: 11px;
}

.ctx-doc-current-folder {
    color: var(--text-color);
    font-weight: 600;
    font-size: 12px;
}

.ctx-doc-folder {
    background: var(--bg-color);
}

.ctx-doc-file:hover {
    background: rgba(var(--primary-rgb, 59, 130, 246), 0.06);
}

.ctx-doc-select-btn {
    flex-shrink: 0;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.ctx-doc-select-btn:hover {
    background: var(--primary-color);
    color: white;
}

.ctx-doc-disabled {
    opacity: 0.5;
    cursor: default;
}

.ctx-doc-disabled:hover {
    background: transparent;
}

.ctx-doc-status-hint {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
    .doc-sidebar {
        display: none;
    }

    .doc-preview-panel {
        position: fixed;
        inset: var(--header-height) 0 0 0;
        width: 100%;
        z-index: 160;
    }

    .doc-upload-queue {
        width: calc(100% - 32px);
    }
}
