/*
 * Brand overrides on top of Bootstrap 5 (CDN), plus the browser panel.
 *
 * RULE (learned the hard way): Bootstrap display utilities compile with
 * !important, which beats Alpine x-show's inline display:none. So NO
 * element with x-show may carry d-flex / d-block / d-none. Layout for
 * those elements lives in our own plain classes below (.inline-edit-row,
 * .browser-toolbar) — no !important, so the inline style wins when hiding.
 */

:root {
  --procyon-dark: #0d1b2a;
  --procyon-accent: #e0a458;
  --procyon-blue: #2563eb;
  --row-border: #f1f3f5;
}

/* Alpine: hide elements until Alpine initializes (x-cloak pattern). */
[x-cloak] {
  display: none !important;
}

/* Push the footer to the bottom on short pages. */
body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

.navbar {
  background-color: var(--procyon-dark) !important;
}

.navbar-brand {
  color: var(--procyon-accent) !important;
}

/* The logout control is a <button> styled as a navbar link. */
.navbar button.nav-link {
  border: 0;
  background: none;
  cursor: pointer;
}

/* Org switcher (batch 4): label left, ✓ marker right, on every item. */
.navbar .dropdown-menu .dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.navbar .org-check {
  color: var(--procyon-accent);
}

/* Staff running-timer chip in the navbar. */
.timer-chip {
  color: var(--procyon-accent) !important;
  font-variant-numeric: tabular-nums;
}

.timer-chip.timer-over {
  color: #ff8f8f !important;
}

.site-footer {
  background-color: var(--procyon-dark);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
}

.hero img {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
}

/* ----- Dashboard (batch 5, refined 2026-09-21) ----- */

/* Section headers: brand blue, bold, gold accent bar, generous space
   above — they must read as section banners and separate cleanly from
   their contents (client feedback 2026-09-21). Change --procyon-blue in
   :root to retune the color everywhere in one line. */
.dash-section {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--procyon-blue);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 2.5rem 0 0.9rem;
}

.dash-section::before {
  content: "";
  flex: 0 0 auto;
  width: 0.3rem;
  height: 1.15rem;
  border-radius: 2px;
  background: var(--procyon-accent);
}

/* Organization sub-labels: deliberately subordinate to section headers —
   small, uppercase, muted — so the page hierarchy reads at a glance.
   (Single-org clients only; the chip audience gets .org-chip instead.) */
.dash-org {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6c757d;
  margin: 1.4rem 0 0.55rem;
}

/* The todo count badge rides the section heading. */
.dash-badge {
  font-size: 0.7rem;
  vertical-align: 2px;
}

/* Flowing list panel: like .browser-panel but NO height cap — the todo
   and timeline must read as page content, not a boxed scroller that cuts
   off mid-row (client feedback 2026-09-21). */
.dash-panel {
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  background: #fff;
  overflow: hidden;
}

/* Row-type badges (Time / Invoice / Payment / Credit / File): fixed width
   so the titles align down the list. */
.dash-kind {
  flex: 0 0 auto;
  width: 5.2rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Org chip (staff UX pass 2026-09-21): colors come INLINE from the
   org_chip tag (deterministic per-org palette); this class owns shape,
   ellipsis, and alignment. Full name on the face, full name in title. */
.org-chip {
  display: inline-block;
  flex: 0 0 auto;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.6;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
}

/* Quick Links: one row per organization — the org anchors the left,
   the buttons flow and wrap to the right (client-approved layout). */
.quick-links-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.4rem 0;
}

.qlabel {
  flex: 0 0 9rem;
  font-weight: 600;
}

.qbuttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* Contract cards: pure information (navigation lives in Quick Links).
   One per contract — never per file. */
.contract-card {
  display: block;
  height: 100%;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fff;
  color: inherit;
  text-decoration: none;
}

.contract-card:hover {
  border-color: var(--procyon-accent);
  background: #fffdf8;
  color: inherit;
}

.contract-name {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.contract-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.stat-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
}

.stat-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Unpaid money is the one number that demands attention. */
.stat-hot .stat-value {
  color: #b02a37;
}

/* ----- Browser panel (Finder-style) ----- */

.browser-panel {
  display: flex;
  flex-direction: column;
  max-height: 65vh;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  background: #fff;
  overflow: hidden;
}

