/* Files block browser (Dropbox-style). Everything is scoped under .fx so the app's
   legacy/materialize rules for tables, inputs and checkboxes don't leak in. */

/* Shared design tokens: the Files browser (.fx) and the task view (.tk). */
.fx, .tk, .tk-comments, .tb, .tb-card, .chat {
  --fx-bg: var(--box-bg);
  --fx-text: var(--text-color);
  --fx-muted: #6b7280;
  --fx-line: #eceef2;
  --fx-hover: #f5f7fb;
  --fx-selected: #eaf1ff;
  --fx-accent: #1f60f5;
  --fx-accent-text: #fff;
  --fx-radius: 12px;
  --fx-folder: #5b8def;
  --fx-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --fx-pop: 0 12px 32px rgba(16, 24, 40, .16);
  color: var(--fx-text);
  font-family: "inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: relative;
  margin-top: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fx, :root:not([data-theme="light"]) .tk, :root:not([data-theme="light"]) .tk-comments, :root:not([data-theme="light"]) .tb, :root:not([data-theme="light"]) .tb-card, :root:not([data-theme="light"]) .chat {
    --fx-muted: #9aa0a6;
    --fx-line: #2f3134;
    --fx-hover: #2a2c2f;
    --fx-selected: #1f2d4a;
    --fx-accent: #4f86f7;
    --fx-folder: #8ab4f8;
    --fx-shadow: none;
    --fx-pop: 0 12px 32px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] .fx, :root[data-theme="dark"] .tk, :root[data-theme="dark"] .tk-comments, :root[data-theme="dark"] .tb, :root[data-theme="dark"] .tb-card, :root[data-theme="dark"] .chat {
  --fx-muted: #9aa0a6;
  --fx-line: #2f3134;
  --fx-hover: #2a2c2f;
  --fx-selected: #1f2d4a;
  --fx-accent: #4f86f7;
  --fx-folder: #8ab4f8;
  --fx-shadow: none;
  --fx-pop: 0 12px 32px rgba(0, 0, 0, .5);
}

.fx *, .fx *::before, .fx *::after, .tk *, .tk *::before, .tk *::after { box-sizing: border-box; }
.fx a { color: inherit; text-decoration: none; }
.fx button { font-family: inherit; }

/* ---------- header ---------- */
.fx-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.fx-title { font-size: 26px; font-weight: 600; margin: 0; line-height: 1.2; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-header__actions { display: flex; align-items: center; gap: 8px; }
.fx-header__extra { display: flex; align-items: center; gap: 8px; }
.fx-header__extra .chip { margin: 0; }

.fx-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  font-size: 14px; font-weight: 500; line-height: 1; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--fx-line); background: var(--fx-bg); color: var(--fx-text);
  transition: background .12s, border-color .12s;
}
.fx-btn:hover { background: var(--fx-hover); }
.fx-btn:focus-visible { outline: 2px solid var(--fx-accent); outline-offset: 2px; }
.fx-btn--primary { background: var(--fx-accent); border-color: var(--fx-accent); color: var(--fx-accent-text) !important; }
.fx-btn--primary:hover { background: var(--fx-accent); filter: brightness(1.08); }
.fx-btn--ghost { border-color: transparent; background: transparent; }
.fx-btn--icon { width: 36px; padding: 0; justify-content: center; }
.fx-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.fx-btn[disabled] { opacity: .5; cursor: default; }

