/* components.css — Tables, cards, badges, forms, modals */

/* ---------- Brand wordmark ---------- */
.logo {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}
.logo__mark,
.logo__name { color: var(--brand-blue); }
.logo__tech { color: var(--brand-accent); }
.logo__mark { margin-right: 1px; }

/* On dark backgrounds (e.g. sidebar) */
.logo--light .logo__mark,
.logo--light .logo__name { color: var(--white); }
.logo--light .logo__tech { color: var(--brand-accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-700);
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--gray-50); text-decoration: none; }

.btn--primary {
  background: var(--brand-accent);
  border-color: var(--brand-accent);
  color: var(--white);
}
.btn--primary:hover { background: #1869a8; }

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--brand-accent);
}
.btn--ghost:hover { background: var(--brand-accent-light); }

.btn--danger {
  background: var(--white);
  border-color: var(--danger);
  color: var(--danger);
}
.btn--danger:hover { background: var(--danger-bg); }

.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card__header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card__title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--gray-700);
  margin: 0;
}
.card__body { padding: 16px; }
.card__body + .card__body { border-top: 1px solid var(--gray-100); }

/* ---------- Metric cards ---------- */
.metric {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.12s, transform 0.12s, border-color 0.12s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.metric:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  border-color: var(--brand-accent);
}
.metric__label {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.metric__value {
  font-size: 30px;
  font-weight: 800;
  color: var(--brand-blue);
  line-height: 1;
}
.metric__hint { font-size: 11px; color: var(--gray-500); }
.metric--alert .metric__value { color: var(--danger); }
.metric--warn .metric__value { color: var(--warning); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger); }
.badge--info    { background: var(--info-bg);    color: var(--info); }
.badge--neutral { background: var(--gray-100);   color: var(--gray-700); }

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  font-size: 13px;
}
.table th {
  text-align: left;
  padding: 11px 14px;
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.table th.sortable {
  cursor: pointer;
  user-select: none;
}
.table th.sortable:hover { color: var(--gray-700); }
.table th.sortable::after {
  content: ' ⇅';
  opacity: 0.35;
  font-size: 10px;
}
.table th.sort-asc::after  { content: ' ↑'; opacity: 1; color: var(--brand-accent); }
.table th.sort-desc::after { content: ' ↓'; opacity: 1; color: var(--brand-accent); }
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover { background: var(--brand-accent-light); }
.table__empty {
  padding: 40px;
  text-align: center;
  color: var(--gray-500);
}
.table .wo-id { font-weight: 700; color: var(--brand-accent); }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 18px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field--full { grid-column: 1 / -1; }
.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
}
.field__label .req { color: var(--danger); }
.field__hint { font-size: 11px; color: var(--gray-500); }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(30, 127, 203, 0.12);
}
.textarea { resize: vertical; min-height: 80px; }
.input:disabled { background: var(--gray-50); color: var(--gray-500); }

.form-section { margin-bottom: 22px; }
.form-section__title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--brand-accent);
  border-bottom: 1px solid var(--gray-100);
  padding-bottom: 6px;
  margin-bottom: 14px;
}
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.filter-bar .field { min-width: 130px; flex: 1 1 130px; }
.filter-bar .field--search { flex: 2 1 220px; }

/* ---------- Login card ---------- */
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  padding: 36px 34px;
}
.login-card__brand {
  text-align: center;
  margin-bottom: 26px;
}
.login-card__brand-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--brand-blue);
}
.login-card__brand-sub {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-500);
  margin-top: 4px;
}
.login-card .field { margin-bottom: 14px; }

