/* ============================================================================
   Project Vault — shared styles
   data-bank document sharing frontend (guest + admin)

   Design goals: minimal, professional, accessible, responsive.
   Inter is self-hosted (frontend/fonts/); falls back to system font stack.
   Ebix design system tokens: navy/orange palette, 6 px radius.
   ========================================================================== */

:root {
  --bg:#F2F4F7; --surface:#ffffff; --border:#E1E4EA; --text:#091120;
  --text-muted:#566481; --accent:#E85D17; --accent-hover:#d04d0f;
  --accent-subtle:rgba(232,93,23,.10);
  --navy:#091120; --navy-mid:#1a2a4a;
  /* Ebix bare-name aliases — used by the redesigned Files/Guests/Activity UI
     (Phase C–G, ported from the approved mock). Same values as the legacy
     names above; defining both lets the existing console CSS and the ported
     redesign CSS share one stylesheet. */
  --orange:#E85D17; --orange-hover:#d04d0f; --orange-subtle:rgba(232,93,23,.10);
  --muted:#566481; --light:#F2F4F7; --destructive:#d13438;
  --danger:#d13438; --danger-hover:#b3261e; --success:#1e7e34;
  --warning-bg:#fff4e5; --warning-text:#8a5300;
  --notice:#091120; --radius:6px;
  --shadow:0 1px 2px rgba(9,17,32,.06),0 1px 3px rgba(9,17,32,.05);
  --shadow-pop:0 10px 30px rgba(9,17,32,.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

/* ---- Notice banner (legacy — kept for guest SPA) ------------------------- */
.notice-banner {
  background: var(--notice);
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
}

/* ---- Navy app bar (owner console redesign — Phase C) --------------------- */
.appbar { background: var(--navy); color: #fff; padding: 0 24px; }
.appbar-top { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand .lock { color: var(--orange); }
.brand .ws { font-weight: 500; font-size: 12px; color: #9fb0cc; background: var(--navy-mid);
  padding: 3px 9px; border-radius: 999px; }
.appbar .who { font-size: 13px; color: #9fb0cc; display: flex; align-items: center; gap: 12px; }
.tabs { display: flex; gap: 2px; }
.tab { padding: 11px 16px; color: #c2cee0; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; font-size: 14px; user-select: none; }
.tab:hover { color: #fff; }
.tab.active { color: #fff; border-bottom-color: var(--orange); }

/* ---- Screen containers (Files / Guests / Activity) ----------------------- */
.screen { display: none; }
.screen.active { display: block; }

/* ---- Legacy header (kept for any residual use) --------------------------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  flex-wrap: wrap;
}

.user-email {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* ---- Layout -------------------------------------------------------------- */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

/* The owner console uses (near) full width — it's a Drive-style app, not a
   reading column. Guest pages keep the narrow centered `main` above. */
main.console {
  max-width: 1680px;
  padding: 20px 28px;
}

section.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 24px;
}

section.card h2 {
  font-size: 16px;
  margin: 0 0 16px;
  font-weight: 600;
}

.section-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: -8px 0 16px;
}

/* ---- Buttons ------------------------------------------------------------- */
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  transition: background 0.12s ease;
}

button:hover { background: var(--accent-hover); }

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border);
}
button.secondary:hover { background: #f0f3f7; }

button.danger {
  background: var(--danger);
}
button.danger:hover { background: var(--danger-hover); }

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.small {
  padding: 5px 10px;
  font-size: 13px;
}

/* ---- Forms --------------------------------------------------------------- */
input[type="text"],
input[type="email"],
input[type="file"] {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}

input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-form input[type="email"],
.inline-form input[type="text"] {
  flex: 1 1 220px;
}

label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

/* ---- Tables -------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

tbody tr:hover { background: #fafbfc; }

td.actions { text-align: right; white-space: nowrap; }

tr.folder-group-header th {
  background: var(--bg, #f5f6f8);
  color: var(--text, #1a1d23);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  padding: 8px 12px;
  border-top: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
}

tr.folder-group-header:first-child th {
  border-top: none;
}

/* ---- Status pills -------------------------------------------------------- */
.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: capitalize;
}
.pill.active  { background: #e6f4ea; color: var(--success); }
.pill.revoked { background: #fde8e6; color: var(--danger); }
.pill.expired { background: #f0f1f3; color: var(--text-muted); }

/* ---- Empty / message states --------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}
.empty-state .empty-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.notice {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  border: 1px solid transparent;
}
.notice.warn   { background: var(--warning-bg); color: var(--warning-text); border-color: #f0d9b5; }
.notice.error  { background: #fde8e6; color: var(--danger); border-color: #f5c6c2; }
.notice.info   { background: #eaf1f8; color: var(--accent); border-color: #cfe0f0; }

.hidden { display: none !important; }

/* Vault URL text in the workspaces table: truncate so the table stays readable */
.vault-url-text {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  font-size: 0.85em;
  color: var(--text-muted);
}

/* Visually hidden but available to screen readers (e.g. action-column header) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Signed-out gate ----------------------------------------------------- */
.gate {
  text-align: center;
  padding: 56px 24px;
}
.gate h2 { margin-top: 0; }
.gate p { color: var(--text-muted); max-width: 460px; margin: 0 auto 20px; }

/* ---- Toasts -------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 14px;
  max-width: 320px;
  animation: toast-in 0.15s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Footer -------------------------------------------------------------- */
.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 24px;
}

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 560px) {
  .app-header { padding: 12px 16px; }
  main { padding: 16px; }
  section.card { padding: 16px; }
  .user-email { max-width: 130px; }
}

/* ---- Expiry modal -------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.25);
  padding: 24px;
  width: 100%;
  max-width: 400px;
}
.modal-card h3 { margin: 0 0 4px; }
.expiry-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 12px;
}
.expiry-choices label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ---- Folder rows --------------------------------------------------------- */
.folder-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.folder-row:last-child { border-bottom: none; }

.folder-name {
  flex: 1 1 auto;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.folder-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ---- Folder checkbox list (invite + edit-access modals) ------------------ */
.folder-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fafbfc;
}
.folder-checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.folder-checkbox-list .no-folders-hint {
  font-size: 13px;
  color: var(--text-muted);
}
.folder-scope-warn {
  font-size: 13px;
  color: var(--warning-text);
  background: var(--warning-bg);
  border: 1px solid #f0d9b5;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 8px 0 0;
}

/* ---- Files two-pane layout (Drive-style, ported from approved mock) ------- */
.files {
  display: grid;
  /* minmax(0,1fr) (not 1fr) lets the pane shrink below its content width so a
     wide table scrolls INSIDE .pane-body instead of pushing the column — and
     the Upload button / row actions — off the right edge. */
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 440px;
  border-top: 1px solid var(--border);
}
.nav {
  border-right: 1px solid var(--border);
  padding: 12px;
  background: #fbfcfe;
}
.nav-sec {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 6px 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}
.nav-item:hover { background: #eef1f6; }
.nav-item.active { background: var(--orange-subtle); color: var(--orange); font-weight: 600; }
.nav-item.drop-hot { background: var(--orange-subtle); outline: 2px dashed var(--orange); outline-offset: -2px; }
.nav-item .ic { width: 18px; text-align: center; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item.active .count { color: var(--orange); }
.nav-item .fmenu {
  margin-left: 6px; opacity: 0; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; border-radius: 4px;
}
.nav-item:hover .fmenu { opacity: 1; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 4px; }
.newfolder { display: flex; gap: 6px; padding: 8px 6px 2px; }
.newfolder input {
  flex: 1; min-width: 0; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; font-size: 13px;
}

.pane { display: flex; flex-direction: column; min-width: 0; }
.pane-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
/* Documents + People sit side by side on wide screens, stacked on narrow. */
.pane-content { display: flex; flex: 1; min-width: 0; align-items: stretch; }
.pane-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 600;
}
.pane-title .sub { font-weight: 400; font-size: 13px; color: var(--muted); }
.pane-head .spacer { flex: 1; }
.pane-body { padding: 4px 6px 10px; overflow-x: auto; overflow-y: auto; flex: 1 1 auto; min-width: 0; }
.pane-body table { min-width: 560px; }
.pane-body table { width: 100%; border-collapse: collapse; }
.pane-body th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px;
}
.pane-body td {
  padding: 11px 12px; border-top: 1px solid var(--border);
  font-size: 14px; vertical-align: middle;
}
.pane-body tbody tr { cursor: grab; }
.pane-body tbody tr:hover { background: #fafbfd; }
.pane-body tbody tr.dragging { opacity: .4; }
.fname { display: flex; align-items: center; gap: 9px; }
.fname .ic { color: var(--muted); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: #eef1f6; color: var(--muted);
  border-radius: 999px; padding: 2px 9px; font-size: 12px;
}
.chip.unfiled { background: #f0f1f3; }

.rowmenu-btn {
  border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1;
  padding: 2px 8px; border-radius: var(--radius);
}
.rowmenu-btn:hover { background: #eef1f6; color: var(--navy); }

.pane-empty {
  padding: 38px 20px; text-align: center; color: var(--muted);
}
/* Loading state shown while a list/screen is fetching. */
.loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 44px 20px; color: var(--muted); font-size: 14px;
}
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--orange); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.pane-empty .big { font-size: 15px; color: var(--navy); margin-bottom: 4px; }

/* People-with-access: right sidebar on wide screens, stacked below on narrow.
   Hidden (display:none, set in JS) when viewing All/Unfiled. */
.people {
  flex: 0 0 280px;
  border-left: 1px solid var(--border);
  background: #fbfcfe;
  padding: 14px 16px;
  overflow-y: auto;
}
@media (max-width: 900px) {
  .pane-content { flex-direction: column; }
  .people {
    flex: none;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}
.people h4 {
  margin: 0 0 8px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}
.person {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 6px 3px 11px;
  margin: 0 8px 8px 0; font-size: 13px;
}
.person .x {
  border: 0; background: none; color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 50%;
}
.person .x:hover { background: #fde8e6; color: var(--destructive); }

/* ---- Activity filter bar ---- */
.filterbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.filterbar label { font-size: 13px; color: var(--muted); }
.filterbar select {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font: inherit; font-size: 13px; background: #fff;
}
.fchip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--orange-subtle); color: var(--orange);
  border: 1px solid rgba(232,93,23,.3); border-radius: 999px;
  padding: 4px 6px 4px 12px; font-size: 13px; font-weight: 600;
}
.fchip .x {
  border: 0; background: none; color: var(--orange);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 0 3px;
}
.server-note { margin-left: auto; font-size: 12px; color: var(--muted); }

/* context-menu popovers */
.pop {
  position: fixed; z-index: 40; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-pop); padding: 5px; min-width: 180px;
}
.pop button {
  display: flex; width: 100%; gap: 8px; background: none;
  color: var(--navy); font-weight: 500; text-align: left;
  padding: 8px 10px; border-radius: 5px; border: 0;
}
.pop button:hover { background: #eef1f6; }
.pop button.danger-item:hover { background: #fde8e6; color: var(--destructive); }
.pop.hidden { display: none; }

/* folder-picker overlay */
.fp-overlay {
  position: fixed; inset: 0; background: rgba(9,17,32,.4);
  z-index: 50; display: flex; align-items: center; justify-content: center;
}
.fp-overlay.hidden { display: none; }
.fp-modal {
  background: var(--surface); border-radius: 10px;
  box-shadow: var(--shadow-pop); width: 390px; max-width: 92vw; padding: 22px;
}
.pick {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px;
  margin-bottom: 8px; cursor: pointer; display: flex; align-items: center; gap: 10px;
}
.pick:hover { border-color: var(--orange); }
.pick.sel { border-color: var(--orange); background: var(--orange-subtle); }
.pick .dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #c4ccd6; flex: none;
}
.pick.sel .dot {
  border-color: var(--orange);
  background: radial-gradient(circle, var(--orange) 42%, #fff 46%);
}

/* ghost button variant (used in folder-picker footer) */
button.ghost {
  background: var(--surface); color: var(--navy);
  border-color: var(--border); font-weight: 500;
}
button.ghost:hover { background: var(--light); }

@media (max-width: 720px) {
  .files { grid-template-columns: 1fr; }
  .nav { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* ---- Stacked form (guest email -> code) ---------------------------------- */
.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
  margin: 16px auto 0;
}
.stacked-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
}
