/* =============================================================================
   TruckerProfit CRM — Components
   Buttons, inputs, cards, badges, tables, modals, toasts, dropdowns,
   sidebar nav, KPI cards, breadcrumbs.
   ============================================================================= */

/* ---------- Typography helpers ---------- */
.t-display {
  font-family: var(--font-display);
  font-weight: var(--fw-display-black);
  letter-spacing: var(--ls-display);
  line-height: var(--lh-tight);
}
.t-display-light {
  font-family: var(--font-display);
  font-weight: var(--fw-display-light);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-snug);
}
.t-mono {
  font-family: var(--font-mono);
  letter-spacing: var(--ls-mono);
}
.t-eyebrow {
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: var(--fs-12);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--text-muted);
}
.t-muted { color: var(--text-muted); }
.t-secondary { color: var(--text-secondary); }
.t-gold { color: var(--gold); }

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); }
h1 { font-size: var(--fs-56); font-weight: var(--fw-display-black); letter-spacing: var(--ls-display); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-40); font-weight: var(--fw-display-bold); letter-spacing: var(--ls-display); line-height: var(--lh-tight); }
h3 { font-size: var(--fs-24); font-weight: var(--fw-display-bold); letter-spacing: var(--ls-tight); line-height: var(--lh-snug); }
h4 { font-size: var(--fs-18); font-weight: var(--fw-display-bold); letter-spacing: var(--ls-tight); line-height: var(--lh-snug); }
p { margin: 0; }

@media (max-width: 767px) {
  h1 { font-size: var(--fs-40); }
  h2 { font-size: var(--fs-32); }
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-8);
  min-height: 48px;
  padding: 0 var(--sp-24);
  font-family: var(--font-body);
  font-size: var(--fs-15);
  font-weight: var(--fw-medium);
  letter-spacing: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
  text-decoration: none;
  background: transparent;
  color: var(--text-primary);
  white-space: nowrap;
}

.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5; cursor: not-allowed; pointer-events: none;
}

.btn--primary {
  background: var(--gold);
  color: var(--text-on-gold);
  font-weight: var(--fw-bold);
}
.btn--primary:hover { background: var(--gold-soft); box-shadow: var(--shadow-gold); color: var(--text-on-gold); }

.btn--secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--bg-hover); border-color: var(--gold); }

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

.btn--danger {
  background: var(--danger);
  color: #fff;
}
.btn--danger:hover { filter: brightness(1.1); color: #fff; }

.btn--sm { min-height: 36px; padding: 0 var(--sp-16); font-size: var(--fs-13); }
.btn--icon {
  min-height: 44px;
  min-width: 44px;
  padding: 0;
}

/* ---------- Icons ---------- */
.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }

/* ---------- Inputs ---------- */
.input, .textarea, .select {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--sp-16);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-15);
  transition: border-color var(--dur-base), background var(--dur-base);
}
.input::placeholder { color: var(--text-muted); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--bg-elevated);
}
.textarea { min-height: 120px; padding-block: var(--sp-12); resize: vertical; }

.field { display: flex; flex-direction: column; gap: var(--sp-8); }
.field label {
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-32);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
}
.card--hoverable:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
}
.card--elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}
.card--accent {
  border-color: rgba(212, 168, 75, 0.32);
  background: linear-gradient(180deg, rgba(212, 168, 75, 0.06), transparent 70%), var(--bg-surface);
}

@media (max-width: 767px) {
  .card { padding: var(--sp-24); }
}

/* ---------- KPI cards ---------- */
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-24);
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur-base), transform var(--dur-base), box-shadow var(--dur-base);
}
.kpi::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), transparent 70%);
  opacity: 0.6;
}
.kpi:hover {
  border-color: var(--border-default);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi__label {
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}
.kpi__value {
  font-family: var(--font-mono);
  font-size: var(--fs-40);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  letter-spacing: var(--ls-mono);
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
}
.kpi__unit {
  font-family: var(--font-body);
  font-size: var(--fs-16);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
}
.kpi__delta {
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
}
.kpi__delta--up { color: var(--success); }
.kpi__delta--down { color: var(--danger); }
.kpi__delta--flat { color: var(--text-muted); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 4px var(--sp-12);
  font-family: var(--font-body);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  border-radius: var(--radius-pill);
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  line-height: 1.3;
}
.badge--gold {
  background: rgba(212, 168, 75, 0.12);
  color: var(--gold);
  border-color: rgba(212, 168, 75, 0.32);
}
.badge--success {
  background: rgba(0, 208, 132, 0.12);
  color: var(--success);
  border-color: rgba(0, 208, 132, 0.32);
}
.badge--danger {
  background: rgba(229, 72, 77, 0.12);
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.32);
}
.badge--info {
  background: rgba(77, 163, 255, 0.12);
  color: var(--electric);
  border-color: rgba(77, 163, 255, 0.32);
}
.badge--lg {
  font-size: var(--fs-13);
  padding: 6px var(--sp-16);
}

