/*
 * 云空间文件（2026-11-09）。与项目页同一套浅色纸面：白卡、细边框、克制的操作菜单。
 * 页面同时出现在对话页的 `.chat-files-view` 与组织主区域 `.org-main` 里，
 * 组织主区域有一条全局把按钮刷成 #242424 的规则，这里按页面 id 局部覆盖。
 */

.space-files-page { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 0 40px; position: relative; }
.space-files-page[data-drag="true"]::after {
  content: "松开上传到当前空间";
  position: absolute; inset: 0; z-index: 30;
  display: grid; place-items: center;
  border: 2px dashed #9db3c8; border-radius: 16px;
  background: rgba(244, 248, 252, .82);
  color: #47617b; font-size: 13px; font-weight: 560;
  pointer-events: none;
}

.space-files-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin: 0 0 18px;
}
.space-files-head-copy { min-width: 0; }
.space-files-head h1 {
  margin: 0; font-size: 25px; font-weight: 640; letter-spacing: -.03em; color: #1f2937;
}
.space-files-head .org-sub { margin: 6px 0 0; max-width: 560px; }
.space-files-head-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.space-files-usage { width: 196px; }
.space-files-usage-copy {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 5px; color: #8b95a0; font-size: 10.5px;
}
.space-files-usage-copy strong { color: #4b5563; font-size: 11px; font-weight: 560; font-variant-numeric: tabular-nums; }
.space-files-usage-bar {
  height: 5px; border-radius: 999px; background: #eceef1; overflow: hidden;
}
.space-files-usage-fill {
  display: block; height: 100%; width: 0;
  border-radius: inherit; background: #4b6b8a;
  transition: width 200ms ease;
}

.space-files-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.space-files-search-wrap { position: relative; flex: 1 1 240px; min-width: 0; }
.space-files-search-wrap > .ui-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: #9aa3ad; pointer-events: none;
}
.space-files-search {
  width: 100%; height: 36px; padding: 0 12px 0 34px;
  border: 1px solid #e4e7ea; border-radius: 10px; background: #fff;
  color: #2f3944; font: inherit; font-size: 12.5px; box-shadow: none;
}
.space-files-search:focus-visible { outline: none; border-color: #c3ced9; box-shadow: 0 0 0 3px rgba(78, 116, 160, .09); }
.space-files-project {
  flex: 0 1 190px; height: 36px; padding: 0 10px;
  border: 1px solid #e4e7ea; border-radius: 10px; background: #fff;
  color: #48525d; font: inherit; font-size: 12px; box-shadow: none;
}

.space-files-tabs { display: flex; gap: 2px; margin: 0 0 14px; flex-wrap: wrap; }
.space-files-tab {
  min-height: 30px; padding: 5px 11px;
  border: 0; border-radius: 8px; background: transparent;
  color: #6b7480; font: inherit; font-size: 11.5px; font-weight: 540;
  box-shadow: none; cursor: pointer;
}
.space-files-tab:hover:not(:disabled) { background: #f2f4f5; }
.space-files-tab[aria-selected="true"] { background: #eceef1; color: #2a333d; font-weight: 580; }

.space-files-list { display: flex; flex-direction: column; gap: 8px; }
.space-files-row {
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center; gap: 12px;
  padding: 12px 13px;
  border: 1px solid #eceef1; border-radius: 13px; background: #fff;
  transition: border-color 150ms, box-shadow 150ms;
}
.space-files-row:hover { border-color: #e0e4e8; box-shadow: 0 3px 14px rgba(24, 42, 59, .04); }
.space-files-row[data-status="trashed"] { background: #fbfbfc; }
.space-files-icon {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 11px; background: #f3f4f6; color: #6b7480;
}
.space-files-icon .ui-icon { width: 18px; height: 18px; }
.space-files-row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.space-files-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #222c36; font-size: 13px; font-weight: 570;
}
.space-files-meta { color: #8b95a0; font-size: 10.5px; }
.space-files-origin { color: #a0a7b0; font-size: 10px; }

.space-files-row-actions { display: flex; align-items: center; gap: 2px; }
.space-files-download {
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: 8px; color: #6b7480; text-decoration: none;
}
.space-files-download:hover { background: #f2f4f5; color: #2f3944; }
.space-files-download .ui-icon { width: 16px; height: 16px; }

.space-files-more { position: relative; }
.space-files-more > summary {
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: 8px; color: #8b95a0; cursor: pointer; list-style: none;
}
.space-files-more > summary::-webkit-details-marker { display: none; }
.space-files-more > summary:hover { background: #f2f4f5; color: #2f3944; }
.space-files-more > summary .ui-icon { width: 16px; height: 16px; }
.space-files-more[open] > summary { background: #eceef1; color: #2f3944; }
.space-files-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 40;
  width: 152px; padding: 4px;
  border: 1px solid #e3e7ea; border-radius: 11px; background: #fff;
  box-shadow: 0 10px 30px rgba(20, 36, 48, .12), 0 2px 5px rgba(20, 36, 48, .04);
}
.space-files-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 31px; padding: 6px 9px;
  border: 0; border-radius: 7px; background: transparent;
  color: #37424d; text-align: left; font: inherit; font-size: 11.5px;
  box-shadow: none; cursor: pointer;
}
.space-files-menu button:hover:not(:disabled) { background: #f2f4f5; }
.space-files-menu button.is-danger { color: #a45151; }
.space-files-menu button.is-danger:hover:not(:disabled) { background: #fdf5f5; }
.space-files-menu .ui-icon { width: 13px; height: 13px; color: #8b95a0; }
.space-files-menu button.is-danger .ui-icon { color: #b06a6a; }

.space-files-empty {
  display: flex; flex-direction: column; gap: 4px;
  padding: 34px 20px; border: 1px dashed #e4e8eb; border-radius: 14px;
  background: #fafbfc; text-align: center;
}
.space-files-empty strong { font-size: 13px; font-weight: 580; color: #5c6672; }
.space-files-empty span { font-size: 11.5px; line-height: 1.6; color: #98a1ab; }

.space-files-status {
  margin: 12px 0 0; font-size: 11.5px; line-height: 1.6; color: #6b7480;
}
.space-files-status[data-tone="bad"] { color: #a45151; }
.space-files-status[hidden] { display: none; }

.space-files-progress { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.space-files-progress[hidden] { display: none; }
.space-files-progress-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 130px 52px;
  align-items: center; gap: 10px; padding: 8px 11px;
  border: 1px solid #eef0f2; border-radius: 10px; background: #fafbfc;
}
.space-files-progress-row[data-state="bad"] { border-color: #efd6d6; background: #fff8f8; }
.space-files-progress-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #4b5563; font-size: 11.5px; }
.space-files-progress-bar { height: 4px; border-radius: 999px; background: #e6e9ec; overflow: hidden; }
.space-files-progress-fill { display: block; height: 100%; width: 0; background: #4b6b8a; transition: width 120ms linear; }
.space-files-progress-text { color: #8b95a0; font-size: 10.5px; text-align: right; font-variant-numeric: tabular-nums; }
.space-files-progress-row[data-state="bad"] .space-files-progress-text { color: #a45151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.space-files-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 20px 20px 16px;
  border: 1px solid #e3e7ea; border-radius: 16px; background: #fff;
  box-shadow: 0 24px 60px rgba(20, 36, 48, .18);
}
.space-files-dialog::backdrop { background: rgba(20, 28, 36, .28); backdrop-filter: blur(2px); }
.space-files-dialog h2 { margin: 0 0 8px; font-size: 15px; font-weight: 620; color: #232a31; }
.space-files-dialog-hint { margin: 0 0 12px; font-size: 11.5px; line-height: 1.65; color: #7b8490; }
.space-files-dialog .space-files-project { width: 100%; margin-bottom: 14px; }
.space-files-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.space-files-refs { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; margin: 0 0 12px; }
.space-files-ref {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid #eef0f2; border-radius: 9px; background: #fafbfc;
}
.space-files-ref-kind { color: #8b95a0; font-size: 10.5px; font-weight: 560; }
.space-files-ref-meta { color: #4b5563; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 组织主区域把按钮刷成 #242424；文件页自己的灰/白层级按 id 提优先级。 */
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] button.org-secondary,
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] button.org-ghost {
  background: #fff; color: #37424d; border: 1px solid #e2e6ea;
}
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] button.org-ghost { border-color: transparent; background: transparent; }
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] button.space-files-tab {
  background: transparent; color: #6b7480; border: 0;
}
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] button.space-files-tab[aria-selected="true"] {
  background: #eceef1; color: #2a333d;
}
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] button.space-files-tab:hover:not(:disabled) { background: #f2f4f5; }
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] .space-files-menu button {
  background: transparent; color: #37424d; border: 0;
}
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] .space-files-menu button:hover:not(:disabled) { background: #f2f4f5; }
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] .space-files-menu button.is-danger { color: #a45151; }
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] .space-files-menu button.is-danger:hover:not(:disabled) { background: #fdf5f5; }
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] input.space-files-search,
body.is-chat .org-main section.space-files-page.space-files-page[data-page="space-files"] select.space-files-project {
  color: #2f3944; border-color: #e4e7ea; background: #fff;
}

@media (max-width: 640px) {
  .space-files-head { align-items: flex-start; }
  .space-files-head-actions { width: 100%; justify-content: space-between; }
  .space-files-usage { width: 100%; max-width: 220px; }
  .space-files-project { flex-basis: 100%; }
  .space-files-row { grid-template-columns: 34px minmax(0, 1fr) auto; padding: 10px; }
  .space-files-progress-row { grid-template-columns: minmax(0, 1fr) 80px 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .space-files-usage-fill, .space-files-progress-fill, .space-files-row { transition: none; }
}

/* ---------------------------------------------------------------- 输入区附件 */

.chat-attach {
  display: grid; place-items: center; flex: none;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 9px; background: transparent;
  color: #6b7480; box-shadow: none; cursor: pointer;
}
.chat-attach:hover:not(:disabled) { background: #f2f4f5; color: #37424d; }
.chat-attach .ui-icon { width: 16px; height: 16px; }
body.is-chat button.chat-attach:hover:not(:disabled) { background: #f2f4f5; box-shadow: none; }

.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.chat-attachments[hidden] { display: none; }
.chat-attachment {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  padding: 3px 3px 3px 8px;
  border: 1px solid #e6e9ec; border-radius: 999px; background: #fafbfc;
  color: #4b5563; font-size: 11px;
}
.chat-attachment[data-state="done"] { border-color: #d8e6dc; background: #f7fbf8; }
.chat-attachment .ui-icon { width: 12px; height: 12px; flex: none; color: #8b95a0; }
.chat-attachment-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attachment-size { flex: none; color: #9aa3ad; font-size: 10px; }
.chat-attachment-remove {
  display: grid; place-items: center; flex: none;
  width: 18px; height: 18px; padding: 0;
  border: 0; border-radius: 50%; background: transparent;
  color: #9aa3ad; box-shadow: none; cursor: pointer;
}
.chat-attachment-remove:hover:not(:disabled) { background: #eceef1; color: #4b5563; }
.chat-attachment-remove .ui-icon { width: 11px; height: 11px; }
body.is-chat button.chat-attachment-remove:hover:not(:disabled) { background: #eceef1; box-shadow: none; }

.chat-composer[data-drop="true"] .chat-box {
  border-color: #9db3c8;
  box-shadow: 0 0 0 3px rgba(120, 150, 180, .12);
}
