/* Vivo Payroll -- built on the Forma design system tokens (tokens.css).
   Plain CSS/HTML implementation of the Forma component specs (no React/
   Tailwind build step here), scoped to what an internal payroll admin tool
   actually needs: app shell, buttons, cards, badges, forms, tables, KPI
   cards, status banners. */

/* ---------- Layout: app shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: var(--border-width) solid var(--border-default);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-3);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-6);
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: var(--text-h3);
  color: var(--text-primary);
}

.sidebar-brand-mark {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--action-primary);
  display: inline-block;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-label);
  font-weight: var(--weight-medium);
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background-color var(--duration-fast) var(--ease-standard);
}

.sidebar-item:hover {
  background: var(--bg-hover);
}

.sidebar-item.is-active {
  background: var(--bg-selected);
  color: var(--verde-700);
  box-shadow: inset 2px 0 0 var(--verde-600);
}

.sidebar-item .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: var(--border-width) solid var(--border-subtle);
  padding-top: var(--space-3);
  margin-top: var(--space-3);
}

.sidebar-logout {
  color: var(--text-secondary);
}

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

.topbar {
  height: var(--topbar-height);
  border-bottom: var(--border-width) solid var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  background: var(--bg-surface);
}

.topbar-title {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: var(--text-body);
  color: var(--text-secondary);
}

.content {
  padding: var(--space-6);
  max-width: var(--container-app);
  width: 100%;
  margin: 0 auto;
}

/* ---------- Typography ---------- */

h1 {
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin: 0 0 var(--space-1);
}

h2 {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin: var(--space-8) 0 var(--space-4);
}

h3 {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--space-4);
}

.subtitle {
  color: var(--text-secondary);
  font-size: var(--text-body);
  margin: 0 0 var(--space-6);
  max-width: var(--container-prose);
}

a {
  color: var(--text-link);
}
a:hover {
  color: var(--text-link-hover);
}

/* ---------- Steps (wizard progress) ---------- */

.steps {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.steps span,
.steps a {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--bg-sunken);
  color: var(--text-secondary);
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  text-decoration: none;
}

.steps a:hover {
  background: var(--border-default);
  color: var(--text-primary);
}

.steps span.active {
  background: var(--action-primary);
  color: var(--action-primary-text);
}

/* ---------- Cards ---------- */

.card {
  background: var(--bg-surface);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
}

.card.dense {
  padding: var(--space-5);
}

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

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--bg-surface);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: var(--space-5);
}

.kpi-label {
  font-size: var(--text-overline);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-secondary);
  margin: 0;
}

.kpi-tick {
  width: 24px;
  height: 2px;
  background: var(--brass-400);
  margin-top: var(--space-2);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: var(--text-kpi);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin: var(--space-3) 0 0;
  font-variant-numeric: tabular-nums;
}

.kpi-value.emphasis {
  color: var(--verde-700);
}

.kpi-delta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: var(--space-2) 0 0;
  font-size: var(--text-body-sm);
  font-weight: var(--weight-medium);
}

.kpi-delta svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.kpi-delta.good { color: var(--status-success-text); }
.kpi-delta.bad { color: var(--status-error-text); }

.kpi-delta-label {
  font-weight: var(--weight-regular);
  color: var(--text-secondary);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: var(--weight-medium);
  font-size: 14px;
  border: var(--border-width) solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
  white-space: nowrap;
}

.btn:disabled {
  cursor: not-allowed;
  background: var(--bg-disabled) !important;
  color: var(--text-disabled) !important;
  border-color: transparent !important;
}

/* primary is the default unmarked .btn */
.btn, .btn.primary {
  background: var(--action-primary);
  color: var(--action-primary-text);
}
.btn:not(.secondary):not(.tertiary):not(.text):not(.danger):not(.danger-subtle):hover {
  background: var(--action-primary-hover);
}
.btn:not(.secondary):not(.tertiary):not(.text):not(.danger):not(.danger-subtle):active {
  background: var(--action-primary-active);
}

.btn.secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn.secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.btn.secondary:active {
  background: var(--bg-active);
}

.btn.tertiary {
  background: transparent;
  color: var(--text-primary);
}
.btn.tertiary:hover {
  background: var(--bg-hover);
}

.btn.text {
  background: transparent;
  color: var(--text-link);
  height: auto;
  padding: 0;
}
.btn.text:hover {
  text-decoration: underline;
}

.btn.danger {
  background: var(--red-500);
  color: #fff;
}
.btn.danger:hover {
  background: #A83329;
}
.btn.danger:active {
  background: #8C2B22;
}

.btn.danger-subtle {
  background: var(--bg-surface);
  color: var(--status-error-text);
  border-color: var(--border-default);
}
.btn.danger-subtle:hover {
  background: var(--status-error-bg);
}

.btn.sm {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-body-sm);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* ---------- Forms ---------- */

label, .field-label {
  display: block;
  font-size: var(--text-label);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin: var(--space-4) 0 var(--space-1);
}

input[type=text], input[type=number], input[type=date], input[type=password], input[type=file], select, textarea {
  height: 36px;
  width: 100%;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-body);
  transition: border-color var(--duration-fast) var(--ease-standard);
}

input[type=file] {
  height: auto;
  padding: var(--space-2) var(--space-3);
}

textarea {
  height: auto;
  min-height: 88px;
  padding: var(--space-2) var(--space-3);
  resize: vertical;
}

input:hover, select:hover, textarea:hover {
  border-color: var(--border-strong);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

input::placeholder {
  color: var(--text-disabled);
}

input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--verde-600);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.badge.neutral { background: var(--neutral-100); color: var(--neutral-700); }
.badge.success { background: var(--status-success-bg); color: var(--status-success-text); }
.badge.warning { background: var(--status-warning-bg); color: var(--status-warning-text); }
.badge.error   { background: var(--status-error-bg); color: var(--status-error-text); }
.badge.info    { background: var(--status-info-bg); color: var(--status-info-text); }
.badge.brass   { background: var(--brass-100); color: var(--brass-700); }

/* ---------- Tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
  background: var(--bg-surface);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

thead tr {
  background: var(--bg-sunken);
  border-bottom: var(--border-width-strong) solid var(--border-strong);
}

th {
  text-align: left;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-overline);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-secondary);
  height: 40px;
}

tbody tr {
  border-bottom: var(--border-width) solid var(--border-subtle);
  transition: background-color var(--duration-fast) var(--ease-standard);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-hover);
}

td {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-body-sm);
  color: var(--text-primary);
  height: 44px;
}

td.numeric, th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tr.dept-header td {
  background: var(--bg-selected);
  font-weight: var(--weight-semibold);
  color: var(--verde-700);
}

tr.dept-total td {
  background: var(--bg-sunken);
  font-weight: var(--weight-semibold);
}

tr.summary td {
  background: var(--bg-selected);
  font-weight: var(--weight-semibold);
}

/* ---------- Status banners ---------- */

.banner, .flag, .error {
  display: block;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-body-sm);
  margin-bottom: var(--space-3);
}

.flag {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
}

.error {
  background: var(--status-error-bg);
  color: var(--status-error-text);
}

/* ---------- Location tiles (dashboard) ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}

.location-tile {
  display: block;
  padding: var(--space-5);
  background: var(--bg-surface);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}

.location-tile:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.location-tile .name {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: var(--text-h3);
}

.location-tile .meta {
  color: var(--text-secondary);
  font-size: var(--text-body-sm);
  margin-top: var(--space-1);
}

/* ---------- Utility ---------- */

form.inline {
  display: inline;
}

.numeric {
  font-variant-numeric: tabular-nums;
}