/* ---------- Sidebar nav items ---------- */
.nav-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-block: var(--sp-12);
}
.nav-section__title {
  padding: 0 var(--sp-12);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--text-muted);
  margin-bottom: var(--sp-8);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  min-height: 44px;
  padding: 0 var(--sp-12);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transition: background var(--dur-fast), color var(--dur-fast);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item--active {
  background: linear-gradient(90deg, rgba(212, 168, 75, 0.16), rgba(212, 168, 75, 0.04));
  color: var(--gold);
}
.nav-item--active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--gold);
  border-radius: 0 3px 3px 0;
}
.nav-item .icon {
  width: 20px;
  height: 20px;
  color: currentColor;
}
.nav-item__label { flex: 1 1 auto; }
.nav-item__badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--gold);
  background: rgba(212, 168, 75, 0.12);
  padding: 2px 6px;
  border-radius: var(--radius-pill);
}

/* ---------- Breadcrumbs ---------- */
.crumbs {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  font-size: var(--fs-13);
  color: var(--text-muted);
  margin-bottom: var(--sp-16);
}
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--gold); }
.crumbs__sep { opacity: 0.4; }
.crumbs__current { color: var(--text-primary); font-weight: var(--fw-medium); }

/* ---------- Tables ---------- */
.table-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-14);
}
.table thead th {
  text-align: left;
  padding: var(--sp-16);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-input);
}
.table tbody td {
  padding: var(--sp-16);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-hover); }
.table .t-mono { font-size: var(--fs-13); }

/* ---------- Dropdown ---------- */
.dropdown {
  position: relative;
}
.dropdown__panel {
  position: absolute;
  top: calc(100% + var(--sp-8));
  right: 0;
  min-width: 240px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-8);
  z-index: var(--z-dropdown);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--dur-base), transform var(--dur-base);
}
.dropdown[data-open="true"] .dropdown__panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: var(--sp-12);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  min-height: 44px;
}
.dropdown__item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.dropdown__divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-8) 0;
}
.dropdown__header {
  padding: var(--sp-12);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal-backdrop);
  display: grid;
  place-items: center;
  padding: var(--sp-24);
}
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 560px;
  width: 100%;
  z-index: var(--z-modal);
  padding: var(--sp-32);
}

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  bottom: var(--sp-24);
  right: var(--sp-24);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
  max-width: 380px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-md);
  padding: var(--sp-16);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-14);
  color: var(--text-primary);
}
.toast--success { border-left-color: var(--success); }
.toast--danger { border-left-color: var(--danger); }

/* ---------- Hero / page header ---------- */
.page-hero {
  display: flex;
  flex-direction: column;
  gap: var(--sp-16);
  margin-bottom: var(--sp-48);
}
.page-hero__greeting {
  font-family: var(--font-display);
  font-weight: var(--fw-display-light);
  font-size: var(--fs-56);
  letter-spacing: var(--ls-display);
  line-height: var(--lh-tight);
  color: var(--text-primary);
}
.page-hero__greeting strong {
  font-weight: var(--fw-display-black);
  color: var(--gold);
}
.page-hero__sub {
  font-size: var(--fs-18);
  color: var(--text-secondary);
  max-width: 64ch;
  line-height: var(--lh-relaxed);
}
.page-hero__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  .page-hero__greeting { font-size: var(--fs-32); }
  .page-hero__sub { font-size: var(--fs-15); }
  .page-hero { margin-bottom: var(--sp-32); }
}

/* ---------- Coming soon callout ---------- */
.callout {
  background:
    radial-gradient(circle at 0% 0%, rgba(212, 168, 75, 0.1), transparent 50%),
    var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--sp-32);
  display: flex;
  flex-direction: column;
  gap: var(--sp-16);
}
.callout__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--gold);
}
.callout__title {
  font-family: var(--font-display);
  font-weight: var(--fw-display-bold);
  font-size: var(--fs-24);
  letter-spacing: var(--ls-tight);
}
.callout__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
}
.callout__list li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-12);
  color: var(--text-secondary);
  font-size: var(--fs-15);
  line-height: var(--lh-relaxed);
}
.callout__list .icon {
  color: var(--gold);
  margin-top: 2px;
}
.callout__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  margin-top: var(--sp-8);
  align-self: flex-start;
}

/* ---------- Lang switcher / theme toggle ---------- */
.pill-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
}
.pill-toggle button {
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  min-height: 30px;
}
.pill-toggle button[aria-pressed="true"] {
  background: var(--gold);
  color: var(--text-on-gold);
}

/* ---------- Avatar ---------- */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--gold-deep), var(--gold));
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: var(--fw-display-bold);
  color: var(--navy);
  font-size: var(--fs-13);
  letter-spacing: var(--ls-display);
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ---------- Notification dot ---------- */
.has-dot { position: relative; }
.has-dot::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg-surface);
}

/* ---------- Skeleton placeholder ---------- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-input) 0%,
    var(--bg-hover) 50%,
    var(--bg-input) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
