/* ═══════════════════════════════════════
   Worker Dashboard — Design System 2.0
   ═══════════════════════════════════════ */

/* ── Worker layout — no bottom nav, no content-in (breaks fixed FAB) ── */
.worker-layout .main-content {
  padding-bottom: calc(var(--space-2xl) + env(safe-area-inset-bottom, 0px));
  animation: none;
  overflow-x: clip;
}

.worker-layout .nav-overflow__panel {
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
}

/* Flash: override dashboard positioning (no sidebar, above FAB) */
.worker-layout #flash {
  position: fixed;
  top: auto;
  left: var(--space-md);
  right: var(--space-md);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 56px + var(--space-lg) + var(--space-sm));
  transform: none;
  max-width: none;
  z-index: calc(var(--z-sticky) + 5);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: auto;
}

/* ── Worker header — company branding bar + menu ── */
.worker-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xs) var(--space-sm) var(--space-lg);
  padding-top: calc(var(--space-sm) + env(safe-area-inset-top, 0px));
  min-height: var(--mobile-header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.worker-header__name {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.worker-header__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition-fast);
  animation: menu-shimmer 4s ease-in-out infinite;
}

[data-theme="light"] .worker-header__menu {
  animation-name: menu-shimmer-light;
}

.worker-header__menu:hover,
.worker-header__menu:active {
  background: var(--surface-2);
  color: var(--text);
}

/* ── Expandable FAB menu ── */
/* ── FAB backdrop ── */
.fab-menu__backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-fab) - 1);
  background: rgba(0, 0, 0, 0);
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
  pointer-events: none;
  transition:
    background 0.3s ease,
    backdrop-filter 0.3s ease,
    -webkit-backdrop-filter 0.3s ease;
}

.fab-menu--open .fab-menu__backdrop {
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

/* ── FAB container ── */
.fab-menu {
  position: fixed;
  bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
  right: var(--space-lg);
  z-index: var(--z-fab);
  width: 60px;
  height: 60px;
  overflow: visible;
}

/* ── Trigger button ── */
.fab-menu__trigger {
  position: relative;
  z-index: 1;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(124, 58, 237, 0.5);
  border: none;
  cursor: pointer;
  transition:
    transform 0.25s var(--ease-spring),
    box-shadow 0.2s ease;
}

.fab-menu--open .fab-menu__trigger {
  transform: scale(1.1);
  box-shadow: 0 6px 32px rgba(124, 58, 237, 0.7);
}

.fab-menu--locked .fab-menu__trigger {
  cursor: not-allowed;
  opacity: 0.6;
}

/* ── Action list — absolute, radiates around trigger ── */
.fab-menu__actions {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.fab-menu--open .fab-menu__actions {
  pointer-events: auto;
}

/* Each action: btn only is absolutely positioned, label floats separately */
.fab-menu__action {
  position: absolute;
  bottom: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  opacity: 0;
  transform: scale(0.4);
  transition:
    opacity 0.3s ease,
    transform 0.3s var(--ease-spring);
  pointer-events: none;
}

/* R=90px circle — action 1 at 90° (straight up), action 2 at 150° (upper-left) */
.fab-menu--open .fab-menu__action:nth-child(1) {
  opacity: 1;
  transform: translate(0px, -100px) scale(1);
  transition-delay: 0.05s;
  pointer-events: auto;
}

.fab-menu--open .fab-menu__action:nth-child(2) {
  opacity: 1;
  transform: translate(-78px, -45px) scale(1);
  transition-delay: 0.0s;
  pointer-events: auto;
}

/* ── Action button — purple, white icon ── */
.fab-menu__action-btn {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.45);
  flex-shrink: 0;
  transition: transform 0.15s var(--ease-spring);
}

.fab-menu__action:active .fab-menu__action-btn {
  transform: scale(0.9);
}

/* ── Label pill ── */
.fab-menu__label {
  order: -1;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: white;
  background: rgba(30, 20, 50, 0.85);
  border: 1px solid rgba(167, 139, 250, 0.25);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* ── FAB icon rotation on expand ── */
.fab__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s var(--ease-spring);
}

.fab__icon--open {
  transform: rotate(45deg);
}

/* ── Worker tabs — week / month toggle ── */
.worker-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-md);
}