/* The rows region scrolls; toolbar and storage line stay pinned.
   min-height: 0 is required for overflow to work inside a flex column. */
.browser-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.browser-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--row-border);
}

.storage-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--row-border);
}

.storage-line .progress {
  height: 4px;
}

/* Category chips (Procyon Files tab). */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--row-border);
}

.chip {
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 0.1rem 0.65rem;
  border: 1px solid #dee2e6;
  border-radius: 999px;
  color: #495057;
  background: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--procyon-accent);
  color: var(--procyon-dark);
}

.chip-active {
  background: var(--procyon-dark);
  border-color: var(--procyon-dark);
  color: #fff;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--row-border);
  color: inherit;
  text-decoration: none;
}

a.file-row:hover,
a.file-row:hover .row-name {
  background: #f8f9fa;
  color: inherit;
}

.row-glyph {
  width: 1.5rem;
  text-align: center;
  flex: 0 0 auto;
  text-decoration: none;
}

/* Name + notes stack. Owns the flexible width; children ellipsize. */
.row-title-block {
  flex: 1 1 auto;
  min-width: 0;
}

.row-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.row-notes {
  display: block;
  color: #6c757d;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-path {
  color: #adb5bd;
  font-size: 0.8rem;
  white-space: nowrap;
}

.row-date,
.row-size {
  color: #6c757d;
  font-size: 0.85rem;
  white-space: nowrap;
  flex: 0 0 auto;
}

.row-size {
  width: 8rem;
  text-align: right;
}

.row-menu {
  width: 2rem;
  text-align: right;
  flex: 0 0 auto;
}

.row-menu-btn {
  border: 0;
  background: none;
  padding: 0 0.25rem;
  font-size: 1.1rem;
  line-height: 1;
  color: #6c757d;
  cursor: pointer;
}

.row-menu-btn:hover {
  color: var(--procyon-dark);
}

/* Action buttons in contract rows (Receipt, Edit, Remove). Unlike
   .row-menu — a fixed 2rem column sized for the portal's ⋯ dropdown —
   this column sizes to its content, so a labeled button never overflows
   the panel. The title block shrinks instead (it has min-width: 0). */
.row-actions {
  flex: 0 0 auto;
  text-align: right;
  white-space: nowrap;
}

/* Editable rows (new folder, renames, notes). Our own class on purpose —
   see the rule at the top of this file. */
.inline-edit-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--row-border);
  background: #fafbfc;
}

.inline-input {
  max-width: 40rem;
  flex: 1 1 auto;
}

.drop-hint {
  padding: 2.5rem 1rem;
  text-align: center;
  color: #6c757d;
}

/* Drag-over highlight for the whole panel. */
.dropzone-active {
  outline: 2px dashed var(--procyon-accent);
  outline-offset: -2px;
  background-color: #fff8ef;
}

/* ----- Messaging (messaging v1) ----- */

/* Chat-style thread: bubbles shrink to their content and align to their
   side. Mine carry the brand accent tint; theirs stay plain. */
.msg-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg {
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 0.6rem 0.9rem;
  background: #fff;
  max-width: 42rem;
}

.msg-mine {
  align-self: flex-end;
  background: #fffdf8;
  border-color: var(--procyon-accent);
}

.msg-theirs {
  align-self: flex-start;
}

.msg-meta {
  font-size: 0.75rem;
  color: #6c757d;
  margin-bottom: 0.25rem;
}

.msg-body {
  white-space: pre-line;
  overflow-wrap: break-word;
}

/* The Read marker sits under the sender's side of the thread. */
.msg-read {
  text-align: right;
  font-size: 0.75rem;
  color: #adb5bd;
}

/* ----- Questionnaires (questionnaires v1) ----- */

/* The autosave indicator: quiet until it has something to say. x-show
   governs visibility — our own class, never a Bootstrap display utility
   (the rule at the top of this file). */
.saved-indicator {
  font-size: 0.78rem;
  color: #6c757d;
  font-variant-numeric: tabular-nums;
}

/* ----- Print: invoices and receipts ----- */

@media print {
  .navbar,
  .site-footer,
  .alert,
  .btn,
  .no-print {
    display: none !important;
  }

  /* Chips are screen chrome; the document names its parties itself. */
  .org-chip {
    display: none !important;
  }

  body {
    background: #fff !important;
  }

  main {
    padding: 0 !important;
  }

  main .container {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .invoice-doc {
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }
}