/* ---------- Modal / slide-in panel ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 43, 91, 0.45);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: 480px;
  max-width: 100%;
  background: var(--white);
  height: 100%;
  overflow-y: auto;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
  animation: slide-in 0.2s ease;
  display: flex;
  flex-direction: column;
}
@keyframes slide-in { from { transform: translateX(40px); } to { transform: translateX(0); } }

.panel__header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--white);
}
.panel__title { margin: 0; }
.panel__close {
  border: none;
  background: none;
  font-size: 22px;
  color: var(--gray-500);
  line-height: 1;
  padding: 2px 6px;
}
.panel__close:hover { color: var(--gray-900); }
.panel__body { padding: 22px; flex: 1; }
.panel__footer {
  padding: 16px 22px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: var(--white);
}

/* ---------- Stage stepper ---------- */
.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}
.stepper__item {
  flex: 1 1 0;
  min-width: 70px;
  text-align: center;
  position: relative;
  padding-top: 18px;
  font-size: 10px;
  color: var(--gray-500);
  line-height: 1.25;
}
.stepper__item::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gray-200);
}
.stepper__item:first-child::before { left: 50%; }
.stepper__item:last-child::before { right: 50%; }
.stepper__dot {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gray-200);
  border: 2px solid var(--white);
  z-index: 1;
}
.stepper__item.is-done::before { background: var(--brand-accent); }
.stepper__item.is-done .stepper__dot { background: var(--brand-accent); }
.stepper__item.is-current .stepper__dot {
  background: var(--brand-accent);
  box-shadow: 0 0 0 4px var(--brand-accent-light);
}
.stepper__item.is-current { color: var(--brand-blue); font-weight: 700; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__item {
  position: relative;
  padding: 0 0 18px 22px;
  border-left: 2px solid var(--gray-200);
}
.timeline__item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline__item::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand-accent);
  border: 2px solid var(--white);
}
.timeline__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.timeline__author { font-weight: 700; }
.timeline__time { font-size: 11px; color: var(--gray-500); }
.timeline__note { margin: 4px 0; }
.timeline__customer {
  background: var(--brand-accent-light);
  border-left: 3px solid var(--brand-accent);
  padding: 8px 10px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12px;
  margin: 6px 0;
}
.timeline__next {
  font-size: 12px;
  color: var(--gray-700);
  margin-top: 4px;
}

/* ---------- Detail bits ---------- */
.kv { display: flex; flex-direction: column; gap: 10px; }
.kv__row { display: flex; justify-content: space-between; gap: 12px; }
.kv__key { color: var(--gray-500); font-size: 12px; }
.kv__val { font-weight: 600; text-align: right; }

.detail-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  background: var(--brand-accent-light);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}
.detail-hero__block { display: flex; flex-direction: column; gap: 2px; }
.detail-hero__label { font-size: 11px; text-transform: uppercase; color: var(--gray-500); letter-spacing: 0.3px; }
.detail-hero__value { font-weight: 700; font-size: 14px; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--gray-500);
  font-weight: 700;
  margin: 0 0 8px;
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--gray-900);
  color: var(--white);
  padding: 11px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }
.toast--info { background: var(--brand-accent); }

/* ---------- Dashboard split (reminders + SLA rules) ---------- */
.dash-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}
@media (max-width: 900px) {
  .dash-split { grid-template-columns: 1fr; }
}

.reminder {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.reminder:last-child { margin-bottom: 0; }
.reminder.is-clickable { cursor: pointer; }
.reminder.is-clickable:hover { background: var(--brand-accent-light); }
.reminder__when {
  flex: 0 0 70px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
}
.reminder__when--overdue { color: var(--danger); }
.reminder__body { flex: 1; }
.reminder__title { font-weight: 700; font-size: 13px; }
.reminder__sub { font-size: 11px; color: var(--gray-500); }

.sla-rule-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.sla-rule {
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.sla-rule__dsp { font-weight: 700; font-size: 12px; color: var(--gray-700); }
.sla-rule__weeks { font-size: 26px; font-weight: 800; color: var(--brand-accent); line-height: 1.1; }
.sla-rule__unit { font-size: 11px; color: var(--gray-500); }
.sla-rule-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--warning);
  background: var(--warning-bg);
  border-radius: var(--radius);
  padding: 10px 12px;
}

/* ---------- Site access team ---------- */
.access-person {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
@media (max-width: 800px) {
  .access-person { grid-template-columns: 1fr 1fr; }
}
.access-person__label { font-size: 11px; color: var(--gray-500); }
.access-person__value { font-weight: 600; }

/* ---------- Email draft ---------- */
.email-toggle { display: flex; gap: 8px; margin-bottom: 14px; }
.email-frame {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.email-frame__head {
  background: var(--gray-50);
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.email-frame__row { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 10px; }
.email-frame__row label { font-size: 12px; color: var(--gray-500); }
.email-frame__body {
  width: 100%;
  border: none;
  padding: 16px;
  min-height: 320px;
  resize: vertical;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
  outline: none;
}
.email-frame__foot {
  background: var(--gray-50);
  padding: 12px 14px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
}

/* ---------- Misc ---------- */
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.priority-high { color: var(--warning); font-weight: 700; }
.priority-critical { color: var(--danger); font-weight: 700; }
.priority-medium { color: var(--gray-700); }
.priority-low { color: var(--gray-500); }
