/* ==========================================
   Media Viewer - Image & Video
   ========================================== */

.media-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  z-index: 4000;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease;
}

.media-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.media-viewer-title {
  font-size: 14px;
  font-weight: 500;
  color: #e0e0e0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-viewer-title i { color: #60cdff; }

.media-viewer-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.media-viewer-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255,255,255,0.06);
  color: #ccc;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
  position: relative;
}
.media-viewer-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.media-viewer-btn.close-viewer:hover { background: rgba(255,90,90,0.2); color: #ff6b6b; }
.media-viewer-btn.active { background: rgba(96,205,255,0.15); color: #60cdff; }

.media-viewer-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding: 20px;
}

/* Image viewer */
.media-viewer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  cursor: grab;
  transition: transform 0.15s ease;
  user-select: none;
}
.media-viewer-image.zoomed { cursor: zoom-out; }
.media-viewer-image.dragging { cursor: grabbing; transition: none; }

/* Video player */
.media-viewer-video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  outline: none;
  background: #000;
}

/* Video subtitles styling */
.media-viewer-video::cue {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 18px;
  font-family: 'Inter', sans-serif;
  line-height: 1.4;
  padding: 4px 8px;
  border-radius: 4px;
}

/* Navigation arrows */
.media-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  z-index: 10;
}
.media-nav-btn:hover { background: rgba(0, 120, 212, 0.6); transform: translateY(-50%) scale(1.1); }
.media-nav-prev { left: 20px; }
.media-nav-next { right: 20px; }

/* Info bar */
.media-viewer-info {
  padding: 8px 20px;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #8b949e;
  flex-shrink: 0;
}

/* ==========================================
   Track Selector (Subtitles & Audio)
   ========================================== */

.media-track-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.track-selector {
  position: relative;
}

.track-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5000;
  min-width: 260px;
  max-height: 300px;
  overflow-y: auto;
  background: rgba(30, 30, 30, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: fadeSlideIn 0.15s ease;
}
.track-dropdown.show { display: block; }

.track-menu {
  padding: 6px;
}

.track-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #ccc;
  transition: all 0.15s;
}
.track-option:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.track-option .fa-check {
  width: 14px;
  font-size: 10px;
  color: #60cdff;
  opacity: 0;
}
.track-option.active .fa-check {
  opacity: 1;
}
.track-option.active {
  color: #60cdff;
}

.track-lang {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(96,205,255,0.15);
  color: #60cdff;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 600;
  margin-left: auto;
}

.track-codec {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(255,217,61,0.15);
  color: #ffd93d;
  border-radius: 4px;
  font-weight: 600;
}

.track-detail {
  font-size: 11px;
  color: #8b949e;
}

/* ==========================================
   Archive Viewer Modal
   ========================================== */

.archive-modal { max-width: 700px !important; }
.archive-list {
  max-height: 400px;
  overflow-y: auto;
}
.archive-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
}
.archive-entry:hover { background: rgba(255,255,255,0.02); }
.archive-entry i { color: #60cdff; width: 18px; text-align: center; }
.archive-entry .entry-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-entry .entry-size { color: #8b949e; font-size: 12px; }
.archive-entry.is-dir i { color: #ffd93d; }

.archive-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ==========================================
   Document Viewer
   ========================================== */

.doc-viewer-content {
  flex: 1;
  overflow: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.doc-loading, .doc-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  font-size: 15px;
  color: #8b949e;
}
.doc-error { color: #ff6b6b; }
.doc-error i { font-size: 20px; }

.doc-warning {
  padding: 10px 20px;
  background: rgba(255, 217, 61, 0.1);
  color: #ffd93d;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255,217,61,0.15);
  flex-shrink: 0;
}

/* Text / Code Viewer */
.doc-text-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.doc-text-content {
  flex: 1;
  margin: 0;
  padding: 20px 24px;
  font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #d4d4d4;
  background: #1e1e1e;
  overflow: auto;
  tab-size: 4;
  white-space: pre-wrap;
  word-break: break-word;
}
.doc-text-content.doc-code {
  white-space: pre;
  word-break: normal;
}

/* Word Document Viewer */
.doc-word-wrapper {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 30px 20px;
  background: #3a3a3a;
}
.doc-word-content {
  max-width: 800px;
  width: 100%;
  background: #fff;
  color: #333;
  padding: 50px 60px;
  border-radius: 4px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.3);
  font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100%;
}
.doc-word-content h1 { font-size: 24px; margin: 16px 0 8px; color: #1a1a1a; }
.doc-word-content h2 { font-size: 20px; margin: 14px 0 6px; color: #1a1a1a; }
.doc-word-content h3 { font-size: 16px; margin: 12px 0 6px; color: #1a1a1a; }
.doc-word-content p { margin: 6px 0; }
.doc-word-content table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.doc-word-content td, .doc-word-content th {
  border: 1px solid #d0d0d0;
  padding: 6px 10px;
  font-size: 13px;
}
.doc-word-content img { max-width: 100%; }

/* Excel Viewer */
.doc-excel-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.excel-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
  overflow-x: auto;
}
.excel-tab {
  padding: 8px 18px;
  font-size: 12px;
  border: none;
  background: rgba(255,255,255,0.05);
  color: #aaa;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: all 0.15s;
  white-space: nowrap;
}
.excel-tab:hover { background: rgba(255,255,255,0.1); color: #ddd; }
.excel-tab.active {
  background: #2d2d2d;
  color: #60cdff;
  font-weight: 600;
}

.excel-sheet { display: none; flex: 1; overflow: hidden; }
.excel-sheet.active { display: flex; }

.excel-table-wrapper {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.excel-table {
  border-collapse: collapse;
  font-size: 12px;
  min-width: 100%;
  font-family: 'Cascadia Code', 'Consolas', monospace;
}
.excel-table tr:hover { background: rgba(96,205,255,0.05); }
.excel-table th, .excel-table td {
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.06);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.excel-table th {
  background: rgba(96,205,255,0.08);
  color: #60cdff;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
.excel-table td { color: #d4d4d4; }
.excel-row-num {
  background: rgba(255,255,255,0.03) !important;
  color: #6e6e6e !important;
  font-size: 10px;
  text-align: center;
  width: 40px;
  min-width: 40px;
  user-select: none;
  position: sticky;
  left: 0;
  z-index: 1;
}

/* PDF Viewer */
.doc-pdf-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  background: #525659;
}

/* ==========================================
   Video.js Integration Styles
   ========================================== */

.media-viewer-content .video-js {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
}

.media-viewer-content .video-js .vjs-tech {
  object-fit: contain;
}

/* Make Video.js control bar match our dark theme */
.media-viewer-content .video-js .vjs-control-bar {
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  height: 40px;
  padding: 0 8px;
}

.media-viewer-content .video-js .vjs-play-progress {
  background: #60cdff;
}

.media-viewer-content .video-js .vjs-slider {
  background: rgba(255,255,255,0.2);
}

.media-viewer-content .video-js .vjs-load-progress div {
  background: rgba(255,255,255,0.25);
}

/* Make big play button fit theme */
.media-viewer-content .video-js .vjs-big-play-button {
  background: rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  line-height: 60px;
  font-size: 24px;
}
.media-viewer-content .video-js:hover .vjs-big-play-button {
  background: rgba(96,205,255,0.3);
  border-color: #60cdff;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
