/* ==========================================================================
   Dashboard widget — a purpose-built card rendered by a per-widget partial.
   Card chrome lives here; the board grid/sections live in dashboard_home.css
   and the edit-mode catalogue in dashboard_editor.css.
   ========================================================================== */
.dashboard-widget {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-base), border-color var(--transition-base),
    opacity var(--transition-base), transform var(--transition-base);
}

.dashboard-widget:hover {
  box-shadow: var(--shadow-md);
}

/* == size → grid footprint (clamped to a section's available columns) == */
/* How wide each size is left to the section the widget is in: a section knows
   how many columns it has, and a span wider than that is what used to push the
   cards over each other (see .dashboard-board__widgets in dashboard_home.css).
   The classes are still here because they are what the section's rules select
   on. */

/* == header == */
.dashboard-widget__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.dashboard-widget__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background-color: var(--tint-green-16);
  color: var(--color-primary-dark);
}

.dashboard-widget__icon-svg {
  width: 18px;
  height: 18px;
}

.dashboard-widget__title {
  flex: 1;
  min-width: 0;
  font-size: var(--font-size-medium);
  font-weight: 600;
  color: var(--color-primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-widget__actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Size switch, drag handle and remove button only surface while editing. */
.dashboard-widget__sizes,
.dashboard-widget__drag,
.dashboard-widget__remove {
  display: none;
}

.dashboard-widget__sizes {
  gap: 2px;
  padding: 2px;
  background-color: var(--color-surface-sunken);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
}

.dashboard-widget__size {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.dashboard-widget__size:hover {
  color: var(--color-primary-dark);
}

.dashboard-widget__size.is-active {
  background-color: var(--color-primary-green);
  color: var(--color-white);
}

.dashboard-widget__drag {
  color: var(--color-text-faint);
  cursor: grab;
}

.dashboard-widget__remove {
  padding: var(--space-1);
  border: none;
  background: transparent;
  color: var(--color-text-faint);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.dashboard-widget__remove:hover {
  background-color: var(--tint-danger-10);
  color: var(--color-danger);
}

/* == body == */
.dashboard-widget__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* == hero (big single figure — schedule/notifications/time small) == */
.widget-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.widget-hero__eyebrow {
  font-size: var(--font-size-small);
  text-transform: uppercase;
  letter-spacing: var(--label-letter-spacing);
  color: var(--color-text-muted);
}

.widget-hero__value {
  font-size: var(--font-size-xxxlarge);
  font-weight: 700;
  line-height: 1.05;
  color: var(--color-primary-dark);
}

.widget-hero__value.is-muted {
  color: var(--color-text-faint);
}

.widget-hero__title {
  font-size: var(--font-size-medium);
  color: var(--color-text);
}

.widget-footnote {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

.widget-footnote--truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* == stat tiles == */
.widget-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-6);
}

.widget-stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 72px;
}

.widget-stat__value {
  font-size: var(--font-size-xxlarge);
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-primary-dark);
}

.widget-stat--accent .widget-stat__value {
  color: var(--color-warning-dark);
}

.widget-stat--danger .widget-stat__value {
  color: var(--color-danger);
}

.widget-stat__label {
  font-size: var(--font-size-small);
  text-transform: uppercase;
  letter-spacing: var(--label-letter-spacing);
  color: var(--color-text-muted);
}

/* == breakdown bar + legend == */
.widget-breakdown {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.widget-breakdown__bar {
  display: flex;
  height: 10px;
  gap: 2px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background-color: var(--color-surface-sunken);
}

.widget-breakdown__bar--empty::after {
  content: "";
  flex: 1;
  background-color: var(--color-border);
}

.widget-breakdown__seg {
  min-width: 4px;
}

.widget-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.widget-legend__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

.widget-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.widget-legend__count {
  font-weight: 700;
  color: var(--color-primary-dark);
}

/* Shared status colour swatches for segments and legend dots. */
.widget-breakdown__seg--green,
.widget-legend__dot--green {
  background-color: var(--color-primary-green);
}

.widget-breakdown__seg--blue,
.widget-legend__dot--blue {
  background-color: #3498db;
}

.widget-breakdown__seg--yellow,
.widget-legend__dot--yellow {
  background-color: var(--color-warning);
}

.widget-breakdown__seg--red,
.widget-legend__dot--red {
  background-color: var(--color-danger);
}

.widget-breakdown__seg--gray,
.widget-legend__dot--gray {
  background-color: var(--color-text-faint);
}

.widget-breakdown__seg--purple,
.widget-legend__dot--purple {
  background-color: #8e44ad;
}

/* == agenda (schedule) == */
.widget-agenda {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.widget-agenda__item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.widget-agenda__item:not(:first-child) {
  border-top: 1px solid var(--color-border);
}

.widget-agenda__time {
  display: flex;
  flex-direction: column;
  min-width: 74px;
}

.widget-agenda__day {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

.widget-agenda__hour {
  font-size: var(--font-size-medium);
  font-weight: 700;
  color: var(--color-primary-dark);
}

.widget-agenda__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.widget-agenda__title {
  font-size: var(--font-size-medium);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-agenda__type {
  font-size: var(--font-size-small);
  color: var(--color-text-faint);
}

/* == notifications == */
.widget-notifs {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.widget-notifs__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}

.widget-notifs__item:not(:first-child) {
  border-top: 1px solid var(--color-border);
}

.widget-notifs__dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background-color: var(--color-border-strong);
}

.widget-notifs__item.is-unread .widget-notifs__dot {
  background-color: var(--color-primary-green);
}

.widget-notifs__msg {
  flex: 1;
  min-width: 0;
  font-size: var(--font-size-medium);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-notifs__item.is-unread .widget-notifs__msg {
  font-weight: 600;
  color: var(--color-primary-dark);
}

.widget-notifs__time {
  font-size: var(--font-size-small);
  color: var(--color-text-faint);
  flex-shrink: 0;
}

/* == bar chart (time log) == */
.widget-bars {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  height: 96px;
}

.widget-bars__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  height: 100%;
}

.widget-bars__value {
  font-size: 10px;
  color: var(--color-text-faint);
}

.widget-bars__track {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 26px;
  display: flex;
  align-items: flex-end;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-sunken);
  overflow: hidden;
}

.widget-bars__fill {
  width: 100%;
  min-height: 3px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--color-primary-green), #46b78c);
}

.widget-bars__label {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}

/* == record list (cases/reviews/firms/complaints) == */
.widget-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.widget-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.widget-list__item:not(:first-child) {
  border-top: 1px solid var(--color-border);
}

.widget-list__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.widget-list__label {
  font-size: var(--font-size-medium);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-list__meta {
  font-size: var(--font-size-small);
  color: var(--color-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-list__aside {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.widget-due {
  font-size: var(--font-size-small);
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.widget-due--overdue {
  color: var(--color-danger);
}

/* == inline meta pills (business projects/tasks/checklists) == */
.widget-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.widget-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-small);
  color: var(--color-secondary-dark);
  background-color: var(--color-surface-sunken);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
}

.widget-pill__icon {
  color: var(--color-text-muted);
}

/* == section sub-label inside a large widget == */
.widget-section-label {
  font-size: var(--font-size-small);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--label-letter-spacing);
  color: var(--color-text-muted);
}

/* == empty states == */
.widget-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-3);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--font-size-small);
}

.widget-empty--inline {
  padding: var(--space-4) var(--space-3);
}

.widget-empty__icon {
  width: 22px;
  height: 22px;
  opacity: 0.6;
}

/* == states == */
.dashboard-widget--dragging {
  opacity: 0.5;
  box-shadow: var(--shadow-md);
}

.dashboard-home--editing .dashboard-widget {
  cursor: grab;
  border-style: dashed;
}

.dashboard-home--editing .dashboard-widget__sizes {
  display: inline-flex;
}

.dashboard-home--editing .dashboard-widget__drag,
.dashboard-home--editing .dashboard-widget__remove {
  display: inline-flex;
}

.dashboard-home--editing .dashboard-widget__open {
  display: none;
}

/* == "Assigned to me": three kinds of record in one table == */
.assigned-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-x: auto;
}

.assigned-list__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-small);
}

.assigned-list__table th {
  text-align: left;
  padding: 0 var(--space-2) var(--space-2);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--label-letter-spacing);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.assigned-list__table td {
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-text);
}

.assigned-list__table tr:last-child td {
  border-bottom: none;
}

.assigned-list__link {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
}

.assigned-list__link:hover {
  text-decoration: underline;
}

/* Which of the three kinds of record the row is, set under its name so the
   first column reads as one thing rather than two. */
.assigned-list__type {
  display: block;
  color: var(--color-text-muted);
  font-size: 11px;
}

/* "+2", where a task names more than one firm or client. */
.assigned-list__extra {
  color: var(--color-text-muted);
}

.assigned-list__more {
  margin: 0;
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
}
