/* ── Viewer Modal ─────────────────────────────────────────────── */

.viewer-backdrop {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(8px) saturate(140%);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    animation: viewerFadeIn 0.2s ease;
}
@keyframes viewerFadeIn { from{opacity:0} to{opacity:1} }

.viewer-panel {
    background: rgba(6,0,20,0.97);
    border: 1px solid rgba(0,212,255,0.25);
    border-radius: 6px;
    width: min(1200px, 100%);
    height: 92vh;
    display: flex; flex-direction: column;
    box-shadow: 0 0 60px rgba(0,212,255,0.08), 0 30px 80px rgba(0,0,0,0.7);
    animation: viewerSlideIn 0.2s ease;
    overflow: hidden;
}
@keyframes viewerSlideIn {
    from { opacity:0; transform:scale(0.97) translateY(8px); }
    to   { opacity:1; transform:scale(1)    translateY(0); }
}

/* Header */
.viewer-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(0,212,255,0.1);
    flex-shrink: 0;
    background: rgba(0,212,255,0.02);
}
.viewer-title-wrap {
    display: flex; align-items: center; gap: 0.5rem;
    min-width: 0;
}
.viewer-type-badge {
    font-family: 'Share Tech Mono', monospace; font-size: 0.65rem;
    padding: 0.1rem 0.4rem; border-radius: 3px;
    border: 1px solid; letter-spacing: 0.05em; flex-shrink: 0;
}
.badge-image    { color: #00ff88; border-color: rgba(0,255,136,0.3); background: rgba(0,255,136,0.06); }
.badge-video    { color: #ff006e; border-color: rgba(255,0,110,0.3); background: rgba(255,0,110,0.06); }
.badge-audio    { color: #ff8c00; border-color: rgba(255,140,0,0.3); background: rgba(255,140,0,0.06); }
.badge-text,
.badge-code     { color: #a371f7; border-color: rgba(163,113,247,0.3); background: rgba(163,113,247,0.06); }
.badge-document { color: #00d4ff; border-color: rgba(0,212,255,0.3); background: rgba(0,212,255,0.06); }
.badge-other    { color: rgba(140,195,215,0.52); border-color: rgba(0,212,255,0.14); background: transparent; }

.viewer-filename {
    font-family: 'Share Tech Mono', monospace; font-size: 0.85rem;
    color: rgba(210,245,255,0.92);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.viewer-hdr-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.viewer-close-btn {
    background: none; border: 1px solid rgba(0,212,255,0.14);
    border-radius: 4px; color: rgba(140,195,215,0.52);
    width: 30px; height: 30px; font-size: 1.1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; font-family: monospace; line-height: 1;
}
.viewer-close-btn:hover { background: rgba(255,0,110,0.1); border-color: rgba(255,0,110,0.4); color: #ff006e; }

/* Body */
.viewer-body {
    flex: 1; overflow: auto; min-height: 0;
    display: flex; align-items: flex-start; justify-content: center;
    position: relative;
    align-self: stretch;
}

/* Image viewer */
.viewer-img {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
    display: block; margin: auto;
    border-radius: 4px;
}

/* Video viewer */
.viewer-video {
    max-width: 100%; max-height: 100%;
    display: block; margin: auto;
    border-radius: 4px;
    outline: none;
}

/* Audio viewer */
.viewer-audio-wrap {
    display: flex; flex-direction: column; align-items: center;
    gap: 1.5rem; padding: 3rem 2rem; width: 100%; max-width: 520px;
}
.viewer-audio-icon {
    width: 100px; height: 100px; border-radius: 50%;
    background: rgba(255,140,0,0.08); border: 2px solid rgba(255,140,0,0.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 2.5rem;
    box-shadow: 0 0 40px rgba(255,140,0,0.15);
    animation: audioPulse 2.5s ease-in-out infinite;
}
@keyframes audioPulse { 0%,100%{box-shadow:0 0 30px rgba(255,140,0,.12)} 50%{box-shadow:0 0 50px rgba(255,140,0,.25)} }
.viewer-audio-name {
    font-family: 'Share Tech Mono', monospace; font-size: 0.85rem;
    color: rgba(140,195,215,0.52); text-align: center;
    max-width: 400px; word-break: break-word;
}
.viewer-audio-player {
    width: 100%;
    accent-color: #ff8c00;
    outline: none;
}

/* PDF viewer */
.viewer-pdf {
    width: 100%; height: 100%; border: none;
    display: block;
    min-height: 600px;
}

/* Text editor */
.viewer-text-wrap {
    display: flex; flex-direction: column;
    width: 100%; height: 100%; min-height: 0;
    align-self: stretch; flex: 1;
}
.viewer-text-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.4rem 1rem;
    border-bottom: 1px solid rgba(0,212,255,0.08);
    background: rgba(0,212,255,0.02);
    flex-shrink: 0;
}
.viewer-text-info {
    font-family: 'Share Tech Mono', monospace; font-size: 0.7rem;
    color: rgba(140,195,215,0.52); letter-spacing: 0.03em;
    display: flex; gap: 1rem;
}
.viewer-editor {
    flex: 1; resize: none; border: none; outline: none;
    background: transparent;
    color: rgba(210,245,255,0.88);
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 0.82rem; line-height: 1.7;
    padding: 1rem 1.25rem;
    width: 100%;
    tab-size: 4;
}
.viewer-editor[readonly] { cursor: default; }
.viewer-editor:not([readonly]) {
    background: rgba(0,212,255,0.015);
    caret-color: #00d4ff;
}
.viewer-editor:not([readonly]):focus { outline: none; }

/* Footer (text tools) */
.viewer-footer {
    border-top: 1px solid rgba(0,212,255,0.1);
    background: rgba(0,212,255,0.02);
    flex-shrink: 0;
}
.viewer-footer-inner {
    padding: 0.65rem 1.25rem;
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.viewer-save-btn {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-family: 'Share Tech Mono', monospace; font-size: 0.75rem;
    padding: 0.35rem 0.8rem; border-radius: 4px;
    background: rgba(0,212,255,0.1); color: #00d4ff;
    border: 1px solid rgba(0,212,255,0.3);
    cursor: pointer; transition: all 0.2s; letter-spacing: 0.04em;
}
.viewer-save-btn svg { width: 12px; height: 12px; }
.viewer-save-btn:hover { background: rgba(0,212,255,0.2); box-shadow: 0 0 16px rgba(0,212,255,0.2); }
.viewer-save-btn:disabled { opacity: 0.4; cursor: default; }
.viewer-save-status {
    font-family: 'Share Tech Mono', monospace; font-size: 0.72rem;
    color: rgba(140,195,215,0.52);
}
.viewer-save-status.ok  { color: #00ff88; }
.viewer-save-status.err { color: #ff006e; }

/* Versions panel */
.viewer-versions-toggle {
    margin-left: auto;
    font-family: 'Share Tech Mono', monospace; font-size: 0.72rem;
    color: rgba(140,195,215,0.52); background: none;
    border: 1px solid rgba(0,212,255,0.14); border-radius: 4px;
    padding: 0.25rem 0.6rem; cursor: pointer; transition: all 0.2s;
    letter-spacing: 0.04em;
}
.viewer-versions-toggle:hover { color: #00d4ff; border-color: rgba(0,212,255,0.35); }

.viewer-versions-panel {
    border-top: 1px solid rgba(0,212,255,0.08);
    padding: 0.75rem 1.25rem;
    max-height: 180px; overflow-y: auto;
}
.viewer-versions-title {
    font-family: 'Share Tech Mono', monospace; font-size: 0.65rem;
    color: rgba(140,195,215,0.52); text-transform: uppercase;
    letter-spacing: 0.1em; margin-bottom: 0.5rem;
}
.version-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.3rem 0; border-bottom: 1px solid rgba(0,212,255,0.05);
    font-family: 'Share Tech Mono', monospace; font-size: 0.72rem;
    color: rgba(140,195,215,0.52);
}
.version-row:last-child { border-bottom: none; }
.version-num { color: #00d4ff; min-width: 24px; }
.version-restore-btn {
    margin-left: auto; background: none;
    border: 1px solid rgba(0,212,255,0.14); border-radius: 3px;
    color: rgba(140,195,215,0.52); font-family: 'Share Tech Mono', monospace;
    font-size: 0.65rem; padding: 0.1rem 0.4rem; cursor: pointer;
    transition: all 0.15s; letter-spacing: 0.03em;
}
.version-restore-btn:hover { color: #00d4ff; border-color: rgba(0,212,255,0.35); }

/* Truncation warning banner */
.viewer-truncated-banner {
    padding: 0.35rem 1rem;
    background: rgba(255,140,0,0.08);
    border-bottom: 1px solid rgba(255,140,0,0.2);
    font-family: 'Share Tech Mono', monospace; font-size: 0.7rem;
    color: #ff8c00; flex-shrink: 0;
    display: flex; align-items: center; gap: 0.5rem;
}

/* Not viewable state */
.viewer-no-preview {
    display: flex; flex-direction: column; align-items: center;
    gap: 1rem; padding: 3rem; color: rgba(140,195,215,0.52);
    font-family: 'Share Tech Mono', monospace; font-size: 0.82rem;
    text-align: center;
}
.viewer-no-preview .big-icon { font-size: 3rem; opacity: 0.4; }
