/* ============================================================
   ELIHive — Data Room Browser
   ============================================================ */

.wrap--browser { padding-top: 18px; }

.header-actions { display: flex; gap: 10px; align-items: center; }

/* Toolbar */
.dr-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--cream-2), #fff);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: 0 10px 26px -22px rgba(28,22,17,0.5);
}
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.crumb {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  color: var(--warmgray-2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.crumb:hover { color: var(--charcoal); background: rgba(232,168,32,0.10); }
.crumb.is-current { color: var(--charcoal); font-weight: 600; cursor: default; }
.crumb.is-current:hover { background: none; }
.crumb-sep { color: var(--warmgray); user-select: none; }

.dr-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn--sm { padding: 8px 14px; font-size: 0.82rem; }
.ghost-link.btn--sm { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.ghost-link.btn--sm[disabled] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
#back-btn svg { transition: transform .15s ease; }
#back-btn:not([disabled]):hover svg { transform: translateX(-2px); }

/* Filter bar */
.dr-filterbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 14px 2px;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 280px;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--warmgray-2);
}
.search:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(232,168,32,0.16); }
.search input { border: none; outline: none; background: none; font-family: var(--font-sans); font-size: 0.9rem; color: var(--ink); width: 100%; }
.dr-count { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; color: var(--warmgray-2); text-transform: uppercase; white-space: nowrap; }
.dr-refreshed { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.03em; color: var(--warmgray); white-space: nowrap; }
.dr-meta-right { display: flex; align-items: center; gap: 12px; flex: none; }
.dr-filterbar { align-items: center; }

/* Grid */
.dr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-top: 6px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease;
  text-decoration: none;
  color: inherit;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -22px rgba(28,22,17,0.55); border-color: rgba(232,168,32,0.6); }
