/* ===================================
   Attachment Viewer Modal
   Full-screen modal for viewing images and documents
   =================================== */

.attachment-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.attachment-viewer-modal.active {
    display: flex;
}

/* Overlay */
.viewer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
}

/* Container */
.viewer-container {
    position: relative;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
}

.viewer-title {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 16px;
}

.viewer-close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.viewer-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Content Area */
.viewer-content {
    flex: 1;
    padding: 20px;
    overflow: auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

/* Loading State */
.viewer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
}

.viewer-loading .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Image Container */
.viewer-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    height: 100%;
}

.viewer-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
    cursor: grab;
}

.viewer-image:active {
    cursor: grabbing;
}

/* Image Zoom Controls */
.viewer-image-controls {
    display: flex;
    gap: 8px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px;
}

.viewer-image-controls button {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #3b82f6;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-image-controls button:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
}

.zoom-reset {
    min-width: 60px !important;
    width: auto !important;
    padding: 0 12px;
    font-size: 14px !important;
}

/* Document Container */
.viewer-document-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    align-self: stretch;
}

.viewer-document-content {
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.viewer-document-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.viewer-document-content h1,
.viewer-document-content h2,
.viewer-document-content h3 {
    color: #3b82f6;
    margin-top: 24px;
    margin-bottom: 12px;
}

.viewer-document-content code {
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* Metadata Panel */
.viewer-metadata {
    padding: 16px 20px;
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.metadata-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.metadata-label {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.metadata-value {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9em;
}

/* Navigation for Multiple Attachments */
.viewer-navigation {
    padding: 12px 20px;
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    display: none;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.viewer-navigation button {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #3b82f6;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-navigation button:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
}

.viewer-navigation button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-position {
    color: var(--text-secondary);
    font-size: 0.9em;
    min-width: 60px;
    text-align: center;
}

/* Error State */
.viewer-error {
    color: #ef4444;
    padding: 20px;
    text-align: center;
    font-size: 1.1em;
}

/* Responsive */
@media (max-width: 768px) {
    .viewer-container {
        width: 95%;
        max-height: 95vh;
    }

    .viewer-header {
        padding: 12px 16px;
    }

    .viewer-content {
        padding: 12px;
    }

    .viewer-metadata {
        flex-direction: column;
        gap: 8px;
    }

    .viewer-image {
        max-height: 60vh;
    }
}

/* Light Theme Support */
[data-theme="light"] .viewer-overlay {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="light"] .viewer-container {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .viewer-header {
    background: rgba(0, 0, 0, 0.03);
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .viewer-metadata {
    background: rgba(0, 0, 0, 0.05);
    border-top-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .viewer-navigation {
    background: rgba(0, 0, 0, 0.05);
    border-top-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .viewer-document-content {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .viewer-document-content pre {
    background: rgba(0, 0, 0, 0.08);
}