.worker-tabs__tab {
  flex: 1;
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  text-align: center;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.worker-tabs__tab:hover {
  color: var(--text);
}

.worker-tabs__tab--active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: var(--font-semibold);
}

.worker-tabs__panel {
  animation: fade-up 0.2s var(--ease-out);
}

/* ── Section header ── */
.worker-section {
  margin-bottom: var(--space-2xl);
}

.worker-section__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.worker-section__title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.worker-section__count {
  font-size: var(--text-2xs);
  font-weight: var(--font-bold);
  background: var(--surface-3);
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Timesheet row — compact inline card ── */
.worker-ts {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 var(--space-md);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-sm);
  border-left: 3px solid var(--border);
  transition: background var(--transition-fast);
}

.worker-ts__left {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.worker-ts__project {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text);
  margin-bottom: var(--space-2xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.worker-ts__time {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.worker-ts__icon {
  flex-shrink: 0;
  opacity: 0.5;
}

.worker-ts__sep {
  opacity: 0.4;
}

.worker-ts__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
  max-width: calc(100% - 3rem);
}

.worker-ts__badges:empty {
  display: none;
}

.worker-ts__comment {
  margin-top: var(--space-2xs, 2px);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
  line-height: var(--leading-snug);
}

.worker-ts__right {
  grid-column: 2;
  grid-row: 1;
  text-align: right;
}

.worker-ts__hours {
  font-size: var(--text-xl);
  font-weight: var(--font-extrabold);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tighter);
}

/* Actions row */
.worker-ts__actions {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  gap: var(--space-sm);
  padding-top: var(--space-sm);
  margin-top: var(--space-sm);
  border-top: 1px solid var(--border-subtle);
}

.worker-ts__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.worker-ts__action:hover {
  background: var(--surface-2);
  color: var(--text);
}

.worker-ts__action--danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* button_to wraps in a form — reset it */
.worker-ts__actions form {
  display: contents;
}

/* ── Empty state ── */
.worker-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-4xl) var(--space-lg);
}

.worker-empty__icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  color: var(--text-faint);
}

.worker-empty__text {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

/* ── Compact greeting page-header for "mes heures" index views ── */
.worker-layout .page-header,
.my-hours .page-header {
  min-height: auto;
  padding: var(--space-xs) var(--space-lg) var(--space-sm);
  margin: 0 calc(-1 * var(--space-md));
  border-bottom: 1px solid var(--border-subtle);
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
  top: 0;
}

.worker-layout .page-header:has(.page-header__back),
.my-hours .page-header:has(.page-header__back) {
  justify-content: flex-end;
}

.worker-layout .page-header__back,
.my-hours .page-header__back {
  position: absolute;
  left: var(--space-md);
}

.worker-layout .page-header h1,
.my-hours .page-header h1 {
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-snug);
}

.worker-layout .page-header .text--muted,
.my-hours .page-header .text--muted {
  font-size: var(--text-xs);
  color: var(--text-faint);
}

