/*
 * file-sharing.css — Phase 2A frontend styles.
 *
 * Pending-attachment chips, drop-zone overlay, in-bubble attachment blocks,
 * lightbox + PDF modal, FilesPanel (right sidebar), quota indicator widget.
 * Light + dark variants for every surface (admin-portal-style: rely on the
 * .dark class on <html>).
 */

/* ---------- Pending attachments bar (above compose pill) ---------- */

.pending-attachments-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 4px 4px;
  max-height: 140px;
  overflow-y: auto;
  animation: pending-bar-in 160ms ease-out;
}
.pending-attachments-bar.hidden { display: none; }
@keyframes pending-bar-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.file-chip {
  animation: file-chip-in 140ms ease-out;
}
@keyframes file-chip-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 9999px;
  max-width: 260px;
  font-size: 13px;
  color: #1e293b;
}
html.dark .file-chip {
  background: rgba(30, 41, 59, 0.6);
  border-color: #475569;
  color: #e2e8f0;
}

.file-chip-icon { color: #64748b; }
html.dark .file-chip-icon { color: #94a3b8; }

.file-chip-meta { min-width: 0; flex: 1; }
.file-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.file-chip-size { font-size: 11px; color: #475569; font-variant-numeric: tabular-nums; }
html.dark .file-chip-size { color: #cbd5e1; }

.file-chip-progress {
  margin-top: 4px;
  height: 3px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}
html.dark .file-chip-progress { background: #334155; }
.file-chip-progress-bar {
  height: 100%;
  background: #6366f1;
  transition: width 120ms ease;
}
.file-chip-error { color: #ef4444; font-size: 11px; }

.file-chip-remove {
  background: transparent;
  border: 0;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 9999px;
}
.file-chip-remove:hover { color: #ef4444; background: rgba(239, 68, 68, 0.08); }
html.dark .file-chip-remove { color: #94a3b8; }
html.dark .file-chip-remove:hover { color: #f87171; background: rgba(248, 113, 113, 0.15); }

/* ---------- Drop-zone overlay ---------- */

.file-drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(99, 102, 241, 0.12);
  border: 2px dashed #6366f1;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  pointer-events: none;
  backdrop-filter: blur(2px);
}
html.dark .file-drop-overlay {
  background: rgba(99, 102, 241, 0.22);
  border-color: #818cf8;
}
.file-drop-overlay-inner {
  text-align: center;
  color: #4f46e5;
}
html.dark .file-drop-overlay-inner { color: #c7d2fe; }
.file-drop-icon { font-size: 48px; margin-bottom: 12px; }
.file-drop-title { font-size: 18px; font-weight: 600; }
.file-drop-hint { font-size: 13px; margin-top: 4px; opacity: 0.8; }

/* ---------- In-bubble attachments ---------- */

.attachment {
  margin-top: 6px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 360px;
}

.attachment-image img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  cursor: zoom-in;
  border-radius: 10px 10px 0 0;
  background: #e2e8f0;
}
html.dark .attachment-image img { background: #334155; }

.attachment-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  font-size: 12px;
  background: #f8fafc;
  color: #64748b;
}
html.dark .attachment-meta-row { background: rgba(30, 41, 59, 0.6); color: #94a3b8; }
.attachment-meta-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-meta-download,
.attachment-generic-download,
.attachment-pdf-open {
  background: #6366f1;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}
.attachment-meta-download:hover,
.attachment-generic-download:hover,
.attachment-pdf-open:hover { background: #4f46e5; }

.attachment-pdf,
.attachment-generic {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
html.dark .attachment-pdf,
html.dark .attachment-generic {
  background: rgba(30, 41, 59, 0.6);
  border-color: #475569;
}
.attachment-pdf-icon i { color: #ef4444; font-size: 24px; }
.attachment-generic-icon i { color: #64748b; font-size: 24px; }
html.dark .attachment-generic-icon i { color: #94a3b8; }
.attachment-pdf-meta,
.attachment-generic-meta { flex: 1; min-width: 0; }
.attachment-pdf-name,
.attachment-generic-name {
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html.dark .attachment-pdf-name,
html.dark .attachment-generic-name { color: #e2e8f0; }
.attachment-pdf-size,
.attachment-generic-size { font-size: 11px; color: #64748b; }
html.dark .attachment-pdf-size,
html.dark .attachment-generic-size { color: #94a3b8; }

.attachment-audio audio { width: 100%; }

/* ---------- Lightbox + PDF modal ---------- */

.file-lightbox-backdrop,
.file-pdf-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 24px;
}
.file-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.file-lightbox-close,
.file-pdf-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  border: 0;
  border-radius: 9999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, transform 120ms ease;
}
.file-lightbox-close:hover,
.file-pdf-close:hover { background: rgba(15, 23, 42, 0.85); transform: scale(1.05); }
.file-lightbox-close:focus-visible,
.file-pdf-close:focus-visible { outline: 2px solid #818cf8; outline-offset: 2px; }

.file-pdf-inner {
  width: min(960px, 95vw);
  height: min(80vh, 90vh);
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
html.dark .file-pdf-inner { background: #1e293b; }
.file-pdf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}
html.dark .file-pdf-header { background: #0f172a; border-color: #334155; }
.file-pdf-title {
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html.dark .file-pdf-title { color: #e2e8f0; }
.file-pdf-close {
  position: static;
  background: transparent;
  color: #64748b;
}
html.dark .file-pdf-close { color: #94a3b8; }
.file-pdf-frame { flex: 1; border: 0; }

/* ---------- FilesPanel (right sidebar) ---------- */

.files-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
  color: #1e293b;
}
html.dark .files-panel { background: #0f172a; color: #e2e8f0; }
.files-panel-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
}
html.dark .files-panel-header { border-color: #334155; }
.files-panel-title { font-weight: 600; font-size: 14px; }
.files-panel-search {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: inherit;
}
.files-panel-search:focus { outline: 2px solid #6366f1; outline-offset: 0; }
html.dark .files-panel-search {
  background: rgba(30, 41, 59, 0.6);
  border-color: #475569;
}

.files-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.files-panel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
}
html.dark .files-panel-row { border-color: rgba(51, 65, 85, 0.5); }
.files-panel-row:hover { background: #f8fafc; }
html.dark .files-panel-row:hover { background: rgba(30, 41, 59, 0.6); }

.files-panel-row-icon { color: #64748b; font-size: 18px; width: 20px; text-align: center; }
html.dark .files-panel-row-icon { color: #94a3b8; }
.files-panel-row-meta { flex: 1; min-width: 0; }
.files-panel-row-name {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.files-panel-row-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.files-panel-row-pill {
  flex-shrink: 0;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 9999px;
  background: #fef3c7;
  color: #92400e;
}
html.dark .files-panel-row-pill { background: rgba(252, 211, 77, 0.18); color: #fde68a; }
.files-panel-row-sub { font-size: 11px; color: #475569; margin-top: 2px; font-variant-numeric: tabular-nums; }
html.dark .files-panel-row-sub { color: #cbd5e1; }
.files-panel-row-action {
  color: #6366f1;
  padding: 6px 8px;
  border-radius: 6px;
}
.files-panel-row-action:hover { background: rgba(99, 102, 241, 0.1); }
html.dark .files-panel-row-action { color: #c7d2fe; }
html.dark .files-panel-row-action:hover { background: rgba(99, 102, 241, 0.22); }

.files-panel-empty,
.files-panel-loading {
  padding: 32px 16px;
  text-align: center;
  color: #64748b;
}
html.dark .files-panel-empty,
html.dark .files-panel-loading { color: #94a3b8; }
.files-panel-empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
  color: #cbd5e1;
}
html.dark .files-panel-empty-icon { color: #475569; }
.files-panel-empty-title { font-weight: 500; color: #1e293b; }
html.dark .files-panel-empty-title { color: #e2e8f0; }
.files-panel-empty-body { font-size: 13px; margin-top: 4px; }

/* ---------- Quota indicator ---------- */

.quota-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #1e293b;
  font-size: 12px;
}
.quota-indicator.hidden { display: none; }
html.dark .quota-indicator { background: rgba(30, 41, 59, 0.6); color: #e2e8f0; }
.quota-indicator-icon { color: #64748b; }
html.dark .quota-indicator-icon { color: #94a3b8; }
.quota-indicator-track {
  width: 56px;
  height: 4px;
  border-radius: 9999px;
  background: #cbd5e1;
  overflow: hidden;
}
html.dark .quota-indicator-track { background: #475569; }
.quota-indicator-bar {
  height: 100%;
  width: 0%;
  background: #6366f1;
  transition: width 200ms ease;
}
.quota-indicator-warn .quota-indicator-bar { background: #f59e0b; }
.quota-indicator-crit .quota-indicator-bar { background: #ef4444; }
.quota-indicator-label { font-variant-numeric: tabular-nums; }
