/* ============================================================
   widgets.css — Media Gallery, Document Browser & Drop Hole
   ============================================================ */

/* ---- SHARED: Filter bar, grid, tiles ---- */
.wg-filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(59,130,246,0.15);
  background: rgba(15,23,42,0.5);
  flex-shrink: 0;
}
.wg-filter-group {
  display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0;
  background: rgba(30,41,59,0.6); border: 1px solid rgba(59,130,246,0.15);
  border-radius: 6px; padding: 0 8px;
}
.wg-filter-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: #e2e8f0; font-size: 12px; padding: 6px 0; font-family: inherit;
}
.wg-filter-input::placeholder { color: #64748b; }
.wg-filter-select {
  background: rgba(30,41,59,0.6); border: 1px solid rgba(59,130,246,0.15);
  border-radius: 6px; color: #94a3b8; font-size: 11px; padding: 5px 8px;
  outline: none; cursor: pointer; font-family: inherit;
}
.wg-filter-select:hover { border-color: rgba(59,130,246,0.4); }
.wg-filter-select option { background: #1e293b; }

.wg-icon-btn {
  width: 28px; height: 28px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(51,65,85,0.4); border: 1px solid rgba(59,130,246,0.1);
  color: #64748b; cursor: pointer; transition: all 150ms ease;
  font-size: 11px; flex-shrink: 0;
}
.wg-icon-btn:hover { background: rgba(59,130,246,0.2); color: #94a3b8; }
.wg-icon-btn.active { background: rgba(59,130,246,0.3); color: #60a5fa; border-color: rgba(59,130,246,0.4); }

.wg-gallery-body {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px; position: relative;
}

/* ---- GRID LAYOUTS ---- */
.wg-gallery-grid { display: grid; gap: 8px; align-content: start; min-height: 100%; }
.wg-gallery-grid.cols-1 { grid-template-columns: 1fr; }
.wg-gallery-grid.cols-2 { grid-template-columns: repeat(2,1fr); }
.wg-gallery-grid.cols-4 { grid-template-columns: repeat(4,1fr); }
.wg-gallery-grid.cols-6 { grid-template-columns: repeat(6,1fr); }
.wg-gallery-grid.cols-8 { grid-template-columns: repeat(8,1fr); }

/* ---- TILES ---- */
.wg-tile {
  background: rgba(15,23,42,0.45); border: 1px solid rgba(59,130,246,0.1);
  border-radius: 6px; overflow: hidden; cursor: pointer; transition: all 200ms ease;
}
.wg-tile:hover {
  border-color: rgba(59,130,246,0.4); transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.wg-tile-img {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.2); overflow: hidden;
}
.wg-tile-img img { width: 100%; height: 100%; object-fit: cover; opacity: 1; }
.wg-tile-label {
  padding: 4px 6px; font-size: 10px; color: #94a3b8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-top: 1px solid rgba(59,130,246,0.05);
}

/* ---- LIST MODE ---- */
.wg-list-header {
  display: flex; align-items: center; gap: 12px; padding: 4px 10px;
  font-size: 10px; font-weight: 600; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(59,130,246,0.1);
  user-select: none;
}
.wg-list-row {
  display: flex; align-items: center; gap: 12px; padding: 6px 10px;
  border-radius: 6px; cursor: pointer; transition: all 150ms ease;
  border: 1px solid transparent;
}
.wg-list-row:hover { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.2); }
.wg-list-tag {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  background: rgba(59,130,246,0.12); color: #94a3b8;
  font-size: 10px; font-weight: 500; text-transform: capitalize;
}
.wg-list-thumb {
  width: 40px; height: 40px; border-radius: 4px; background: rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.wg-list-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 1; }
.wg-list-icon {
  width: 36px; height: 36px; border-radius: 6px; background: rgba(30,41,59,0.6);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 15px;
}
.wg-list-name { font-size: 13px; font-weight: 500; color: #e2e8f0; }
.wg-list-meta { font-size: 11px; color: #64748b; margin-top: 2px; }
.wg-doc-open-btn {
  width: 28px; height: 28px; border-radius: 4px; background: transparent;
  border: 1px solid rgba(59,130,246,0.15); display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: all 150ms ease; flex-shrink: 0;
}
.wg-doc-open-btn:hover { background: rgba(59,130,246,0.2); border-color: rgba(59,130,246,0.4); }

/* ---- STRIP MODE ---- */
.wg-gallery-grid.strip-main { height: calc(100% - 80px); }
.wg-strip-hero {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.3); border-radius: 6px; overflow: hidden;
}
.wg-hero-media { max-width: 100%; max-height: 100%; object-fit: contain; }
.wg-thumb-strip {
  display: flex; gap: 6px; padding: 8px 0; overflow-x: auto; flex-shrink: 0;
}
.wg-strip-thumb {
  width: 56px; height: 56px; border-radius: 4px; background: rgba(0,0,0,0.3);
  border: 2px solid transparent; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; overflow: hidden; transition: border-color 150ms ease;
}
.wg-strip-thumb:hover { border-color: rgba(59,130,246,0.4); }
.wg-strip-thumb.active { border-color: #3b82f6; }
.wg-strip-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 1; }

/* ---- PREVIEW OVERLAY ---- */
.wg-preview-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
}
.wg-preview-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
}
.wg-preview-card {
  position: relative; z-index: 1; max-width: 90%; max-height: 90%;
  border-radius: 8px; overflow: hidden; background: rgba(15,23,42,0.45);
  border: 1px solid rgba(59,130,246,0.3); box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.wg-preview-header {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid rgba(59,130,246,0.15); background: rgba(15,23,42,0.45);
}
.wg-preview-media { max-width: 100%; max-height: 70vh; display: block; }

.wg-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 20px; color: #64748b; font-size: 14px; grid-column: 1 / -1;
}

/* ---- DOCUMENT VIEWER TOGGLES ---- */
.wg-view-toggle {
  width: 28px; height: 28px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(51,65,85,0.4); border: 1px solid rgba(59,130,246,0.1);
  color: #64748b; cursor: pointer; transition: all 150ms ease; font-size: 12px;
}
.wg-view-toggle:hover { background: rgba(59,130,246,0.2); color: #94a3b8; }
.wg-view-toggle.active { background: rgba(59,130,246,0.3); color: #60a5fa; border-color: rgba(59,130,246,0.4); }

.docview-code { padding: 12px; }
.docview-preview { border-radius: 0; }

/* ---- MEDIA GALLERY WIDGET: semi-transparent fill ---- */
#media-gallery-widget {
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
#media-gallery-widget .wg-tile-img img,
#media-gallery-widget .wg-list-thumb img,
#media-gallery-widget .wg-strip-thumb img,
#media-gallery-widget .wg-hero-media,
#media-gallery-widget .wg-preview-media {
  opacity: 1 !important;
}

/* ---- DOCUMENT BROWSER: semi-transparent ---- */
#doc-browser-widget {
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}


/* ============================================================
   DROP HOLE — 3D Wireframe Gravitational Well
   Fully transparent, frameless, draggable canvas widget.
   ============================================================ */
.drop-hole-widget {
  position: fixed !important;
  z-index: 200 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  overflow: visible !important;
  pointer-events: none;
}
.drop-hole-widget.visible { pointer-events: auto; display: block !important; }

.dh-well {
  width: 100%; height: 100%;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
}
.dh-well:active { cursor: grabbing; }

#dh-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* Core — click-to-browse target, positioned over the well centre */
.dh-core {
  position: absolute;
  z-index: 5;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 300ms ease;
  /* positioned by JS at the projected well centre */
}
.dh-core:hover .dh-icon { color: rgba(45,212,191,1); text-shadow: 0 0 24px rgba(45,212,191,0.6); }

.dh-core-inner {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 5px; text-align: center;
}

.dh-icon {
  font-size: 24px; color: rgba(45,212,191,0.7);
  transition: all 300ms ease;
  text-shadow: 0 0 12px rgba(45,212,191,0.3);
}
.dh-text {
  font-size: 11px; font-weight: 600; color: rgba(226,232,240,0.85);
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
}
.dh-subtext { font-size: 9px; color: #64748b; text-shadow: 0 0 6px rgba(0,0,0,0.8); }

.dh-progress {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: #2dd4bf;
  text-shadow: 0 0 10px rgba(0,0,0,0.8);
}

/* Tiny close button — top-right corner */
.dh-close-btn {
  position: absolute; top: 4px; right: 4px; z-index: 10;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(15,23,42,0.45); border: 1px solid rgba(100,116,139,0.3);
  color: #64748b; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 10px; transition: all 200ms ease;
  opacity: 0; pointer-events: none;
}
.drop-hole-widget:hover .dh-close-btn { opacity: 1; pointer-events: auto; }
.dh-close-btn:hover { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.5); color: #f87171; }

/* ---- STATE: drag-active ---- */
.dh-active .dh-icon { color: #4ade80 !important; text-shadow: 0 0 20px rgba(74,222,128,0.5); }

/* ---- Appear / Disappear ---- */
.dh-appear {
  animation: dh-open 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes dh-open {
  0%   { transform: translate(-50%,-50%) scale(0.3); opacity: 0; }
  100% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
}
.dh-disappear {
  animation: dh-close 0.3s ease-in forwards;
}
@keyframes dh-close {
  0%   { opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(0.3); opacity: 0; }
}

/* ============================================================
   CODEMIRROR 5 STYLES
   ============================================================ */
.CodeMirror {
  height: 100% !important;
  background: #0b1120 !important;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.5;
}
.CodeMirror-gutters {
  background: rgba(15,23,42,0.45) !important;
  border-right: 1px solid rgba(59,130,246,0.15) !important;
}
.CodeMirror-linenumber { color: #475569 !important; }
.CodeMirror-cursor { border-color: #60a5fa !important; }
.CodeMirror-selected { background: rgba(59,130,246,0.2) !important; }
.CodeMirror-activeline-background { background: rgba(59,130,246,0.06) !important; }
.CodeMirror-dialog {
  background: #1e293b !important;
  color: #e2e8f0 !important;
}
.CodeMirror-dialog input {
  color: #e2e8f0 !important;
  background: #0f172a !important;
  border: 1px solid rgba(59,130,246,0.3) !important;
}
.CodeMirror-merge { height: 100% !important; }
.CodeMirror-merge-pane { height: 100% !important; }
.CodeMirror-merge-gap { background: #0f172a !important; }
.CodeMirror-merge-r-deleted, .CodeMirror-merge-l-deleted {
  background: rgba(239,68,68,0.15) !important;
}
.CodeMirror-merge-r-inserted, .CodeMirror-merge-l-inserted {
  background: rgba(34,197,94,0.15) !important;
}

/* Document toolbar buttons */
.doc-save-btn, .doc-diff-btn {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
}
.doc-save-btn {
  background: rgba(34,197,94,0.2);
  border: 1px solid rgba(34,197,94,0.4);
  color: #4ade80;
}
.doc-save-btn:hover { background: rgba(34,197,94,0.3); }
.doc-diff-btn {
  background: rgba(139,92,246,0.2);
  border: 1px solid rgba(139,92,246,0.4);
  color: #a78bfa;
}
.doc-diff-btn:hover { background: rgba(139,92,246,0.3); }
.doc-diff-btn.active {
  background: rgba(59,130,246,0.3);
  border-color: rgba(59,130,246,0.5);
  color: #60a5fa;
}

/* ============================================================
   COMMAND PALETTE — semi-transparent
   ============================================================ */
.command-palette-box {
  background: rgba(15,23,42,0.45) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
}
