/* ============================================================
   widgets.css — Unified Gallery, Document Browser, Drop Hole,
                  Code Import/Export, CodeMirror, Shared Styles
   ============================================================ */

/* ---- 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;
  position: relative;
}
.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.ug-selected {
  border-color: rgba(59,130,246,0.7);
  box-shadow: 0 0 0 2px rgba(59,130,246,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);
}

/* ---- Tile checkbox ---- */
.ug-checkbox {
  position: absolute; top: 4px; left: 4px; z-index: 5;
  accent-color: #3b82f6; width: 16px; height: 16px;
  cursor: pointer;
}

/* ---- 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-row.ug-selected { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.4); }
.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;
  text-decoration: none;
}
.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: 95vw; max-height: 90vh;
  border-radius: 8px; overflow: auto; 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);
  resize: both; min-width: 300px; min-height: 200px;
  display: flex; flex-direction: column;
}
.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; }

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

/* ── Tab Bar ─────────────────────────────────────────────── */
.ug-tab-bar {
  display: flex; gap: 0;
  background: rgba(15,23,42,0.6);
  border-bottom: 1px solid rgba(59,130,246,0.12);
  flex-shrink: 0; height: 36px;
}
.ug-tab {
  flex: 1; padding: 0 12px; font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.35); background: none; border: none;
  cursor: pointer; transition: all 150ms ease; text-align: center;
  border-bottom: 2px solid transparent;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.ug-tab:hover { color: rgba(255,255,255,0.55); background: rgba(59,130,246,0.05); }
.ug-tab-active {
  color: rgba(255,255,255,0.9);
  border-bottom-color: #3b82f6;
  background: rgba(59,130,246,0.08);
}
.ug-tab i { font-size: 11px; }

/* ── Toolbar ─────────────────────────────────────────────── */
.ug-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 12px; height: 36px;
  background: rgba(15,23,42,0.4);
  border-bottom: 1px solid rgba(59,130,246,0.08);
  flex-shrink: 0;
}
.ug-toolbar-left {
  display: flex; align-items: center; gap: 4px;
}
.ug-tool-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 4px; font-size: 11px;
  background: rgba(51,65,85,0.3); border: 1px solid rgba(59,130,246,0.08);
  color: #94a3b8; cursor: pointer; transition: all 150ms ease;
}
.ug-tool-btn:hover { background: rgba(59,130,246,0.15); color: #e2e8f0; }
.ug-tool-btn.ug-tool-active {
  background: rgba(59,130,246,0.25); color: #60a5fa;
  border-color: rgba(59,130,246,0.4);
}
.ug-tool-btn.ug-tool-danger { color: #f87171; }
.ug-tool-btn.ug-tool-danger:hover { background: rgba(239,68,68,0.15); }

/* ── Breadcrumbs ─────────────────────────────────────────── */
.ug-breadcrumbs {
  display: flex; align-items: center; gap: 4px; font-size: 11px;
}
.ug-bc-item {
  color: #60a5fa; cursor: pointer; padding: 2px 4px; border-radius: 3px;
  transition: background 150ms;
}
.ug-bc-item:hover { background: rgba(59,130,246,0.15); }
.ug-bc-sep { color: #475569; }

/* ── Folder Cards ────────────────────────────────────────── */
.ug-folder-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 8px; border-radius: 8px;
  background: rgba(30,41,59,0.5); border: 1px solid rgba(59,130,246,0.1);
  cursor: pointer; transition: all 200ms ease;
}
.ug-folder-card:hover {
  background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3);
  transform: translateY(-1px);
}
.ug-folder-name {
  font-size: 10px; color: #94a3b8; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Placeholder Art ─────────────────────────────────────── */
.ug-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; width: 100%; height: 100%;
  min-height: 32px;
}
.ug-placeholder-circle {
  border-radius: 50%;
  background: color-mix(in srgb, var(--ph-bg, #64748b) 20%, transparent);
  display: flex; align-items: center; justify-content: center;
  color: var(--ph-bg, #64748b);
  box-shadow: 0 0 12px color-mix(in srgb, var(--ph-bg, #64748b) 15%, transparent);
}
.ug-placeholder-badge {
  font-weight: 700; letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--ph-bg, #64748b) 80%, white);
  text-transform: uppercase;
}

/* ── Source Badges ───────────────────────────────────────── */
.ug-source-badge {
  display: inline-flex; align-items: center; padding: 1px 6px;
  border-radius: 3px; font-size: 9px; font-weight: 600;
  letter-spacing: 0.03em; border: 1px solid;
}


/* ============================================================
   DROP HOLE — 3D Wireframe Gravitational Well
   ============================================================ */
.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;
}

.dh-core {
  position: absolute; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 300ms ease;
}
.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); }

.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; }

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

.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;
}
