/* MRP Shifts — timesheet submission.
   Visual language carried over from the Shiny app: cards with coloured
   headers, the #2C51F7 brand blue, and a light blue-grey page. Candidates
   mostly submit from a phone, so every layout starts single-column and only
   spreads out when there is room. */

:root {
  --brand: #2c51f7;
  --brand-dark: #1e3ad1;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #dbe4f0;
  --line-soft: #e8eef5;
  --panel: #f8fbff;
  --page: #eef2fb;
  --success: #1f9d63;
  --danger: #d92d20;
  --warning: #b45309;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* The app toggles visibility with the `hidden` attribute, and several of those
   elements also carry a `display` rule below. A class selector beats the user
   agent's [hidden] rule, so state this explicitly or the modal and the loading
   spinner would both be visible on load. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

/* ---------- header ---------- */

.app-header {
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.brand__logo {
  display: block;
  height: 26px;
  width: auto;
}

.brand__name {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand__name b {
  color: #93a9ff;
}

.brand__candidate {
  font-weight: 600;
  font-size: 0.95rem;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- layout ---------- */

.app-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 4rem 1rem;
  color: var(--muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

/* ---------- cards ---------- */

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  border-top: 4px solid var(--brand);
}

.card--success .card__header { border-top-color: var(--success); }
.card--primary .card__header { border-top-color: var(--brand); }
.card--info .card__header { border-top-color: #0ea5e9; }
.card--danger .card__header { border-top-color: var(--danger); }

.card__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.card__badge {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}

.card__body {
  padding: 1.1rem;
}

.card__body--flush {
  padding: 0;
}

.access__heading {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.access__message {
  margin: 0;
  color: var(--ink-soft);
}

/* ---------- fields ---------- */

.details-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .details-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field__sublabel {
  font-size: 0.78rem;
  color: var(--muted);
}

.field__control {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  min-height: 44px;
}

.field__control:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.field__control--stacked {
  margin-top: 0.35rem;
}

.field__extra {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.field__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.2em;
}

/* ---------- shift rows ---------- */

.rows {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.row {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 0.85rem;
}

.row--overlap {
  border-color: #f0b3ae;
  border-left-color: var(--danger);
  background: #fff6f5;
}

.row--unsaved {
  border-left-color: var(--brand);
}

.row__grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr 1fr;
  align-items: end;
}

/* Notes and the date each need more room than a time box. */
.row__cell--date { grid-column: 1 / -1; }
.row__cell--notes { grid-column: 1 / -1; }
.row__cell--meta {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

@media (min-width: 860px) {
  .row__grid {
    grid-template-columns: minmax(160px, 1.5fr) 116px 116px 116px minmax(150px, 1.8fr) auto;
  }

  .row__cell--date,
  .row__cell--notes,
  .row__cell--meta {
    grid-column: auto;
  }

  .row__cell--meta {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
  }
}

.row__day {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--brand-dark);
  margin-bottom: 0.2rem;
}

.row__hours {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  white-space: nowrap;
}

.row__hours--empty {
  color: var(--muted);
  font-weight: 500;
}

.row__warning {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px dashed #f0b3ae;
  font-size: 0.85rem;
  color: #a4231b;
}

.rows__empty {
  padding: 1rem 0;
  color: var(--muted);
}

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.6rem 1.1rem;
  min-height: 44px;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  transition: background-color 120ms ease, border-color 120ms ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { background: var(--brand-dark); }

.btn--secondary {
  background: #eaefff;
  border-color: #c3d0ff;
  color: var(--brand-dark);
}

.btn--secondary:hover:not(:disabled) { background: #dde5ff; }

.btn--ghost {
  border-color: #cbd5e1;
  color: var(--ink-soft);
}

.btn--ghost:hover:not(:disabled) { background: #f1f5f9; }

.btn--icon {
  min-height: 40px;
  padding: 0.4rem 0.7rem;
  border-color: #f0b3ae;
  color: var(--danger);
  background: #fff;
  font-size: 0.85rem;
}

.btn--icon:hover:not(:disabled) { background: #fff1f0; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-soft);
}

.total {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.total strong {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.total--empty {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- tables ---------- */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 640px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

.data-table th {
  background: var(--panel);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-bottom: 2px solid var(--line);
}

.data-table td:last-child,
.data-table th:last-child {
  white-space: normal;
}

.data-table tbody tr:nth-child(even) {
  background: var(--panel);
}

.data-table__empty {
  color: var(--muted);
  font-style: italic;
}

.data-table__id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

.data-table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 720px) {
  .modal {
    align-items: center;
    padding: 1.5rem;
  }
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal__panel {
  position: relative;
  background: #fff;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 780px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}

@media (min-width: 720px) {
  .modal__panel { border-radius: 16px; }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.modal__title {
  margin: 0;
  font-size: 1.1rem;
}

.modal__close {
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.3rem;
}

.modal__body {
  padding: 1.1rem;
  overflow-y: auto;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.confirm-summary {
  padding: 0.9rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: linear-gradient(135deg, #eff6ff, #ffffff);
  margin-bottom: 0.9rem;
}

.confirm-summary__lead {
  margin: 0 0 0.4rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.confirm-summary__facts {
  display: grid;
  gap: 0.2rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.confirm-note {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(560px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  border-left: 5px solid var(--brand);
  animation: toast-in 160ms ease-out;
}

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

.toast--success { border-left-color: #3ddc97; }
.toast--error { border-left-color: #ff6b6b; }
.toast--warning { border-left-color: #fbbf24; }
.toast--info { border-left-color: #60a5fa; }

.toast__title {
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.toast__message {
  font-size: 0.92rem;
  color: #e2e8f0;
}