/* ---------- dropdown menus (details/summary: works without JS) ---------- */
.fx-menu { position: relative; display: inline-block; }
.fx-menu > summary { list-style: none; cursor: pointer; }
.fx-menu > summary::-webkit-details-marker { display: none; }
.fx-menu__list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  min-width: 190px; padding: 6px; border-radius: 10px;
  background: var(--fx-bg); border: 1px solid var(--fx-line); box-shadow: var(--fx-pop);
}
.fx-menu__list--left { left: 0; right: auto; }
.fx-menu__item, .fx-menu__list form button, .fx-menu__list input[type=submit] {
  display: flex !important; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px !important; border-radius: 6px; border: 0; background: transparent;
  font-size: 14px; color: var(--fx-text) !important; text-align: left; cursor: pointer; height: auto; margin: 0;
}
.fx-menu__item:hover, .fx-menu__list form button:hover, .fx-menu__list input[type=submit]:hover { background: var(--fx-hover); }
.fx-menu__item svg { width: 18px; height: 18px; color: var(--fx-muted); flex-shrink: 0; }
.fx-menu__item--danger, .fx-menu__list .fx-menu__item--danger { color: #d93025 !important; }
.fx-menu__item--danger svg { color: #d93025; }
.fx-menu__sep { height: 1px; background: var(--fx-line); margin: 6px 4px; }
.fx-menu__list form { margin: 0; }

/* ---------- toolbar ---------- */
.fx-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-height: 40px; }
.fx-search { position: relative; flex: 1; max-width: 320px; }
.fx-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--fx-muted); pointer-events: none; }
.fx .fx-search input[type=search] {
  width: 100%; height: 36px !important; margin: 0 !important; padding: 0 12px 0 32px !important;
  border: 1px solid var(--fx-line) !important; border-radius: 8px; background: var(--fx-bg) !important;
  color: var(--fx-text); font-size: 14px; box-shadow: none !important;
}
.fx .fx-search input[type=search]:focus { border-color: var(--fx-accent) !important; outline: none; }
.fx-toolbar__spacer { flex: 1; }
.fx-segment { display: inline-flex; border: 1px solid var(--fx-line); border-radius: 8px; overflow: hidden; }
.fx-segment button { width: 36px; height: 34px; border: 0; background: transparent; color: var(--fx-muted); display: grid; place-items: center; cursor: pointer; }
.fx-segment button svg { width: 18px; height: 18px; }
.fx-segment button[aria-pressed="true"] { background: var(--fx-hover); color: var(--fx-text); }

/* Selection bar replaces the toolbar while items are selected */
.fx-selbar {
  display: none; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: 40px; padding: 4px 8px 4px 14px; margin-bottom: 8px; border-radius: 10px;
  background: var(--fx-selected); position: sticky; top: 58px; z-index: 20;
}
.fx-selbar__count { font-size: 14px; font-weight: 600; margin-right: 8px; }
.fx-selbar .fx-btn { height: 32px; background: transparent; border-color: transparent; }
.fx-selbar .fx-btn:hover { background: rgba(127, 127, 127, .14); }
.fx-status { font-size: 13px; color: var(--fx-muted); margin: 0 0 8px; min-height: 0; }
.fx-status:empty { display: none; }

/* ---------- list ---------- */
.fx-panel { background: var(--fx-bg); border: 1px solid var(--fx-line); border-radius: var(--fx-radius); box-shadow: var(--fx-shadow); overflow: visible; }