/* ── Worker page-header sticky on mobile (form pages: new/edit) ── */
@media (max-width: 768px) {
  .worker-layout .page-header--sticky {
    position: sticky;
    top: var(--mobile-header-h);
    z-index: var(--z-dropdown);
    background: var(--glass);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    backdrop-filter: blur(16px) saturate(150%);
    margin: 0 calc(-1 * var(--space-md)) var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    transition: box-shadow var(--transition-base);
  }

  .worker-layout .main-content {
    padding: var(--space-md);
    padding-top: 0;
    padding-bottom: calc(var(--space-2xl) + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .worker-hero__greeting {
    font-size: var(--text-xl);
  }

  .worker-ts,
  .purchase-doc-card {
    padding: var(--space-sm) var(--space-md);
  }

  .worker-ts__hours {
    font-size: var(--text-lg);
  }

  /* ── Compact form for mobile (worker + boss/staff "mes heures" forms) ── */
  .my-hours-form .page-header {
    min-height: auto;
    padding: var(--space-sm) var(--space-lg);
    margin-bottom: var(--space-sm);
    align-items: center;
  }

  .my-hours-form .page-header__back {
    flex-basis: auto;
    margin-bottom: 0;
  }

  .my-hours-form .page-header h1 {
    font-size: var(--text-base);
    line-height: var(--leading-tight);
  }

  .my-hours-form .page-header .text--muted {
    font-size: var(--text-xs);
  }

  .worker-layout .form-card,
  .my-hours-form .form-card {
    padding-top: var(--space-sm);
  }

  .worker-layout .form-group,
  .my-hours-form .form-group {
    margin-bottom: var(--space-md);
  }

  /* Time fields stack vertically on mobile (default 1fr from _forms.css) */

  .worker-layout .hours-preview,
  .my-hours-form .hours-preview {
    font-size: var(--text-xl);
    padding: var(--space-xs) var(--space-sm);
  }

  /* Hide redundant date text and cancel button */
  .worker-layout .form-card > form > .text--muted.mb-md,
  .my-hours-form .form-card > form > .text--muted.mb-md {
    display: none;
  }

  .worker-layout .form-actions .btn--ghost,
  .my-hours-form .form-actions .btn--ghost {
    display: none;
  }

  .worker-layout .form-actions,
  .my-hours-form .form-actions {
    padding: var(--space-sm) var(--space-lg);
    padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
    margin-top: var(--space-sm);
  }

  .worker-layout .form-select,
  .my-hours-form .form-select {
    min-height: 44px;
  }

  .worker-layout .time-select .form-select,
  .my-hours-form .time-select .form-select {
    padding-right: var(--space-lg);
    background-position: right var(--space-xs) center;
  }
}

/* ── Day detail tabs ── */
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-md);
}

.detail-tabs__tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.detail-tabs__tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.detail-tabs__count {
  font-size: var(--text-2xs);
  background: var(--surface-3);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
}

.detail-tabs__tab--active .detail-tabs__count {
  background: var(--accent-muted);
  color: var(--accent);
}

/* ── Purchase document cards ── */
.purchase-docs-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* ── Purchase document row — mirrors worker-ts card ── */
.purchase-doc-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-sm);
  border-left: 3px solid var(--border);
  transition: background var(--transition-fast);
}

.purchase-doc-card__row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

.purchase-doc-card__row + .purchase-doc-card__row {
  margin-top: 2px;
}

.purchase-doc-card__supplier {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.purchase-doc-card__badge {
  margin-left: auto;
  flex-shrink: 0;
}

.purchase-doc-card__reference {
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.purchase-doc-card__project {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--text-muted);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.purchase-doc-card__icon {
  flex-shrink: 0;
  opacity: 0.5;
}

.purchase-doc-card__amount {
  margin-left: auto;
  font-size: var(--text-lg);
  font-weight: var(--font-extrabold);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.purchase-doc-card__comment {
  font-size: var(--text-sm);
  color: var(--text-faint);
  margin-top: var(--space-2xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Actions row */
.purchase-doc-card__actions {
  grid-column: 1 / -1;
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

.purchase-doc-card__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.purchase-doc-card__action:hover {
  background: var(--surface-2);
  color: var(--text);
}

.purchase-doc-card__action--danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* button_to wraps in a form — reset it */
.purchase-doc-card__actions form {
  display: contents;
}

/* ── "Mes heures" — boss/staff personal timesheet view ── */
.main-content:has(.my-hours) {
  animation: none;
}

.my-hours .fab-menu {
  bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
}

/* ── Light theme overrides ── */
[data-theme="light"] .worker-ts,
[data-theme="light"] .purchase-doc-card {
  border-left-color: var(--border);
}

