/* Spaces, documents and uploads. */

/* Space cards */
.room-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.room-card {
  display: flex;
  flex-direction: column;
  min-height: 176px;
  padding: 16px 17px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: inherit;
  text-decoration: none;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out),
    transform 160ms var(--ease-out);
}

.room-card:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.room-card:active {
  transform: scale(0.997);
}

.room-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.room-card-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-tint);
  color: var(--muted);
  transition: background 160ms var(--ease-out), color 160ms var(--ease-out);
}

.room-card h3 {
  font-size: 14px;
  line-height: 1.35;
}

.room-desc {
  display: -webkit-box;
  min-height: 36px;
  margin: 4px 0 12px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.room-card-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.room-card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted-light);
  font-size: 12px;
}

.room-open {
  color: var(--ink-soft);
  font-weight: 550;
}

.room-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
}

.room-icon.small {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.dot {
  color: var(--muted-light);
}

.spacer {
  flex: 1;
}

/* Loading skeletons keep the card geometry. */
.skeleton-card {
  gap: 0;
  min-height: 212px;
  pointer-events: none;
}

.skeleton-card .sk-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.sk-title {
  display: block;
  width: 62%;
  height: 13px;
  margin-bottom: 10px;
}

.sk-line {
  display: block;
  width: 100%;
  height: 10px;
  margin-bottom: 6px;
}

.sk-line.short {
  width: 74%;
}

.sk-foot {
  display: block;
  width: 42%;
  height: 10px;
  margin-top: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Space list */
.rooms-table .doc-cell {
  min-width: 220px;
}

.table .doc-cell .name,
.table .link-name .panel-title {
  color: var(--ink);
}

.table .sub {
  color: var(--muted);
  font-size: 12px;
}

.doc-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.doc-cell-text {
  min-width: 0;
}

.doc-cell .name {
  font-size: 13px;
  font-weight: 550;
}

.doc-cell .sub {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

/* Space detail */
.room-breadcrumb {
  min-width: 0;
}

.room-breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.room-breadcrumb [aria-current="page"] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rooms-page .page-header > div:first-child,
.room-detail-page .page-header > div:first-child,
.room-detail-page .modal-header > div:first-child {
  min-width: 0;
}

.room-detail-page .page-header h1,
.room-detail-page .modal-header p {
  overflow-wrap: anywhere;
}

.crumb-sep {
  color: var(--muted-light);
}

.room-page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.room-description {
  max-width: 76ch;
  margin: -2px 0 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.room-description.muted {
  color: var(--muted);
}

.documents-card,
.links-card,
.events-card {
  margin-top: 18px;
}

.documents-card .card-header {
  flex-wrap: wrap;
}

/* Upload dialog */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 22px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms var(--ease-out), background 160ms var(--ease-out),
    box-shadow 160ms var(--ease-out);
}

.dropzone.dragging {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.dropzone.busy {
  cursor: default;
  opacity: 0.7;
}

.dropzone:focus-within {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.dropzone-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-bottom: 3px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-xs);
}

.dropzone-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
}

.dropzone-hint {
  color: var(--muted);
  font-size: 12px;
}

.visually-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.upload-selection {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upload-selection-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.upload-file-list {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  list-style: none;
}

.upload-file {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 3px 5px 3px 11px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

.upload-file:last-child {
  border-bottom: 0;
}

.upload-file-name {
  flex: 1;
  min-width: 0;
}

.upload-file-size {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.upload-status {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.upload-status-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 12px;
}

.upload-percent {
  color: var(--brand-ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width 120ms linear;
}

/* Document groups */
.doc-list-head,
.doc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px 72px 62px 96px 76px 40px;
  align-items: center;
  gap: 10px;
  padding-right: 18px;
  padding-left: 18px;
}

.doc-list-head {
  padding-top: 9px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.doc-groups {
  display: flex;
  flex-direction: column;
}

.doc-group + .doc-group {
  border-top: 1px solid var(--line);
}

.doc-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 8px;
}

.doc-group-head h3 {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-row .badge {
  height: 22px;
  font-size: 12px;
}

.doc-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-row {
  position: relative;
  padding-top: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.doc-row:last-child {
  border-bottom: 0;
}

.doc-primary {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.doc-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.doc-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
}

.doc-inline-meta {
  display: none;
}

.doc-cell {
  color: var(--ink-soft);
  font-size: 12.5px;
  min-width: 0;
}

.doc-col-label {
  display: none;
}

.doc-section-cell .badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
}

.doc-size-cell,
.doc-version-cell {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.doc-updated-cell {
  color: var(--muted);
}

.doc-download-cell {
  display: flex;
  align-items: center;
}

.doc-actions-cell {
  display: flex;
  justify-content: flex-end;
}

/* Row action menu */
.doc-menu-wrap {
  position: relative;
  display: inline-flex;
}

.doc-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out),
    border-color 140ms var(--ease-out);
}

.doc-menu-trigger.open {
  border-color: var(--line);
  background: var(--surface-tint);
  color: var(--ink);
}

.doc-menu-trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.doc-menu-trigger:active {
  transform: scale(0.96);
}

.doc-menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  padding: 0;
  border: 0;
  background: transparent;
}

.doc-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 31;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 196px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform-origin: top right;
  animation: doc-menu-in 140ms var(--ease-out);
}

.doc-menu.above {
  top: auto;
  bottom: calc(100% + 6px);
  transform-origin: bottom right;
}

@keyframes doc-menu-in {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(-2px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.doc-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12.5px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.doc-menu-item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.doc-menu-item:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.doc-menu-item.danger-text:hover {
  background: var(--red-soft);
}

.doc-menu-sep {
  height: 1px;
  margin: 4px 3px;
  background: var(--line);
}

/* Row actions shared with links and visitors */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.row-actions.always {
  gap: 6px;
}

.row-actions .icon-btn {
  width: 29px;
  height: 29px;
}

.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

.icon-btn.danger:hover {
  background: var(--red-soft);
  color: var(--red);
}

.danger-text {
  color: var(--red-ink, #b42318);
}

.btn-secondary.danger-text:hover:not(:disabled) {
  border-color: var(--red-line);
  background: var(--red-soft);
  color: var(--red-ink, #b42318);
}

.btn-sm.danger-text {
  color: var(--red-ink, #b42318);
}

/* Share links list */
.link-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.room-link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

.room-link-row:last-child {
  border-bottom: 0;
}

.link-main {
  flex: 1 1 240px;
  min-width: 0;
}

.link-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.link-title-row .panel-title {
  min-width: 0;
  max-width: 100%;
}

.link-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.link-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.link-title-row .badge,
.room-link-row .badge {
  vertical-align: middle;
  font-size: 12px;
}

.links-table .row-actions {
  flex-wrap: nowrap;
}

/* Analytics */
.analytics-body {
  gap: 20px;
}

.mini-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mini-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.mini-stat span {
  color: var(--muted);
  font-size: 12px;
}

.mini-stat strong {
  color: var(--ink);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.analytics-empty {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-soft);
}

.analytics-empty p {
  color: var(--ink-soft);
  font-size: 12.5px;
}

.analytics-body .event-meta,
.analytics-body .event-agent {
  font-size: 12px;
}

.section-title {
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Hover motion only where a pointer can hover. */
@media (hover: hover) and (pointer: fine) {
  .room-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
  }

  .room-card:hover .room-card-arrow {
    background: var(--brand-soft);
    color: var(--brand);
  }

  .dropzone:hover {
    border-color: var(--line-strong);
    background: var(--surface);
  }

  .doc-menu-trigger:hover {
    background: var(--surface-tint);
    color: var(--ink);
  }

  .doc-menu-item:hover {
    background: var(--surface-tint);
    color: var(--ink);
  }

  .doc-row:hover {
    background: var(--surface-tint);
  }
}

@media (max-width: 1050px) {
  .room-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .doc-list-head {
    display: none;
  }

  .doc-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "main actions"
      "meta meta"
      "download download";
    gap: 8px 10px;
    padding: 12px 16px;
  }

  .doc-primary {
    grid-area: main;
  }

  .doc-actions-cell {
    grid-area: actions;
    align-self: start;
  }

  .doc-inline-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
  }

  .doc-section-cell,
  .doc-size-cell,
  .doc-version-cell,
  .doc-updated-cell {
    display: none;
  }

  .doc-download-cell {
    grid-area: download;
    gap: 8px;
  }

  .doc-col-label {
    display: inline;
    color: var(--muted);
    font-size: 12px;
  }

  .doc-menu-trigger {
    width: 40px;
    height: 40px;
  }

  .doc-menu-item {
    min-height: 40px;
  }
}

@media (max-width: 760px) {
  .room-breadcrumb a {
    min-height: 40px;
    padding-right: 6px;
  }

  .doc-download-cell .switch {
    position: relative;
  }

  .doc-download-cell .switch::before {
    content: "";
    position: absolute;
    inset: -9px -1px;
  }

  .rooms-page .page-actions .btn,
  .rooms-page .empty-actions .btn,
  .rooms-page .toolbar .tab,
  .room-detail-page .page-actions .btn,
  .room-detail-page .empty-actions .btn,
  .room-detail-page .modal .btn {
    min-height: 40px;
    height: 40px;
  }

  .rooms-page .modal .icon-btn,
  .room-detail-page .modal .icon-btn {
    width: 40px;
    height: 40px;
  }

  .room-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .room-page-actions {
    width: 100%;
  }

  .room-page-actions .btn {
    flex: 1;
  }

  .documents-card .card-header,
  .links-card .card-header {
    align-items: flex-start;
  }

  .room-link-row {
    align-items: flex-start;
    padding: 13px 14px;
  }

  .room-link-row .row-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 4px;
  }

  .room-link-row .row-actions .icon-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }

  .room-link-row .row-actions .btn {
    height: 40px;
  }

  .room-page-actions .btn {
    height: 40px;
  }

  .upload-file {
    min-height: 44px;
  }

  .upload-file .icon-btn {
    width: 40px;
    height: 40px;
  }

  .mini-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .doc-group-head {
    padding: 12px 16px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .room-card,
  .room-card-arrow,
  .dropzone,
  .doc-menu-trigger,
  .progress-bar {
    transition: none;
  }

  .room-card:active,
  .doc-menu-trigger:active {
    transform: none;
  }

  .doc-menu {
    animation: none;
  }

  .room-card:hover {
    transform: none;
  }
}
