/* Document preview typography and layout */
.document-preview {
    background: white;
    color: black;
    padding: 20px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 12px;
    white-space: pre-wrap;
    width: fit-content;
    max-width: 100%;
}

/* Document paper outer container with padding */
.document-paper {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 25px 12px 25px 12px;
    box-shadow: inset 0 1px 0 rgba(0,0,0,0.08);
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.document-paper.empty-document {
    padding: 12px 12px;
}

/* Dark theme: use accent color for border and background */
:root:not([data-theme="light"]) .document-paper {
    background: rgba(16,185,129,0.1);
    border: 1px solid var(--accent);
}

/* Error state: red border for documents with errors */
.document-paper.has-errors {
    border: 2px solid #e53e3e;
}

:root:not([data-theme="light"]) .document-paper.has-errors {
    border: 2px solid #fc8181;
}

/* Document content container - positioned elements go here */
.document-content {
    position: relative;
    margin: 0 auto;
    overflow: hidden;
}

.document-content.empty-document {
    min-height: 60px;
}

.document-empty-message {
    color: var(--muted);
    padding: 12px;
    text-align: center;
}

/* View element - text */
.view-text {
    position: absolute;
    white-space: pre;
    overflow: hidden;
    color: #111;
}

/* Dark theme: use white text color */
:root:not([data-theme="light"]) .view-text {
    color: #fff;
}

/* View element - image */
.view-image {
    position: absolute;
    display: block;
}

/* Dark theme: invert black to white, preserve transparency */
:root:not([data-theme="light"]) .view-image {
    filter: invert(1);
}

/* Debug table styles */
.debug-table {
    position: absolute;
    left: 0;
    width: 100%;
    margin-bottom: 4px;
    border-collapse: collapse;
    font-family: 'Consolas', 'Liberation Mono', 'Menlo', 'Courier New', monospace;
    font-size: 11px;
    color: #666;
    background: rgba(0, 0, 0, 0.02);
}

:root:not([data-theme="light"]) .debug-table {
    color: #999;
    background: rgba(255, 255, 255, 0.03);
}

.debug-table td {
    padding: 2px 4px;
    vertical-align: top;
}

.document-error-icon {
    width: 16px;
    height: 16px;
    margin: 0;
    vertical-align: middle;
}

.debug-hex {
    width: 145px;
    min-width: 145px;
    max-width: 145px;
    font-family: 'Consolas', 'Liberation Mono', 'Menlo', 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

.debug-desc {
    padding-left: 12px;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
}

:root:not([data-theme="light"]) .debug-desc {
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.debug-missing {
    color: #e53e3e;
    font-weight: 600;
}

.debug-truncated {
    color: #666;
    font-size: 9px;
    font-style: italic;
}

:root:not([data-theme="light"]) .debug-truncated {
    color: #999;
}

/* Error debug table styling */
.debug-table.debug-error td {
    color: #e53e3e;
    background: rgba(229, 62, 62, 0.05);
}

:root:not([data-theme="light"]) .debug-table.debug-error td {
    color: #fc8181;
    background: rgba(229, 62, 62, 0.1);
}

/* StatusResponse debug table styling - printer responses (FROM printer TO client) */
.debug-table.debug-statusResponse td {
    color: #047857;
    background: rgba(16, 185, 129, 0.08);
}

:root:not([data-theme="light"]) .debug-table.debug-statusResponse td {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.15);
}

/* ============================================================================
   Documents Panel State Templates
   ============================================================================ */

/* Landing Page (No Workspace) */
.docs-landing {
    max-width: 600px;
    margin: 30px auto;
    text-align: center;
}

.docs-landing h1 {
    margin-bottom: 12px;
}

.docs-landing-subtitle {
    color: var(--muted);
    font-size: 16px;
    margin: 0 0 24px;
    line-height: 1.5;
}

.docs-landing-card {
    text-align: left;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.docs-landing-card h3 {
    margin-top: 0;
    margin-bottom: 12px;
}

.docs-landing-card p {
    color: var(--muted);
    line-height: 1.6;
    margin: 0;
}

.docs-landing-card ul {
    color: var(--muted);
    line-height: 1.6;
    padding-left: 24px;
    margin: 0;
}

.docs-landing-cta {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 20px;
}

.docs-landing-cta h3 {
    margin-top: 0;
    margin-bottom: 8px;
    color: var(--accent);
}

.docs-landing-cta p {
    color: var(--muted);
    margin-bottom: 16px;
}

.docs-landing-actions {
    display: flex;
    gap: 12px;
}

.docs-landing-actions .btn {
    flex: 1;
    justify-content: center;
}

.docs-link {
    color: var(--accent);
}

/* Empty State (No Printer Selected / No Documents) */
.docs-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

.docs-empty-state h2 {
    margin: 0 0 8px;
}

.docs-empty-state h3 {
    margin: 0 0 8px;
}

.docs-empty-state p {
    margin: 0;
}

/* Setup Card (No Documents state) */
.docs-setup-card {
    text-align: left;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin: 30px auto;
    max-width: 500px;
}

.docs-setup-card h4 {
    margin-top: 0;
    margin-bottom: 16px;
}

.docs-setup-card p {
    margin-bottom: 16px;
}

.docs-setup-info {
    background: var(--bg);
    border-radius: 8px;
    padding: 16px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.8;
}

.docs-setup-link {
    margin: 24px 0 0 0;
    color: var(--muted);
    line-height: 1.5;
}

/* Multiple canvas blocks */
.document-canvas-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 32px;
}

.document-canvas-footer {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 0;
}

.document-canvas-footer-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.document-canvas-block:last-child {
    margin-bottom: 0;
}

/* ============================================================================
   Loading / Pagination Indicators
   ============================================================================ */

.docs-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 14px;
}

.docs-loading-more {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 20px;
    color: var(--muted);
    font-size: 13px;
}

/* Spacer below the last document batch — visible area that triggers loading */
.docs-scroll-spacer {
    height: 40px;
    flex-shrink: 0;
}

.docs-progress-bar {
    width: 180px;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.docs-progress-bar-fill {
    height: 100%;
    width: 30%;
    background: var(--accent);
    border-radius: 2px;
    animation: docs-progress-slide 1.2s ease-in-out infinite;
}

@keyframes docs-progress-slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(700%); }
}