.card.is-folder { background: linear-gradient(180deg, var(--cream-2), #fff); }

.card__thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--cream);
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.card__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__thumb .filetype-icon { width: 46px; height: 46px; }
.card__thumb .folder-icon { width: 52px; height: 52px; }
.card__badge {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.1em; text-transform: uppercase;
  background: rgba(28,22,17,0.82); color: #fff; padding: 3px 7px; border-radius: 999px;
}
.card.is-folder .card__badge { background: rgba(232,168,32,0.92); color: var(--charcoal); }

.card__body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card__name {
  font-size: 0.88rem; font-weight: 600; color: var(--charcoal); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
  overflow-wrap: break-word;
  word-break: normal;
}
.card__meta { font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.04em; color: #5a5145; display: flex; gap: 8px; flex-wrap: wrap; }
.card__meta .mv { white-space: nowrap; display: inline-flex; gap: 6px; }
.card__meta .dot { color: var(--warmgray); }

/* States */
.dr-state { margin-top: 6px; }
.dr-empty {
  text-align: center; padding: 56px 24px;
  background: #fff; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.dr-empty h3 { margin: 6px 0 0; color: var(--charcoal); font-size: 1.15rem; }
.dr-empty p { margin: 0; color: var(--warmgray-2); max-width: 42ch; }
.dr-empty--err { border-color: rgba(210,106,66,0.5); background: #fdf6f3; }

/* Skeleton loading */
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.sk-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sk-thumb { aspect-ratio: 4/3; background: linear-gradient(100deg, var(--cream) 30%, #fff 50%, var(--cream) 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.sk-line { height: 10px; margin: 11px 13px; border-radius: 4px; background: linear-gradient(100deg, var(--cream) 30%, #efe7d6 50%, var(--cream) 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.sk-line.short { width: 55%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Demo banner */
.demo-banner {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.04em;
  background: rgba(79,179,169,0.12); color: #2f6e68;
  border: 1px solid rgba(79,179,169,0.35); border-radius: 999px;
  padding: 7px 14px; margin-bottom: 4px; width: fit-content;
}
.demo-banner svg { flex: none; }

/* Sectioned root layout */
.dr-grid.is-sections { display: block; }
.dr-sections { display: flex; flex-direction: column; gap: 26px; margin-top: 6px; }
.dr-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  box-shadow: 0 10px 26px -22px rgba(28,22,17,0.35);
}
.dr-section__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.dr-section__head::-webkit-details-marker { display: none; }
.dr-section__head::marker { content: ""; }
.dr-section__head:hover .dr-section__title { color: var(--amber-deep, #a86a1a); }
.dr-section__head:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}
.dr-section__chevron {
  flex: none;
  color: var(--warmgray-2);
  transition: transform .18s ease;
  margin-right: 2px;
}
.dr-section[open] > .dr-section__head .dr-section__chevron { transform: rotate(90deg); }
.dr-section__title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.05rem; font-weight: 700; color: var(--charcoal);
  letter-spacing: -0.005em;
  flex: 1 1 auto;
  min-width: 0;
  transition: color .15s ease;
}
.dr-section__title::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--amber);
  margin-right: 10px;
  transform: rotate(45deg);
  vertical-align: middle;
}
.dr-section__body {
  padding-top: 14px;
}
.dr-section:not([open]) > .dr-section__head { padding-bottom: 0; border-bottom: none; }
.dr-section__meta {
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.08em;
  color: var(--warmgray-2); text-transform: uppercase; white-space: nowrap;
}
.dr-section__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.dr-section__more {
  margin-top: 14px; display: flex; justify-content: flex-end;
}
.dr-section--other .dr-section__title::before { background: var(--warmgray); }

/* Download button spinner */
#download-btn.is-loading,
#preview-download.is-loading { pointer-events: none; opacity: 0.7; }
#download-btn.is-loading svg,
#preview-download.is-loading svg { animation: dl-spin 1s linear infinite; }
@keyframes dl-spin { to { transform: rotate(360deg); } }

/* Google sign-in button slot */
.gsi-slot { display: flex; justify-content: center; margin-top: 10px; }
.gsi-slot:empty { display: none; margin-top: 0; }
.gsi-slot:has(*) + #signin-cta { display: none; }

/* Preview modal */
.preview-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.preview-modal[hidden] { display: none; }
.preview-backdrop {
  position: absolute; inset: 0;
  background: rgba(28,22,17,0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: pv-fade .15s ease-out;
}
.preview-panel {
  position: relative;
  display: flex; flex-direction: column;
  width: min(1180px, 100%);
  height: min(88vh, 900px);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg, 14px);
  box-shadow: 0 40px 90px -30px rgba(28,22,17,0.55);
  overflow: hidden;
  animation: pv-rise .18s ease-out;
}
.preview-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--cream-2), #fff);
  flex: none;
}
.preview-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.preview-badge {
  font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.1em; text-transform: uppercase;
  background: rgba(28,22,17,0.82); color: #fff; padding: 3px 7px; border-radius: 999px; flex: none;
}
.preview-title {
  margin: 0;
  font-size: 0.98rem; font-weight: 600; color: var(--charcoal);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.preview-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.preview-body {
  flex: 1 1 auto;
  background: var(--cream);
  min-height: 0;
}
#preview-iframe {
  width: 100%; height: 100%;
  border: 0; display: block;
  background: #fff;
}
@keyframes pv-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pv-rise { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  .preview-modal { padding: 8px; }
  .preview-panel { height: 94vh; border-radius: 12px; }
  .preview-header { padding: 10px 12px; }
  .preview-title { font-size: 0.9rem; }
}

/* Responsive */
@media (max-width: 640px) {
  .dr-meta-right { flex-direction: column; align-items: flex-end; gap: 2px; }
  .dr-filterbar { flex-wrap: wrap; }
  .site-header { padding: 16px 18px; flex-wrap: wrap; gap: 10px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-name { font-size: 0.98rem; }
  .brand-sub { font-size: 0.56rem; }
  .dr-toolbar { flex-direction: column; align-items: stretch; }
  .dr-actions { justify-content: space-between; }
  .dr-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .ghost-link.btn--sm { padding: 7px 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .card:hover, .btn--primary:hover { transform: none; }
  .sk-thumb, .sk-line { animation: none; }
}
