/* ═══════════════════════════════════════════════════════════════════════════════
   DOCUMENT LIBRARY STYLES
   FILE: css/documentLibrary.css
   PHASE: 10 - Document Library
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   LAYOUT
   ───────────────────────────────────────────────────────────────────────────── */

.document-library {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ─────────────────────────────────────────────────────────────────────────────
   HEADER
   ───────────────────────────────────────────────────────────────────────────── */

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-title h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.header-title h1 .material-icons {
    font-size: 2rem;
    color: var(--primary-color, #4285f4);
}

.header-subtitle {
    margin: 0.25rem 0 0 0;
    color: var(--text-secondary, #666);
    font-size: 0.9375rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   STATS BAR
   ───────────────────────────────────────────────────────────────────────────── */

.library-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 12px;
    min-width: 120px;
    flex: 1;
    max-width: 200px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color, #4285f4);
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary, #666);
    margin-top: 0.25rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   FILTER BAR
   ───────────────────────────────────────────────────────────────────────────── */

.library-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 1rem;
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-select,
.filter-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 0.875rem;
    background: #fff;
    min-width: 150px;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--primary-color, #4285f4);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.search-group {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    position: relative;
}

.search-group .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #4b5563);
    font-size: 1.25rem;
    pointer-events: none;
}

.search-group .filter-input {
    padding-left: 2.5rem;
    width: 100%;
}

.btn-icon {
    padding: 0.5rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-icon:hover {
    background: var(--bg-secondary, #f8f9fa);
    border-color: var(--primary-color, #4285f4);
}

.btn-icon .material-icons {
    font-size: 1.25rem;
    color: var(--text-secondary, #666);
}

/* ─────────────────────────────────────────────────────────────────────────────
   UPLOAD ZONE
   ───────────────────────────────────────────────────────────────────────────── */

.upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #e8f0fe 0%, #f3e8ff 100%);
    border: 2px dashed var(--primary-color, #4285f4);
    border-radius: 16px;
    transition: all 0.2s ease;
}

.upload-zone.drag-over {
    background: linear-gradient(135deg, #d2e3fc 0%, #e8d5ff 100%);
    border-color: #1a73e8;
    transform: scale(1.01);
}

.upload-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.upload-icon {
    font-size: 3rem;
    color: var(--primary-color, #4285f4);
    margin-bottom: 1rem;
}

.upload-zone h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: var(--text-primary, #1a1a1a);
}

.upload-zone p {
    margin: 0 0 1rem 0;
    color: var(--text-secondary, #666);
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted, #4b5563);
    margin-bottom: 1.5rem !important;
}

/* File Preview */
.file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    width: 100%;
    max-width: 400px;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: left;
    overflow: hidden;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary, #1a1a1a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-muted, #4b5563);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color, #4285f4);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.btn-text:hover {
    background: rgba(66, 133, 244, 0.1);
}

.btn-text .material-icons {
    font-size: 1rem;
}

.upload-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    text-align: left;
    width: 100%;
}

.upload-options .option-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.upload-options label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary, #666);
}

.upload-options input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 0.875rem;
}

.upload-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.upload-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 300px;
    padding: 2rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color, #4285f4);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    margin: 0.5rem 0 0 0;
    font-size: 0.8125rem;
    color: var(--text-secondary, #666);
    text-align: center;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DOCUMENT GRID
   ───────────────────────────────────────────────────────────────────────────── */

.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DOCUMENT CARD
   ───────────────────────────────────────────────────────────────────────────── */

.document-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.document-card:hover {
    border-color: var(--primary-color, #4285f4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.document-card.has-published-link {
    border-left: 4px solid var(--success-color, #34a853);
}

/* Card Header */
.doc-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary, #f8f9fa);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.doc-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 10px;
    flex-shrink: 0;
}

.doc-icon .material-icons {
    font-size: 1.5rem;
    color: var(--primary-color, #4285f4);
}

.doc-title-area {
    flex: 1;
    min-width: 0;
}

.doc-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-namespace {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: var(--primary-light, #e8f0fe);
    color: var(--primary-color, #4285f4);
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
}

.doc-actions .btn-icon {
    border: none;
    background: transparent;
    padding: 0.25rem;
}

.doc-actions .btn-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Card Body */
.doc-card-body {
    flex: 1;
    padding: 1rem;
}

.doc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary, #666);
}

.meta-item .material-icons {
    font-size: 1rem;
}

.meta-item.source {
    flex-basis: 100%;
    color: var(--primary-color, #4285f4);
}

.meta-item.health-data-badge {
    color: #d32f2f;
    font-weight: 500;
    background: rgba(211, 47, 47, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.meta-item.health-data-badge .material-icons {
    font-size: 14px;
    color: #d32f2f;
}

/* Linked Tools */
.linked-tools {
    padding: 0.75rem;
    background: var(--success-light, #e6f4ea);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.linked-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--success-dark, #1e7e34);
    margin-bottom: 0.5rem;
}

.linked-header .material-icons {
    font-size: 1rem;
}

.linked-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.linked-tool-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #fff;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-secondary, #666);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.linked-tool-chip.published {
    background: var(--success-color, #34a853);
    color: #fff;
}

.linked-tool-chip.published .material-icons {
    font-size: 0.75rem;
}

.linked-tool-chip.more {
    background: transparent;
    border: 1px dashed var(--border-color, #ccc);
    color: var(--text-muted, #4b5563);
}

.no-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-tertiary, #f5f5f5);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-muted, #4b5563);
    margin-top: 0.5rem;
}

.no-links .material-icons {
    font-size: 1rem;
}

/* Card Footer */
.doc-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
    background: var(--bg-secondary, #f8f9fa);
}

.protected-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--warning-light, #fef7e0);
    color: var(--warning-dark, #f9a825);
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
}

.protected-badge .material-icons {
    font-size: 0.875rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-small .material-icons {
    font-size: 1rem;
    margin-right: 0.25rem;
}

.btn-danger {
    background: transparent;
    color: var(--error-color, #ea4335);
    border: 1px solid var(--error-color, #ea4335);
}

.btn-danger:hover {
    background: var(--error-color, #ea4335);
    color: #fff;
}

.btn-warning {
    background: transparent;
    color: var(--warning-color, #f9ab00);
    border: 1px solid var(--warning-color, #f9ab00);
}

.btn-warning:hover {
    background: var(--warning-color, #f9ab00);
    color: #fff;
}

/* Cancel button in processing cards */
.cancel-processing-btn {
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   EMPTY STATE
   ───────────────────────────────────────────────────────────────────────────── */

#view-document-library .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-icon {
    font-size: 4rem;
    color: var(--text-muted, #ccc);
    margin-bottom: 1rem;
}

#view-document-library .empty-state h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: var(--text-primary, #1a1a1a);
}

#view-document-library .empty-state p {
    margin: 0 0 1.5rem 0;
    color: var(--text-secondary, #666);
}

/* ─────────────────────────────────────────────────────────────────────────────
   ERROR STATE
   ───────────────────────────────────────────────────────────────────────────── */

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    grid-column: 1 / -1;
}

.error-state .material-icons {
    font-size: 3rem;
    color: var(--error-color, #ea4335);
    margin-bottom: 1rem;
}

.error-state p {
    margin: 0 0 1rem 0;
    color: var(--text-secondary, #666);
}

/* ─────────────────────────────────────────────────────────────────────────────
   SIGN-IN PROMPT
   ───────────────────────────────────────────────────────────────────────────── */

.sign-in-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    grid-column: 1 / -1;
}

.sign-in-prompt .material-icons {
    font-size: 4rem;
    color: var(--primary-color, #4285f4);
    margin-bottom: 1rem;
    opacity: 0.8;
}

.sign-in-prompt h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.sign-in-prompt p {
    margin: 0 0 1.5rem 0;
    color: var(--text-secondary, #666);
}

.sign-in-prompt .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DOCUMENT DETAILS MODAL
   ───────────────────────────────────────────────────────────────────────────── */

.document-details-modal {
    max-width: 600px;
}

.document-details-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.document-details-modal .modal-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.25rem;
}

.document-details-modal .modal-header h2 .material-icons {
    color: var(--primary-color, #4285f4);
}

.document-details-modal .modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
}

.document-details-modal .modal-close-btn:hover {
    background: var(--bg-secondary, #f5f5f5);
}

.document-details-modal .modal-body {
    padding: 1.5rem;
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-item .label {
    font-size: 0.75rem;
    color: var(--text-muted, #4b5563);
}

.detail-item .value {
    font-size: 0.875rem;
    color: var(--text-primary, #1a1a1a);
    word-break: break-word;
}

.detail-item .value a {
    color: var(--primary-color, #4285f4);
    text-decoration: none;
}

.detail-item .value a:hover {
    text-decoration: underline;
}

.linked-tools-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.linked-tool-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 8px;
}

.linked-tool-item .material-icons {
    font-size: 1.25rem;
    color: var(--text-secondary, #666);
}

.linked-tool-item .tool-name {
    flex: 1;
    font-weight: 500;
}

.linked-tool-item .tool-status {
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.linked-tool-item .tool-status.draft {
    background: var(--bg-tertiary, #e8eaed);
    color: var(--text-secondary, #666);
}

.linked-tool-item .tool-status.published {
    background: var(--success-color, #34a853);
    color: #fff;
}

.no-links-msg {
    color: var(--text-muted, #4b5563);
    font-style: italic;
}

/* Primary Actions in Modal */
.primary-actions {
    background: var(--bg-secondary, #f8f9fa);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.primary-actions .doc-actions-row {
    margin: 0;
}

.doc-actions-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.doc-actions-row .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.section-hint {
    font-size: 0.8125rem;
    color: var(--text-muted, #4b5563);
    margin: 0 0 0.5rem 0;
}

.link-type {
    font-size: 0.6875rem;
    color: var(--text-muted, #4b5563);
    font-style: italic;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DOCUMENT ACTIONS MENU
   ───────────────────────────────────────────────────────────────────────────── */

.document-actions-menu {
    padding: 0.5rem 0;
}

.document-actions-menu .menu-doc-title {
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.document-actions-menu .menu-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.document-actions-menu .menu-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9375rem;
    text-align: left;
    width: 100%;
}

.document-actions-menu .menu-option:hover:not(.disabled) {
    background: var(--bg-secondary, #f8f9fa);
    border-color: var(--primary-color, #4285f4);
}

.document-actions-menu .menu-option.danger:hover:not(.disabled) {
    background: #fff5f5;
    border-color: var(--error-color, #ea4335);
    color: var(--error-color, #ea4335);
}

.document-actions-menu .menu-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.document-actions-menu .menu-option .disabled-hint {
    font-size: 0.75rem;
    color: var(--text-muted, #4b5563);
    margin-left: auto;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DOCUMENT DETAILS MODAL
   ───────────────────────────────────────────────────────────────────────────── */

.document-details-modal {
    min-width: 400px;
}

.document-details-modal .detail-section {
    margin-bottom: 1.5rem;
}

.document-details-modal .detail-section:last-child {
    margin-bottom: 0;
}

.document-details-modal .detail-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.document-details-modal .detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.document-details-modal .detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.document-details-modal .detail-item.full-width {
    grid-column: 1 / -1;
}

.document-details-modal .detail-item .label {
    font-size: 0.75rem;
    color: var(--text-muted, #4b5563);
    text-transform: uppercase;
}

.document-details-modal .detail-item .value {
    font-size: 0.9375rem;
    color: var(--text-primary, #1a1a1a);
    word-break: break-word;
}

.document-details-modal .detail-item .value a {
    color: var(--primary-color, #4285f4);
    text-decoration: none;
}

.document-details-modal .detail-item .value a:hover {
    text-decoration: underline;
}

.document-details-modal .linked-tools-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.document-details-modal .linked-tool-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 6px;
}

.document-details-modal .linked-tool-item .material-icons {
    font-size: 1rem;
    color: var(--text-muted, #4b5563);
}

.document-details-modal .linked-tool-item .tool-name {
    flex: 1;
    font-size: 0.875rem;
}

.document-details-modal .linked-tool-item .tool-status {
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    text-transform: capitalize;
    background: var(--bg-tertiary, #eee);
}

.document-details-modal .linked-tool-item .tool-status.published {
    background: var(--success-color, #34a853);
    color: #fff;
}

.document-details-modal .linked-tool-item .tool-status.draft {
    background: var(--warning-light, #fff3cd);
    color: var(--warning-color, #f59e0b);
}

.document-details-modal .no-links-msg {
    color: var(--text-muted, #4b5563);
    font-style: italic;
    margin: 0;
}

.document-details-modal .linked-tool-item .link-type {
    font-size: 0.6875rem;
    color: var(--text-muted, #4b5563);
    font-style: italic;
}

.document-details-modal .doc-actions-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.document-details-modal .doc-actions-row .btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DOCUMENT PREVIEW MODAL
   ───────────────────────────────────────────────────────────────────────────── */

.document-preview-modal {
    max-width: 800px;
}

.document-preview-modal .preview-info {
    margin: 0 0 1rem 0;
    padding: 0.75rem;
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-muted, #666);
}

.document-preview-modal .preview-content {
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.document-preview-modal .preview-chunk {
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    overflow: hidden;
}

.document-preview-modal .chunk-header {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary, #f8f9fa);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.document-preview-modal .chunk-text,
.document-preview-modal .preview-text {
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    background: #fff;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DISABLED DELETE BUTTON
   ───────────────────────────────────────────────────────────────────────────── */

.doc-delete-btn.disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.doc-delete-btn:not(.disabled):hover {
    color: var(--error-color, #ea4335);
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .document-library {
        padding: 1rem;
    }

    .library-header {
        flex-direction: column;
    }

    .library-stats {
        flex-direction: column;
    }

    .stat-item {
        max-width: none;
    }

    .library-filters {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .search-group {
        max-width: none;
    }

    .document-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   PROCESSING STATUS (Optimistic UI)
   ───────────────────────────────────────────────────────────────────────────── */

/* Processing Card State */
.document-card.is-processing {
    position: relative;
    border-color: var(--primary-color, #4285f4);
    background: linear-gradient(135deg, #f8fbff 0%, #fff 100%);
}

.document-card.is-processing .doc-card-body {
    opacity: 0.7;
}

/* Processing Overlay */
.processing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #e8f0fe 0%, #d2e3fc 100%);
    border-bottom: 1px solid rgba(66, 133, 244, 0.2);
    z-index: 1;
}

.processing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.processing-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(66, 133, 244, 0.2);
    border-top-color: var(--primary-color, #4285f4);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.processing-text {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary-color, #4285f4);
}

.processing-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 2px;
    overflow: hidden;
}

.processing-bar-fill {
    height: 100%;
    background: var(--primary-color, #4285f4);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* Section Processing Info */
.processing-section-info {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(66, 133, 244, 0.15);
}

.section-status {
    font-size: 0.75rem;
    color: var(--primary-dark, #1a73e8);
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pending State (queued, waiting to process) */
.processing-overlay.is-pending {
    background: linear-gradient(135deg, #f0f4f8 0%, #e8eef4 100%);
    border-bottom-color: rgba(100, 120, 140, 0.2);
}

.processing-spinner.pending {
    border-color: rgba(100, 120, 140, 0.2);
    border-top-color: #64788c;
    animation: spin 2s linear infinite;
}

.is-pending .processing-text {
    color: #64788c;
}

.is-pending .section-status {
    color: #64788c;
}

/* Processing Badge in Footer */
.processing-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, #e8f0fe 0%, #d2e3fc 100%);
    color: var(--primary-color, #4285f4);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
}

.processing-badge .material-icons {
    font-size: 1rem;
}

/* Rotating sync icon */
.material-icons.rotating {
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Failed Card State */
.document-card.is-failed {
    border-color: var(--error-color, #ea4335);
    background: #fff5f5;
}

.failed-overlay {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(234, 67, 53, 0.1);
    border-bottom: 1px solid rgba(234, 67, 53, 0.2);
    color: var(--error-color, #ea4335);
    font-size: 0.8125rem;
    font-weight: 500;
}

.failed-overlay .material-icons {
    font-size: 1.25rem;
}

/* Adjust card header for processing overlay */
.document-card.is-processing .doc-card-header {
    margin-top: 85px; /* Space for processing overlay with section info */
}

/* Disabled view button during processing */
.view-doc-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.view-doc-btn[disabled]:hover {
    background: inherit;
    border-color: inherit;
}
