/* ============================================================
   fileworker.css
   Owns: file grid · file list rows · drop zone ·
         tag filter chips · upload progress bar ·
         source badges · file icon mapping.

   Does NOT own:
     • Upload popup / visibility sheet  → dialog.css
     • Font imports                      → styles.css
     • Base tokens                       → styles.css
   ============================================================ */


/* ── 1. FILES PANEL SHELL ────────────────────────────────────
   ──────────────────────────────────────────────────────────── */

.files-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Topbar: title + view toggle + upload button */
.files-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--separator);
}

.files-topbar-left {
  flex: 1;
  min-width: 0;
}

.files-topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.files-topbar-sub {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.files-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* View toggle — icon pair */
.fw-view-toggle {
  display: flex;
  gap: 2px;
  background: var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.fw-view-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.fw-view-btn:hover  { color: var(--text-primary); }
.fw-view-btn.active {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Upload button */
.fw-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.fw-upload-btn:hover  { background: var(--accent-hover); }
.fw-upload-btn:active { transform: scale(0.96); }


/* ── 2. SEARCH BAR ───────────────────────────────────────────
   ──────────────────────────────────────────────────────────── */

.files-search-wrap {
  position: relative;
  padding: 10px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--separator);
}

.files-search-icon {
  position: absolute;
  left: 27px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.files-search-input {
  width: 100%;
  padding: 0.55rem 0.875rem 0.55rem 2.2rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.files-search-input::placeholder { color: var(--text-placeholder); }
.files-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}


/* ── 3. TAG FILTER CHIPS ─────────────────────────────────────
   Horizontal scroll below search.
   ──────────────────────────────────────────────────────────── */

.files-tag-row {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--separator);
}

.files-tag-row::-webkit-scrollbar { display: none; }
.files-tag-row:empty { display: none; }

.fw-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.13s, background 0.13s, color 0.13s;
  -webkit-tap-highlight-color: transparent;
}

.fw-tag-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.fw-tag-chip.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}


/* ── 4. UPLOAD PROGRESS ──────────────────────────────────────
   Shown while a file is uploading.
   ──────────────────────────────────────────────────────────── */

.fw-progress-wrap {
  padding: 8px 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fw-progress-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.fw-progress-bar {
  height: 4px;
  background: var(--separator);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.fw-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.fw-progress-fill--done { background: var(--success); width: 100%; }
.fw-progress-fill--error { background: var(--danger); }


/* ── 5. SCROLLABLE CONTENT AREA ──────────────────────────────
   ──────────────────────────────────────────────────────────── */

.files-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 80px;
}


/* ── 6. DROP ZONE ────────────────────────────────────────────
   Full-area drag-and-drop target.  Shown when dragging a file
   over the panel.
   ──────────────────────────────────────────────────────────── */

.fw-drop-zone {
  position: relative;
  flex: 1;
}

.fw-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2.5px dashed var(--accent);
  border-radius: var(--radius-lg);
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  pointer-events: none;
}

.fw-drop-overlay-icon { font-size: 2.2rem; }
.fw-drop-zone.dragging .fw-drop-overlay { display: flex; }


/* ── 7. SECTION HEADER ───────────────────────────────────────
   Used when files are grouped by tag.
   ──────────────────────────────────────────────────────────── */

.fw-section {
  margin-bottom: 20px;
}

.fw-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0 2px;
}

.fw-section-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
}

.fw-section-count {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.fw-section-sep {
  flex: 1;
  height: 1px;
  background: var(--separator);
}


/* ── 8. GRID VIEW ────────────────────────────────────────────
   ──────────────────────────────────────────────────────────── */

.fw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

/* File card */
.fw-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.14s, box-shadow 0.14s;
  cursor: default;
}

.fw-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

/* Preview area */
.fw-card-preview {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-bottom: 1px solid var(--separator);
  overflow: hidden;
  flex-shrink: 0;
}

.fw-card-img  { width: 100%; height: 100%; object-fit: cover; }
.fw-card-icon { font-size: 2.2rem; }

/* Info row */
.fw-card-info {
  padding: 8px 10px 4px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fw-card-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fw-card-meta {
  font-size: 0.66rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Action buttons inside card */
.fw-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 4px 8px 8px;
}


/* ── 9. LIST VIEW ────────────────────────────────────────────
   ──────────────────────────────────────────────────────────── */

.fw-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* File row */
.fw-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.14s, box-shadow 0.14s;
  cursor: default;
}

.fw-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.fw-row-icon { font-size: 1.5rem; flex-shrink: 0; }

.fw-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fw-row-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fw-row-meta {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fw-row-actions {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}


/* ── 10. SHARED ACTION BUTTON ────────────────────────────────
   Used in both grid and list for download / delete.
   ──────────────────────────────────────────────────────────── */

.fw-action-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.fw-action-btn:hover             { background: var(--accent-light); color: var(--accent); }
.fw-action-btn--danger:hover     { background: var(--danger-light); color: var(--danger); }
.fw-action-btn:active            { transform: scale(0.88); }


/* ── 11. SOURCE BADGE ────────────────────────────────────────
   "Via Topic" badge shown on report-sourced attachments.
   ──────────────────────────────────────────────────────────── */

.fw-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: var(--accent-light);
  color: var(--accent);
  flex-shrink: 0;
}

.fw-source-badge--upload {
  background: var(--success-light);
  color: var(--success);
}


/* ── 12. VISIBILITY BADGE ────────────────────────────────────
   Public / private label on file rows.
   ──────────────────────────────────────────────────────────── */

.fw-vis-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.62rem;
  font-weight: 700;
}

.fw-vis-badge--public  { background: var(--success-light); color: var(--success); }
.fw-vis-badge--private { background: var(--border);        color: var(--text-tertiary); }
.fw-vis-badge--friends { background: var(--accent-light);  color: var(--accent); }


/* ── 13. EMPTY STATE ────────────────────────────────────────
   ──────────────────────────────────────────────────────────── */

.fw-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  gap: 10px;
  text-align: center;
}

.fw-empty-icon {
  font-size: 2.4rem;
  opacity: 0.4;
}

.fw-empty-text {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  max-width: 260px;
  line-height: 1.55;
}

.fw-empty-action {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.83rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: background 0.14s, transform 0.1s;
}

.fw-empty-action:hover  { background: var(--accent-hover); }
.fw-empty-action:active { transform: scale(0.96); }


/* ── 14. RESPONSIVE ──────────────────────────────────────────
   ──────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .fw-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }
  .fw-row-meta { display: none; }
  .files-topbar { padding: 12px 14px 8px; }
  .files-scroll { padding: 10px 14px 80px; }
}

@media (prefers-reduced-motion: reduce) {
  .fw-card,
  .fw-row,
  .fw-tag-chip,
  .fw-upload-btn { transition: none; }
}


/* ── DIALOG DROPZONE ─────────────────────────────────────────
   Used inside CustomDialog body (not the full-panel overlay).
   Styled as a compact labelled drop target.
   ──────────────────────────────────────────────────────────── */

.fw-dlg-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 18px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 16px;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.fw-dlg-dropzone:hover,
.fw-dlg-dropzone--over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.fw-dlg-dropzone-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.fw-dlg-dropzone--over .fw-dlg-dropzone-label,
.fw-dlg-dropzone--file .fw-dlg-dropzone-label {
  color: var(--accent);
}

.fw-dlg-dropzone-hint {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* Tag chips in file cards — use CSS class instead of inline styles */
.fw-tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--accent-light);
  color: var(--accent);
  white-space: nowrap;
}

.fw-tag-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