.fx-cols {
  display: grid; grid-template-columns: 40px 44px minmax(0, 1fr) 130px 100px 150px 44px; align-items: center;
}
.fx-head { height: 40px; padding: 0 8px; border-bottom: 1px solid var(--fx-line); font-size: 12px; font-weight: 600; color: var(--fx-muted); text-transform: uppercase; letter-spacing: .03em; }
.fx-head button { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.fx-head button:hover { color: var(--fx-text); }
.fx-head__name { grid-column: 2 / 4; padding-left: 4px; }
.fx-arrow { font-size: 10px; }

.fx-entry:not(:has(.fx-row)) { display: none; }
.fx-row {
  position: relative; min-height: 56px; padding: 0 8px;
  border-bottom: 1px solid var(--fx-line); font-size: 14px;
  transition: background .08s;
}
.fx-list > .fx-entry:last-child .fx-row { border-bottom: 0; }
.fx-row:hover { background: var(--fx-hover); }
.fx-row.is-selected { background: var(--fx-selected); }

.fx-check { display: grid; place-items: center; height: 100%; position: relative; z-index: 2; cursor: pointer; }
.fx .fx-check input[type=checkbox] {
  position: static !important; opacity: 1 !important; pointer-events: auto !important;
  width: 18px; height: 18px; margin: 0; cursor: pointer; accent-color: var(--fx-accent);
}
@media (hover: hover) {
  .fx-row .fx-check input[type=checkbox] { opacity: 0 !important; }
  .fx-row:hover .fx-check input[type=checkbox],
  .fx-row .fx-check input[type=checkbox]:checked,
  .fx.has-selection .fx-row .fx-check input[type=checkbox],
  .fx-row .fx-check input[type=checkbox]:focus-visible { opacity: 1 !important; }
}

.fx-thumb { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; overflow: hidden; flex-shrink: 0; }
.fx-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fx-thumb--folder svg { width: 34px; height: 34px; color: var(--fx-folder); }
.fx-thumb--doc svg { width: 30px; height: 30px; color: var(--fx-accent); }
.fx-badge {
  width: 30px; height: 36px; border-radius: 4px; position: relative;
  display: grid; place-items: end center; padding-bottom: 5px;
  background: var(--fx-badge, #7c8594); color: #fff; font-size: 8px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  clip-path: polygon(0 0, 70% 0, 100% 22%, 100% 100%, 0 100%);
}
.fx-badge::after { content: ""; position: absolute; top: 0; right: 0; width: 30%; height: 22%; background: rgba(255, 255, 255, .35); clip-path: polygon(0 0, 0 100%, 100% 100%); }

.fx-name { min-width: 0; padding-left: 4px; display: flex; flex-direction: column; justify-content: center; }
.fx-name__link { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Stretched link: the whole row is clickable, while checkbox and menu stay on top. */
.fx-name__link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.fx-name__sub { display: none; font-size: 12px; color: var(--fx-muted); }
.fx-cell { color: var(--fx-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 8px; }
.fx-more { position: relative; z-index: 3; display: flex; justify-content: center; }
.fx-more > .fx-menu > summary { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--fx-muted); }
.fx-more > .fx-menu > summary:hover, .fx-more > .fx-menu[open] > summary { background: rgba(127, 127, 127, .16); color: var(--fx-text); }
.fx-more svg { width: 18px; height: 18px; }
@media (hover: hover) {
  .fx-row .fx-more > .fx-menu:not([open]) > summary { opacity: 0; }
  .fx-row:hover .fx-more > .fx-menu > summary, .fx-row .fx-more > .fx-menu > summary:focus-visible { opacity: 1; }
}

/* Inline rename form (file rows) */
.fx-rename { display: flex; gap: 6px; align-items: center; position: relative; z-index: 4; }
.fx .fx-rename input[type=text] {
  height: 32px !important; margin: 0 !important; padding: 0 8px !important; font-size: 14px;
  border: 1px solid var(--fx-accent) !important; border-radius: 6px; background: var(--fx-bg) !important; box-shadow: none !important; flex: 1; min-width: 0;
}
.fx-rename .fx-btn { height: 32px; }
.fx-draft input[type=text] { position: relative; z-index: 4; }

/* ---------- grid view ---------- */
.fx--grid .fx-head { display: none; }
.fx--grid .fx-panel { background: transparent; border: 0; box-shadow: none; }
.fx--grid .fx-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.fx--grid .fx-row {
  display: flex; flex-direction: column; align-items: stretch; padding: 0; min-height: 0;
  border: 1px solid var(--fx-line) !important; border-radius: var(--fx-radius); background: var(--fx-bg); overflow: hidden;
}
.fx--grid .fx-row:hover { background: var(--fx-bg); box-shadow: var(--fx-pop); }
.fx--grid .fx-row.is-selected { outline: 2px solid var(--fx-accent); background: var(--fx-selected); }
.fx--grid .fx-check { position: absolute; top: 8px; left: 8px; height: auto; }
.fx--grid .fx-thumb { width: 100%; height: 132px; border-radius: 0; background: var(--fx-hover); order: -1; }
.fx--grid .fx-thumb--folder svg { width: 72px; height: 72px; }
.fx--grid .fx-thumb--doc svg { width: 56px; height: 56px; }
.fx--grid .fx-badge { width: 52px; height: 64px; font-size: 12px; padding-bottom: 8px; }
.fx--grid .fx-name { padding: 10px 40px 10px 12px; }
.fx--grid .fx-name__sub { display: block; }
.fx--grid .fx-cell { display: none; }
.fx--grid .fx-more { position: absolute; right: 6px; bottom: 10px; }
.fx--grid .fx-draft .fx-row { padding: 10px; }

/* ---------- empty + drop ---------- */
.fx-empty { text-align: center; padding: 56px 16px; color: var(--fx-muted); }
.fx-empty svg { width: 64px; height: 64px; color: var(--fx-folder); margin-bottom: 12px; }
.fx-empty h3 { font-size: 18px; margin: 0 0 6px; color: var(--fx-text); font-weight: 600; }
.fx-empty p { margin: 0 0 18px; font-size: 14px; }
.fx-empty .fx-header__actions { justify-content: center; }

.fx-drop {
  display: none; position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  background: color-mix(in srgb, var(--fx-accent) 10%, transparent);
  border: 3px dashed var(--fx-accent); border-radius: 16px; margin: 8px;
  align-items: center; justify-content: center;
}
.fx-drop.is-active { display: flex; }
.fx-drop__msg { background: var(--fx-accent); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: 15px; box-shadow: var(--fx-pop); }

/* Upload progress panel (bottom-right, like Dropbox/Drive) */
.fx-uploads {
  position: fixed; right: 20px; bottom: 20px; z-index: 9999; width: min(360px, calc(100vw - 32px));
  background: var(--fx-bg); border: 1px solid var(--fx-line); border-radius: 12px; box-shadow: var(--fx-pop); overflow: hidden;
}
.fx-uploads[hidden] { display: none; }
.fx-uploads__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--fx-line); }
.fx-uploads__list { max-height: 240px; overflow: auto; padding: 6px 0; }
.fx-upload { padding: 8px 14px; font-size: 13px; }
.fx-upload__row { display: flex; justify-content: space-between; gap: 8px; }
.fx-upload__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-upload__state { color: var(--fx-muted); flex-shrink: 0; }
.fx-upload__bar { height: 4px; border-radius: 2px; background: var(--fx-line); margin-top: 6px; overflow: hidden; }
.fx-upload__bar span { display: block; height: 100%; width: 0; background: var(--fx-accent); transition: width .15s; }
.fx-upload.is-error .fx-upload__state { color: #d93025; }
.fx-upload.is-error .fx-upload__bar span { background: #d93025; }
.fx-upload.is-done .fx-upload__bar span { background: #1f9d55; }

/* ---------- move dialog ---------- */
.fx-modal { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(0, 0, 0, .45); align-items: center; justify-content: center; }
.fx-modal__panel { width: min(480px, 92vw); max-height: 80vh; overflow: auto; background: var(--fx-bg); border-radius: 14px; box-shadow: var(--fx-pop); padding: 18px; }
.fx-modal__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 16px; font-weight: 600; }
.fx-modal__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .fx-cols { grid-template-columns: 40px 44px minmax(0, 1fr) 110px 44px; }
  .fx-cell--kind, .fx-cell--size { display: none; }
  .fx-head .fx-cell--kind, .fx-head .fx-cell--size { display: none; }
}
@media (max-width: 600px) {
  .fx-title { font-size: 22px; }
  .fx-cols { grid-template-columns: 36px 44px minmax(0, 1fr) 44px; }
  .fx-cell { display: none !important; }
  .fx-name__sub { display: block; }
  .fx-header__actions .fx-btn__label { display: none; }
  .fx-search { max-width: none; }
  .fx--grid .fx-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .fx--grid .fx-thumb { height: 104px; }
}

.fx [hidden] { display: none !important; }
.fx-name__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-header__extra .chip { border: 0 !important; padding: 0 !important; font-size: 13px; }
.fx-header__extra .chip a { color: var(--fx-muted); }
.fx-header__extra .chip a:hover { color: var(--fx-accent); }
@media (max-width: 600px) {
  .fx-head .fx-cell--date { display: none; }
  .fx-toolbar__spacer { display: none; }
}
.fx-search { min-width: 0; }
.fx-segment { flex-shrink: 0; }
