/* Documents Page Styles - Updated Dec 24, 2025 */

.documents-container {
    padding: 32px;
    max-width: 900px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Header */
.documents-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.documents-header-left {
    flex: 1;
}

.documents-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.documents-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* Header Actions */
.documents-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #059669;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-danger {
    padding: 10px 20px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Filters - Right aligned in tabs row */
.documents-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.filter-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 400;
    white-space: nowrap;
}

.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-filter {
    padding: 6px 14px;
    background: #f3f4f6;
    color: #374151;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tag-filter:hover {
    background: #e5e7eb;
}

.tag-filter.active {
    background: #10b981;
    color: white;
}

/* Documents List */
.documents-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.documents-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #6b7280;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #0d9488;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Document Card - Updated to match Figma design */
.document-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    transition: box-shadow 0.2s;
    display: flex;
    gap: 16px;
}

.document-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Document Icon */
.document-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #f3f4f6;
    color: #6b7280;
}

.document-icon svg {
    width: 20px;
    height: 20px;
}

/* Q&A Number Badge */
.document-icon.qa-icon {
    background: #dbeafe;
    color: #2563eb;
}

.qa-number {
    font-size: 16px;
    font-weight: 700;
    color: #2563eb;
}

/* Document Content - Takes remaining space */
.document-content {
    flex: 1;
    min-width: 0;
}

/* Title Row with Type */
.document-header {
    margin-bottom: 4px;
}

.document-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 2px 0;
}

.document-type {
    font-size: 13px;
    color: #9ca3af;
    margin: 0;
}

/* Document Preview Text */
.document-preview {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin: 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Document Footer - Tags, Date, Actions */
.document-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    gap: 16px;
}

.document-footer-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.document-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.document-tag {
    padding: 4px 10px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.document-date {
    font-size: 13px;
    color: #9ca3af;
}

/* Document Actions - Edit & Delete buttons */
.document-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.document-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.document-action-btn.edit-btn {
    color: #6b7280;
}

.document-action-btn.edit-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.document-action-btn.delete-btn {
    color: #ef4444;
}

.document-action-btn.delete-btn:hover {
    background: #fef2f2;
}

/* Three-dot menu button */
.document-menu-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    transition: all 0.2s;
}

.document-menu-btn:hover {
    background: #f3f4f6;
    color: #6b7280;
}

/* Legacy styles for compatibility */
.document-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.document-card-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-meta {
    font-size: 13px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 8px;
}

.document-meta-sep {
    color: #d1d5db;
}

.sync-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sync-status.synced {
    color: #16a34a;
}

.sync-status.pending {
    color: #d97706;
}

.sync-status.error {
    color: #dc2626;
}

.document-card-actions {
    display: flex;
    gap: 8px;
}

/* Empty State */
.documents-empty {
    text-align: center;
    padding: 80px 20px;
    background: #f9fafb;
    border-radius: 12px;
    border: 2px dashed #e5e7eb;
}

.empty-icon {
    color: #9ca3af;
    margin-bottom: 16px;
}

.documents-empty h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.documents-empty p {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 24px 0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #1f2937;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-hint {
    font-size: 12px;
    color: #6b7280;
    margin: 8px 0 0 0;
}

/* Type Selector */
.type-selector {
    display: flex;
    gap: 12px;
}

.type-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
}

.type-option:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.type-option.active {
    background: #f0fdfa;
    border-color: #0d9488;
    color: #0d9488;
}

.type-option span {
    font-size: 13px;
    font-weight: 500;
}

/* File Upload */
.file-upload {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
}

.file-upload:hover {
    border-color: #0d9488;
    background: #f0fdfa;
}

.file-upload p {
    margin: 12px 0 0 0;
    font-size: 14px;
}

.file-name {
    font-size: 14px;
    color: #0d9488;
    margin: 12px 0 0 0;
    font-weight: 500;
}

/* Tags Input */
.tags-input {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    min-height: 44px;
    align-items: center;
}

.tags-input:focus-within {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 4px 10px;
    background: #0d9488;
    color: white;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

.tag-remove {
    width: 16px;
    height: 16px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
    line-height: 1;
}

.tag-remove:hover {
    background: rgba(255, 255, 255, 0.3);
}

.tags-input input {
    flex: 1;
    min-width: 100px;
    border: none;
    outline: none;
    font-size: 14px;
    padding: 4px 0;
}

/* Source Selector */
.source-selector {
    display: flex;
    gap: 8px;
}

.source-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
}

.source-option:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.source-option.active {
    background: #f0fdfa;
    border-color: #0d9488;
    color: #0d9488;
}

/* File Upload Zone */
.file-upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    transition: all 0.2s;
    background: #f9fafb;
}

.file-upload-zone:hover,
.file-upload-zone.drag-over {
    border-color: #0d9488;
    background: #f0fdfa;
}

