/* Project-wide styles. Keep this small; Bootstrap does most of the work. */

.sensitive {
  font-family: var(--bs-font-monospace);
  letter-spacing: 0.05em;
}

.table td,
.table th {
  vertical-align: middle;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* Extra status colours beyond Bootstrap's palette (see TaxFiling.STATUS_CLASSES). */
.text-bg-purple {
  background-color: #6f42c1 !important;
  color: #fff !important;
}

.text-bg-teal {
  background-color: #b7e4c7 !important;
  color: #1b4332 !important;
}

.text-bg-approved {
  background-color: #d1e7dd !important;
  color: #0a3622 !important;
  border: 1px solid #198754 !important;
}

/* The status dropdown in lists is coloured like a badge. */
.status-select {
  width: auto;
  min-width: 10.5rem;
  font-weight: 500;
  border-color: rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.status-select option {
  background-color: #fff;
  color: #212529;
  font-weight: 400;
}

/* Open the Clients menu on hover on desktop; the link itself still goes to the list. */
@media (min-width: 992px) {
  .navbar .nav-item.dropdown-hover:hover > .dropdown-menu {
    display: block;
    margin-top: 0;
  }
}

/* ---------------------------------------------------------------------------
   Application shell: left sidebar (collapsible on desktop, off-canvas on mobile)
   --------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  --bs-offcanvas-width: 260px;
  --bs-offcanvas-bg: #1c2128;
  --bs-offcanvas-color: #fff;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  width: 240px;
  min-height: 100vh;
  background: #1c2128;
  color: #c9d1d9;
}

.sidebar-brand {
  display: block;
  padding: 1rem 1.25rem;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand:hover { color: #fff; }
.app-logo { height: 34px; width: auto; display: block; }
.app-logo-sm { height: 26px; width: auto; }
.auth-logo { height: 56px; width: auto; }

.sidebar-nav { padding: 0.5rem 0.75rem; }

.sidebar-link,
.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.4rem;
  color: #c9d1d9;
  text-decoration: none;
  font-size: 0.95rem;
}

.sidebar-link i { width: 1.1rem; text-align: center; font-size: 1rem; opacity: 0.85; }

.sidebar-link:hover,
.sidebar-sublink:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }

.sidebar-link.active,
.sidebar-sublink.active { background: rgba(13, 110, 253, 0.25); color: #fff; font-weight: 500; }

.sidebar-subnav { padding-left: 1.7rem; }

/* Sections that unfold on hover (Billing, Clients); always open on their own pages.
   The fold-back is delayed so a passing mouse does not make the list jump. */
.sidebar-hover .sidebar-subnav {
  max-height: 0; overflow: hidden;
  transition: max-height 0.2s ease 0.4s;
}
.sidebar-hover:hover .sidebar-subnav,
.sidebar-hover:focus-within .sidebar-subnav,
.sidebar-hover.open .sidebar-subnav { max-height: 24rem; transition-delay: 0s; }
.sidebar-hint { width: auto !important; font-size: 0.7rem !important; opacity: 0.5; transition: transform 0.15s ease; }
.sidebar-hover:hover .sidebar-hint,
.sidebar-hover.open .sidebar-hint { transform: rotate(180deg); }


.sidebar-sublink { font-size: 0.875rem; padding: 0.3rem 0.6rem; }
.sidebar-sublink i { width: 1rem; text-align: center; font-size: 0.85rem; opacity: 0.8; }

.sidebar-footer {
  margin-top: auto;
  padding-bottom: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-heading {
  padding: 0.85rem 1.35rem 0.25rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b949e;
}

.sidebar-user { padding: 0.25rem 0.75rem 0; }

.sidebar-user .dropdown-toggle::after { margin-left: auto; }

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--bs-border-color);
}

.app-content {
  flex: 1 1 auto;
  padding: 1.5rem;
}

@media (min-width: 992px) {
  .app-sidebar { flex: 0 0 auto; transition: margin-left 0.2s ease; }
  .sidebar-collapsed .app-sidebar { margin-left: -240px; }
}

/* Timesheet */
.timesheet tr.today th { background-color: #e7f1ff !important; }
.timesheet td, .timesheet th { padding-top: 0.35rem; padding-bottom: 0.35rem; }


/* Timeline and @mentions */
.mention { background: #e7f1ff; color: #0a58ca; border-radius: .25rem; padding: 0 .2rem; font-weight: 500; }
.mention-menu { position: absolute; left: 0; top: 100%; z-index: 1050; min-width: 16rem; }
.timeline-body { white-space: pre-line; }
.timeline-icon { width: 1.2rem; text-align: center; padding-top: .15rem; }


/* Triage split view */
.triage-list { max-height: calc(100vh - 12rem); overflow-y: auto; }
.triage-list .active-item { background: #e7f1ff; border-left: 3px solid #0d6efd; }
.email-frame { width: 100%; min-height: 28rem; border: 0; background: #fff; }
.label-caps { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #6c757d; margin-bottom: .35rem; }

/* Relative due-date pills: one width everywhere so columns line up */
.due-pill { display: inline-block; min-width: 8.5em; text-align: center; }
.due-pill.text-bg-dark, .due-pill.text-bg-danger { letter-spacing: -.01em; }
/* Date + pill as two fixed columns so the pills line up down a list */
.due-when { display: inline-flex; align-items: center; white-space: nowrap; }
.due-date { display: inline-block; min-width: 6.6em; }
.due-date-short { min-width: 3.8em; }
.table-compact .due-date { min-width: 6.2em; }

/* Billed-to type-ahead inside a table cell */
.billed-to-search { position: relative; min-width: 16rem; }
.billed-to-search .list-group { position: absolute; z-index: 20; left: 0; right: 0; background: #fff; max-height: 16rem; overflow-y: auto; border: 1px solid #dee2e6; border-radius: .375rem; }

/* Job commentary popover next to the status dropdown */
.job-notes { position: relative; display: inline-block; }
.job-notes-toggle { line-height: 1; color: #0d6efd; }
.job-notes-toggle.text-muted { color: #adb5bd !important; }
.job-notes-count { font-size: .65rem; }
.billed-to, .billed-to-search { max-width: 18rem; }
.job-notes-panel { display: none; position: fixed; z-index: 1050; width: 22rem; max-width: 80vw;
  background: #fff; border: 1px solid #dee2e6; border-radius: .375rem; box-shadow: 0 .5rem 1rem rgba(0,0,0,.15); padding: .6rem; text-align: left; white-space: normal; }
.job-notes:hover .job-notes-panel, .job-notes.open .job-notes-panel { display: block; }
.job-notes-list { max-height: 12rem; overflow-y: auto; }
td .job-notes-panel { font-weight: normal; }

/* Compact list layout: more rows on screen, one line per row */
.table-compact .table > :not(caption) > * > * { padding: .15rem .4rem; font-size: .8rem; line-height: 1.25; }
.table-compact .table th { font-size: .75rem; white-space: nowrap; }
.table-compact .job-period-note { display: none !important; }
.table-compact .form-select-sm, .table-compact .status-select { padding-top: .05rem; padding-bottom: .05rem; font-size: .75rem; min-width: 8rem; }
.table-compact .btn-sm { padding: .05rem .35rem; font-size: .72rem; }
.table-compact .badge { font-size: .65rem; }
.table-compact .due-pill { min-width: 8em; }
.table-compact .job-notes-toggle .job-notes-count { font-size: .6rem; }
.table-compact td { white-space: nowrap; }
.list-layout .btn-sm { padding: .2rem .5rem; }

/* MTD planner */
.mtd-select { min-width: 8.5rem; }
.mtd-select.mtd-required { background-color: #fff3cd; }
.mtd-select.mtd-registered { background-color: #d1e7dd; }
.mtd-select.mtd-exempt { background-color: #e2e3e5; }
.mtd-notes-col { min-width: 14rem; }
.mtd-notes input[title="Saved"] { border-color: #198754; }

/* Triage: folders, rows, thread view */
.triage-folders .nav-link { color: inherit; border-radius: .25rem; }
.triage-folders .nav-link.active { background: #e7f1ff; }
.triage-row .row-title { font-weight: 400; }
.triage-row.unread .row-title { font-weight: 600; }
.triage-row.unread { border-left: 3px solid #0d6efd; }
.triage-row .row-actions { visibility: hidden; }
.triage-row:hover .row-actions, .triage-row.active-item .row-actions { visibility: visible; }
.triage-row.active-item { background: #e7f1ff; }
.triage-row.cursor { outline: 2px solid #0d6efd; outline-offset: -2px; }
.min-w-0 { min-width: 0; }
.thread-message .thread-body { display: none; }
.thread-message.open .thread-body { display: block; }
.thread-message.open .thread-preview { display: none; }
.thread-message.outgoing { border-left: 3px solid #0d6efd; }
.thread-head { cursor: pointer; }
.avatar-dot { display: inline-block; width: 1.5rem; height: 1.5rem; border-radius: 50%; color: #fff; text-align: center; line-height: 1.5rem; font-size: .8rem; margin-right: .35rem; }
.bulk-bar { min-height: 2rem; }

/* Global search in the top bar */
.global-search { position: relative; max-width: 42rem; }
.global-search-results { position: absolute; top: 100%; left: 0; right: 0; z-index: 1040; background: #fff; border: 1px solid #dee2e6; border-radius: .375rem; max-height: 70vh; overflow-y: auto; display: none; }
.global-search-results:not(:empty) { display: block; }
.search-group-title { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #6c757d; padding: .4rem .75rem .1rem; }
.search-hit { display: flex; align-items: baseline; gap: .5rem; padding: .3rem .75rem; text-decoration: none; color: inherit; }
.search-hit:hover, .search-hit.active { background: #e7f1ff; }
.search-hit-title { font-weight: 500; white-space: nowrap; }
.search-hit-sub { color: #6c757d; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: .6rem .75rem; color: #6c757d; font-size: .85rem; }
.search-page .search-hit { padding: .4rem 0; }
.ask-q { margin: .5rem 0; }
.ask-a p:last-child { margin-bottom: 0; }

/* Resizable Triage split: the list and the thread pane share a flex row */
@media (min-width: 992px) {
  .triage-split > .triage-list-col { flex: 0 0 var(--triage-list, 34%); max-width: none; width: var(--triage-list, 34%); }
  .triage-split > .triage-pane { flex: 1 1 0; max-width: none; width: auto; min-width: 20rem; }
}
.triage-divider { flex: 0 0 8px; cursor: col-resize; margin: 0 -4px; position: relative; }
.triage-divider::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: #dee2e6; }
.triage-divider:hover::after, .triage-divider.dragging::after { background: #0d6efd; }
.timeline-preview { white-space: pre-line; }

/* Thread pane: wide thread, narrow action column (about half a Bootstrap quarter) */
.conversation-main { flex: 1 1 0; min-width: 0; }
@media (min-width: 1200px) { .triage-side { flex: 0 0 13rem; max-width: 13rem; } }
.triage-side .card-body { padding: .6rem .7rem; }
.triage-side .form-select, .triage-side .form-control, .triage-side .btn { font-size: .8rem; }

/* The thread's title bar and action toolbar sit on top of the messages as one box */
.thread-toolbar { border-bottom-left-radius: 0; border-bottom-right-radius: 0; margin-bottom: 0 !important; }
.thread-toolbar + .thread-message { border-top-left-radius: 0; border-top-right-radius: 0; border-top: 0; }
.thread-toolbar .card-footer { background: #f8f9fa; }
.item-actions .btn { white-space: nowrap; }

/* Timeline emails expand in place */
.timeline-email-toggle { cursor: pointer; color: #495057; margin-top: .15rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.timeline-email-toggle:hover { color: #0d6efd !important; }
.timeline-email-toggle.open .bi-chevron-down { transform: rotate(180deg); display: inline-block; }
.email-full .email-frame { min-height: 16rem; }

/* Address suggestions under To / Cc */
.address-menu { position: absolute; top: 100%; left: 0; right: 0; z-index: 1060; max-height: 16rem; overflow-y: auto; }
.address-menu.show { display: block; }
