/* ── File Viewer Modal ─────────────────────────────────────────────────────── */

.fv-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 700;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
}
.fv-overlay.open { opacity: 1; pointer-events: all; }

.fv-modal {
  z-index: 701;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  width: 90vw; max-width: 1100px; height: 85vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */

.fv-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.fv-toolbar-name {
  flex: 1; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.fv-toolbar-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
  color: var(--text-muted); text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.fv-toolbar-btn:hover { background: var(--hover-bg); color: var(--text); }
.fv-toolbar-close {
  font-size: 18px; line-height: 1; border: none; background: none;
  cursor: pointer; color: var(--text-muted); padding: 4px 8px;
}
.fv-toolbar-close:hover { color: var(--text); }

/* ── Body ─────────────────────────────────────────────────────────────────── */

.fv-body {
  flex: 1; overflow-y: auto; padding: 16px;
  min-height: 0;
}

/* ── Loading / Empty / Message states ─────────────────────────────────────── */

.fv-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); font-size: 13px; gap: 8px;
}
.fv-spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: fv-spin 0.6s linear infinite;
}
@keyframes fv-spin { to { transform: rotate(360deg); } }

.fv-empty, .fv-message {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; gap: 12px;
  color: var(--text-muted); font-size: 14px; text-align: center;
}
.fv-message-icon { font-size: 36px; opacity: 0.5; }
.fv-message-text { max-width: 320px; line-height: 1.5; }
.fv-message-btn {
  margin-top: 8px; padding: 6px 16px; border-radius: 6px;
  background: var(--accent); color: #fff; text-decoration: none;
  font-size: 12px; font-weight: 500; display: inline-block;
}
[data-theme="c128"] .fv-message-btn { background: #0a140a; color: #33ff33; border: 1px solid #33ff33; }
[data-theme="ur6000"] .fv-message-btn { background: #0d0a00; color: #ffb000; border: 1px solid #ffb000; }
[data-theme="haven3019"] .fv-message-btn { background: #0d1520; color: #7eb8d4; border: 1px solid #7eb8d4; }
[data-theme="high-contrast"] .fv-message-btn { background: #ffff00; color: #000000; border: 1px solid #ffff00; }
.fv-message-btn:hover { opacity: 0.9; }

/* ── Image renderer ───────────────────────────────────────────────────────── */

.fv-image {
  display: block; max-width: 100%; max-height: 100%;
  margin: 0 auto; object-fit: contain;
}

/* ── PDF renderer ─────────────────────────────────────────────────────────── */

.fv-pdf-page {
  display: block; margin: 0 auto 8px auto; max-width: 100%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── DOCX renderer ────────────────────────────────────────────────────────── */

.fv-docx {
  background: #fff; padding: 20px; border-radius: 4px; min-height: 200px;
  color: #222;
}
.fv-docx table { border-collapse: collapse; width: 100%; }
.fv-docx td, .fv-docx th { border: 1px solid #ccc; padding: 4px 8px; }

/* ── XLSX renderer ────────────────────────────────────────────────────────── */

.fv-xlsx-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  margin-bottom: 12px; flex-shrink: 0; padding: 0 16px;
}
.fv-xlsx-tab {
  padding: 6px 14px; font-size: 11px; border: 1px solid var(--border);
  border-bottom: none; border-radius: 6px 6px 0 0;
  background: var(--hover-bg); color: var(--text-muted); cursor: default;
  margin-right: -1px;
}
.fv-xlsx-tab-active {
  background: var(--panel-bg); color: var(--text); font-weight: 600;
  border-bottom: 1px solid var(--panel-bg); margin-bottom: -1px;
}
.fv-xlsx-tab-disabled { opacity: 0.5; cursor: not-allowed; }

.fv-xlsx-table { overflow-x: auto; }
.fv-xlsx-table table {
  width: 100%; border-collapse: collapse; font-size: 11px;
}
.fv-xlsx-table td, .fv-xlsx-table th {
  border: 1px solid var(--border); padding: 4px 8px; text-align: left;
}
.fv-xlsx-table th { background: var(--hover-bg); font-weight: 600; }
.fv-xlsx-table tr:nth-child(even) { background: var(--hover-bg); }

/* ── Plain text renderer ──────────────────────────────────────────────────── */

.fv-pre {
  margin: 0; white-space: pre-wrap; word-wrap: break-word;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 12px; line-height: 1.5; color: var(--text);
}