.upload-placeholder {
    color: #6b7280;
}

.upload-placeholder p {
    margin: 12px 0 4px 0;
    font-size: 14px;
}

.upload-placeholder .link-btn {
    background: none;
    border: none;
    color: #0d9488;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.upload-hint {
    font-size: 12px;
    color: #9ca3af;
}

.file-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #0d9488;
}

.file-preview .file-name {
    font-weight: 500;
    color: #1f2937;
    margin: 0;
}

.remove-file-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-file-btn:hover {
    background: #fecaca;
}

/* Label Row with AI Button */
.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.label-row label {
    margin-bottom: 0 !important;
}

.ai-suggest-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-suggest-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    transform: translateY(-1px);
}

.ai-suggest-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-generating {
    color: #8b5cf6;
    font-style: italic;
}

/* Tag Suggestions */
.tag-suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.suggestion-label {
    font-size: 12px;
    color: #9ca3af;
}

.tag-suggestion {
    padding: 4px 10px;
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.tag-suggestion:hover {
    background: #e5e7eb;
    color: #374151;
}

.tag-suggestion.added {
    background: #dcfce7;
    color: #16a34a;
    border-color: #bbf7d0;
}

/* Knowledge Tabs and Filters Row */
.knowledge-tabs-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 24px;
}

/* Knowledge Type Tabs - Underlined Style */
.knowledge-tabs {
    display: flex;
    gap: 24px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0;
    margin-bottom: 0;
}

.knowledge-tab {
    padding: 12px 4px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.knowledge-tab:hover {
    color: #374151;
}

.knowledge-tab.active {
    color: #1f2937;
    border-bottom-color: #1f2937;
}

/* Knowledge Type Badge */
.knowledge-type-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Visibility Badge */
.visibility-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

/* Updated Document Card Layout */
.document-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    cursor: pointer;
}

.document-icon {
    background: #f3f4f6;
    color: #6b7280;
}

.document-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.document-tags {
    margin-bottom: 8px;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.document-delete {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.document-delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Test AI Modal */
.test-description {
    color: #6b7280;
    margin: 0 0 20px 0;
}

.test-response {
    margin-top: 20px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
}

.test-response label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.response-content {
    font-size: 14px;
    color: #1f2937;
    line-height: 1.6;
}

.response-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    font-size: 12px;
    color: #6b7280;
}

/* Select Dropdown */
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.form-group select:focus {
    outline: none;
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Status Filter Tabs */
.status-filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.status-filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.status-filter-tab:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.status-filter-tab.active {
    background: #1f2937;
    border-color: #1f2937;
    color: white;
}

.status-filter-tab.active svg {
    stroke: white;
}

.status-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.status-filter-tab.active .status-count {
    background: rgba(255, 255, 255, 0.2);
}

/* Status Selector in Modal */
.status-selector {
    display: flex;
    gap: 8px;
}

.status-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
}

.status-option:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.status-option.active[data-status="draft"] {
    background: #fef9c3;
    border-color: #eab308;
    color: #a16207;
}

.status-option.active[data-status="published"] {
    background: #dcfce7;
    border-color: #22c55e;
    color: #15803d;
}

/* Status Badge on Cards */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.draft {
    background: #fef9c3;
    color: #a16207;
}

.status-badge.published {
    background: #dcfce7;
    color: #15803d;
}

.status-badge svg {
    width: 12px;
    height: 12px;
}

/* Delete Warning */
.delete-warning {
    margin-top: 12px;
    padding: 12px;
    background: #fef3c7;
    border-radius: 8px;
    color: #92400e;
    font-size: 14px;
}

/* Website Sync Section */
.sync-section {
    margin-top: 16px;
    padding: 12px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6b7280;
}

.sync-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
}

.sync-icon.pending {
    background: #f59e0b;
}

.sync-icon.syncing {
    background: #3b82f6;
    animation: pulse 1s infinite;
}

.sync-icon.completed {
    background: #10b981;
}

.sync-icon.failed {
    background: #ef4444;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

#syncWebsiteBtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

#syncWebsiteBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#syncWebsiteBtn svg {
    flex-shrink: 0;
}

#syncWebsiteBtn.syncing svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .documents-container {
        padding: 16px;
    }

    .documents-header {
        flex-direction: column;
        gap: 16px;
    }

    .documents-filters {
        flex-direction: column;
        align-items: flex-start;
    }

    .type-selector {
        flex-direction: column;
    }

    .source-selector {
        flex-wrap: wrap;
    }

    .modal {
        max-height: 100vh;
        border-radius: 0;
    }

    .knowledge-tabs {
        width: 100%;
    }

    .knowledge-tab {
        flex: 1;
        text-align: center;
    }

    .label-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .tag-suggestions {
        flex-wrap: wrap;
    }

    .sync-section {
        flex-direction: column;
        align-items: flex-start;
    }
}
