/* Styles for the in-shell (chat SPA) full "My Files" table. Ported from the
   standalone /files page and scoped under `.files-panel` so the generic class
   names (.list-row, .list-head, .bulk-bar, .project-chip-btn, …) can't collide
   with the chat shell. The zoom modal is appended to <body>, so its styles stay
   global. */

.files-panel .search-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}
.files-panel .search-field { display: grid; gap: 5px; }
.files-panel .search-field label {
  font-size: 12px; color: var(--muted); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.files-panel .search-field input {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 10px; font: inherit; background: #fff;
}

/* Bulk-action bar */
.files-panel .bulk-bar {
  display: none; align-items: center; gap: 12px;
  margin-bottom: 12px; padding: 10px 14px;
  background: #fff7ed; border: 1px solid #fdba74;
  border-radius: 10px; position: relative;
}
.files-panel .bulk-bar.show { display: flex; }
.files-panel .bulk-bar[hidden] { display: none; }
.files-panel .bulk-bar .bulk-count { font-size: 13px; font-weight: 600; color: #9a3412; }
.files-panel .bulk-bar .bulk-spacer { flex: 1; }
.files-panel .bulk-bar .btn.danger {
  background: #fff; color: #b91c1c; border: 1px solid #fecaca;
  padding: 6px 12px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.files-panel .bulk-bar .btn.danger:hover { background: #fef2f2; border-color: #fca5a5; }
.files-panel .bulk-bar .btn.ghost {
  background: transparent; color: #475569; border: 1px solid transparent;
  padding: 6px 10px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.files-panel .bulk-bar .btn.ghost:hover { color: #0f172a; background: #fff; border-color: var(--border); }
.files-panel .bulk-bar #filesBulkProjectHost { position: relative; }

/* Project assignment chip + inline picker (row + dropzone reuse) */
.files-panel .project-chip-btn {
  border: 1px solid #bae6fd; background: #e0f2fe; color: #0369a1;
  border-radius: 999px; padding: 5px 10px; font: inherit; font-weight: 700;
  cursor: pointer; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.files-panel .project-chip-btn.empty { border-color: var(--border); background: #fff; color: var(--muted); font-weight: 600; }
.files-panel .project-chip-btn:hover { border-color: #7dd3fc; color: #075985; }
.files-panel .project-picker-inline {
  position: absolute; z-index: 1000; top: calc(100% + 6px); left: 0;
  width: min(280px, 80vw); padding: 8px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
}
.files-panel .project-picker-inline input {
  width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 9px; font: inherit; margin-bottom: 6px;
}
.files-panel .project-picker-options { display: grid; gap: 4px; max-height: 220px; overflow: auto; }
.files-panel .project-picker-options button {
  width: 100%; border: 0; border-radius: 7px; background: transparent;
  padding: 7px 8px; text-align: left; cursor: pointer; font: inherit; font-size: 13px;
}
.files-panel .project-picker-options button:hover { background: #f1f5f9; }
.files-panel .project-picker-options button.active { background: #e0f2fe; color: #0369a1; font-weight: 700; }

/* List (grid table) */
.files-panel .files-list {
  display: grid;
  grid-template-columns: 36px 56px minmax(200px, 1.8fr) minmax(150px, 1.2fr) minmax(140px, 1fr) 130px 200px;
  column-gap: 16px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; overflow: visible;
}
.files-panel .files-list > .empty { grid-column: 1 / -1; padding: 24px; color: var(--muted); text-align: left; margin: 0; }
.files-panel .list-cell-project { position: relative; overflow: visible; }
.files-panel .list-cell-check { justify-content: center; padding-left: 4px !important; padding-right: 4px !important; }
.files-panel .list-cell-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: #f97316; }
.files-panel .list-row.selected > div { background: #fff7ed; }
.files-panel .list-row.selected:hover > div { background: #ffedd5; }
.files-panel .list-head, .files-panel .list-row { display: contents; }
.files-panel .list-head > div {
  padding: 10px 8px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  background: #fff; border-bottom: 1px solid var(--border);
}
.files-panel .list-head .sort-btn {
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.files-panel .list-head .sort-btn:hover { color: var(--fg); }
.files-panel .list-head .sort-btn .sort-arrow { opacity: .35; font-size: 10px; transition: opacity .15s; }
.files-panel .list-head .sort-btn.active { color: var(--fg); }
.files-panel .list-head .sort-btn.active .sort-arrow { opacity: 1; }
.files-panel .list-row > div {
  padding: 11px 8px; border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; min-width: 0; font-size: 15px;
}
.files-panel .list-row:last-child > div { border-bottom: none; }
.files-panel .list-row:hover > div { background: #f8fafc; }

.files-panel .list-icon {
  width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: #eff6ff; color: #2563eb; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.files-panel .list-icon.pdf { background: #fef2f2; color: #b91c1c; }
.files-panel .list-icon.img { background: #ecfeff; color: #0891b2; }
.files-panel .list-icon.txt { background: #f1f5f9; color: #475569; }
.files-panel .list-icon.vid { background: #f5f3ff; color: #7c3aed; }

.files-panel .list-cell-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.files-panel .list-expand {
  flex-shrink: 0; width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; color: var(--muted); padding: 0;
  transition: background .12s, color .12s, border-color .12s;
}
.files-panel .list-expand svg { width: 16px; height: 16px; display: block; }
.files-panel .list-expand:hover { color: #2563eb; border-color: #bfdbfe; background: #eff6ff; }
.files-panel .list-row.expanded .list-expand { color: #2563eb; border-color: #bfdbfe; background: #eff6ff; }

.files-panel .list-name {
  cursor: pointer; background: none; border: none; padding: 0;
  text-align: left; font-size: 15px; color: var(--fg);
  font-weight: 500; font-family: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1;
}
.files-panel .list-name:hover { color: #2563eb; }
.files-panel .list-cell-ellipsis {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: block; width: 100%; color: var(--muted); font-size: 14px;
}
.files-panel .list-actions { gap: 6px; justify-content: flex-end; }
.files-panel .list-actions .view-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--fg); font-size: 12px; font-weight: 500; cursor: pointer; text-decoration: none;
}
.files-panel .list-actions .view-btn:hover { border-color: #cbd5e1; background: #f8fafc; color: #2563eb; }
.files-panel .list-actions .view-btn svg { width: 12px; height: 12px; }
.files-panel .list-actions .icon-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; padding: 4px 8px; color: var(--muted); font-size: 12px;
}
.files-panel .list-actions .icon-btn:hover { color: #dc2626; border-color: #fecaca; background: #fef2f2; }

.files-panel .list-row-details {
  grid-column: 1 / -1;
  padding: 14px 16px 16px 64px;
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  flex-direction: column; gap: 12px; align-items: stretch !important;
}
.files-panel .list-row-details[hidden] { display: none !important; }
.files-panel .list-row.expanded > div:not(.list-row-details):not(.list-row-idx) { background: #f8fafc; }
.files-panel .list-row-idx {
  grid-column: 1 / -1;
  padding: 14px 16px 16px 64px;
  background: #fefce8; border-top: 1px dashed #fde68a; border-bottom: 1px solid #e2e8f0;
  flex-direction: column; gap: 12px; align-items: stretch !important;
}
.files-panel .list-row-idx[hidden] { display: none !important; }
.files-panel .row-detail-section h4 {
  margin: 0 0 4px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.files-panel .row-detail-section p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--fg); white-space: pre-wrap; }
.files-panel .row-detail-status { margin: 0; font-size: 13px; color: var(--muted); font-style: italic; }
.files-panel .row-detail-topics { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.files-panel .tag-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; color: #475569; font-weight: 500; }
.files-panel .row-detail-kv {
  margin: 0; display: grid;
  grid-template-columns: minmax(80px, max-content) 1fr;
  column-gap: 12px; row-gap: 4px; font-size: 13px; line-height: 1.5;
}
.files-panel .row-detail-kv dt { color: var(--muted); font-weight: 600; }
.files-panel .row-detail-kv dd { margin: 0; color: var(--fg); word-break: break-word; }

.files-panel .row-visual-list { display: flex; flex-direction: column; gap: 10px; }
.files-panel .row-visual-item {
  display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; align-items: start;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px;
}
.files-panel .row-visual-thumb {
  appearance: none; width: 160px; height: 90px; padding: 0; margin: 0;
  border-radius: 8px; overflow: hidden; border: 1px solid #dbeafe; background: #f8fafc;
  display: flex; align-items: center; justify-content: center; cursor: zoom-in;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.files-panel .row-visual-thumb:hover { transform: translateY(-1px); border-color: #93c5fd; box-shadow: 0 6px 18px rgba(37, 99, 235, .16); }
.files-panel .row-visual-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.files-panel .row-visual-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.files-panel .row-visual-title { font-size: 13px; font-weight: 700; color: var(--fg); }
.files-panel .row-visual-desc { margin: 0; font-size: 13px; line-height: 1.45; color: var(--fg); white-space: pre-wrap; }
.files-panel .row-visual-meta { margin: 0; font-size: 12px; line-height: 1.45; color: var(--muted); white-space: pre-wrap; max-height: 86px; overflow: auto; }

/* Inline notes editor */
.files-panel .notes-editor { display: flex; flex-direction: column; gap: 6px; }
.files-panel .notes-editor textarea {
  width: 100%; min-height: 70px; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: 13px; resize: vertical; background: #fff;
}
.files-panel .notes-editor textarea:focus { outline: 2px solid #bfdbfe; border-color: #2563eb; }
.files-panel .notes-row { display: flex; justify-content: flex-end; gap: 6px; align-items: center; }
.files-panel .notes-status { font-size: 12px; color: var(--muted); margin-right: auto; }
.files-panel .notes-row .btn { font-size: 12px; padding: 4px 12px; }
.files-panel .notes-row .btn.primary { background: #2563eb; color: #fff; border: 1px solid #2563eb; border-radius: 8px; cursor: pointer; }
.files-panel .notes-row .btn.primary:disabled { opacity: .6; cursor: default; }

/* Zoom modal (appended to <body> — global) */
body.modal-open { overflow: hidden; }
.visual-modal { position: fixed; inset: 0; z-index: 1600; display: grid; place-items: center; padding: 20px; }
.visual-modal[hidden] { display: none !important; }
.visual-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .72); backdrop-filter: blur(2px); }
.visual-modal-card {
  position: relative; width: min(1080px, calc(100vw - 40px)); max-height: calc(100vh - 40px);
  border-radius: 14px; border: 1px solid #cbd5e1; background: #fff;
  box-shadow: 0 32px 80px rgba(2, 6, 23, .45); padding: 14px;
  display: flex; flex-direction: column; gap: 10px; overflow: hidden;
}
.visual-modal-close {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px;
  border-radius: 999px; border: 1px solid var(--border); background: #fff; color: #334155;
  cursor: pointer; font-size: 17px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.visual-modal-close:hover { color: #0f172a; background: #f8fafc; }
.visual-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-right: 44px; }
.visual-modal-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--fg); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visual-modal-image-wrap {
  border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc;
  display: flex; justify-content: center; align-items: center; overflow: auto;
  min-height: 220px; max-height: calc(100vh - 210px);
}
.visual-modal-image { max-width: 100%; height: auto; display: block; }
.visual-modal-meta { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; white-space: pre-wrap; overflow: auto; max-height: 90px; }
.visual-modal .btn.ghost.small { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--fg); }

@media (max-width: 820px) {
  .files-panel .files-list { grid-template-columns: 56px minmax(160px, 2fr) minmax(130px, 1fr) 160px; }
  .files-panel .list-col-summary, .files-panel .list-cell-summary,
  .files-panel .list-col-updated, .files-panel .list-cell-updated { display: none; }
  .files-panel .list-cell-check { display: none; }
}
@media (max-width: 560px) {
  .files-panel .files-list { grid-template-columns: 56px 1fr 140px; }
  .files-panel .list-col-project, .files-panel .list-cell-project { display: none; }
  .files-panel .row-visual-item { grid-template-columns: 1fr; }
  .files-panel .row-visual-thumb { width: 100%; height: 120px; }
  .files-panel .search-row { grid-template-columns: 1fr; }
  .visual-modal { padding: 10px; }
  .visual-modal-card { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .visual-modal-title { font-size: 14px; }
  .visual-modal-image-wrap { max-height: calc(100vh - 240px); }
}
