/*
 * Steel Pulse MDM theme.
 *
 * Applies the ERP app's palette and typography (docs/design/STYLE_GUIDE.md) on top of Bootstrap 5.3.
 * Colors are defined once as --sp-* tokens for dark (default) and light themes, then mapped onto
 * Bootstrap's own variables so standard Bootstrap components pick them up. Layout classes for the app
 * shell (sidebar, page header, tiles, list pages) follow below.
 */

/* ---- Font (self-hosted Roboto, Apache 2.0) ---------------------------------------------------- */

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../vendor/roboto/roboto-latin-400-normal.8eff0b8045fd.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("../vendor/roboto/roboto-latin-500-normal.115c2d84727b.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../vendor/roboto/roboto-latin-700-normal.c83e4437a53d.woff2") format("woff2");
}

/* ---- Color tokens --------------------------------------------------------------------------- */

:root,
[data-bs-theme="light"] {
  --sp-primary: #2563eb;
  --sp-primary-rgb: 37, 99, 235;
  --sp-primary-darken: #1d4ed8;
  --sp-primary-lighten: #3b82f6;
  --sp-secondary: #4a5568;
  --sp-tertiary: #d97706;
  --sp-shell: #1a2b3c;
  --sp-shell-text: rgba(255, 255, 255, 0.9);
  --sp-drawer-text: rgba(255, 255, 255, 0.75);
  --sp-bg: #f4f5f6;
  --sp-surface: #ffffff;
  --sp-bg-gray: #f0f2f4;
  --sp-text: #1a1a1a;
  --sp-text-muted: #6b7280;
  --sp-text-disabled: rgba(0, 0, 0, 0.38);
  --sp-success: #16a34a;
  --sp-success-rgb: 22, 163, 74;
  --sp-warning: #f59e0b;
  --sp-error: #ef4444;
  --sp-info: #0ea5e9;
  --sp-divider: rgba(0, 0, 0, 0.08);
  --sp-lines: rgba(0, 0, 0, 0.12);
  --sp-striped: rgba(0, 0, 0, 0.03);
}

[data-bs-theme="dark"] {
  --sp-primary: #3b82f6;
  --sp-primary-rgb: 59, 130, 246;
  --sp-primary-darken: #2563eb;
  --sp-primary-lighten: #60a5fa;
  --sp-secondary: #64748b;
  --sp-tertiary: #f59e0b;
  --sp-shell: #0f1923;
  --sp-shell-text: rgba(255, 255, 255, 0.9);
  --sp-drawer-text: rgba(255, 255, 255, 0.75);
  --sp-bg: #111827;
  --sp-surface: #1f2937;
  --sp-bg-gray: #1a2535;
  --sp-text: #f1f5f9;
  --sp-text-muted: #94a3b8;
  --sp-text-disabled: rgba(255, 255, 255, 0.3);
  --sp-success: #16a34a;
  --sp-success-rgb: 22, 163, 74;
  --sp-warning: #f59e0b;
  --sp-error: #ef4444;
  --sp-info: #0ea5e9;
  --sp-divider: rgba(255, 255, 255, 0.08);
  --sp-lines: rgba(255, 255, 255, 0.12);
  --sp-striped: rgba(255, 255, 255, 0.03);
}

/* ---- Map tokens onto Bootstrap ---------------------------------------------------------------- */

:root,
[data-bs-theme] {
  --bs-body-font-family: "Roboto", sans-serif;
  --bs-body-font-size: 0.8125rem;
  --bs-body-line-height: 1.4;
  --bs-body-bg: var(--sp-bg);
  --bs-body-color: var(--sp-text);
  --bs-secondary-color: var(--sp-text-muted);
  --bs-tertiary-bg: var(--sp-bg-gray);
  --bs-border-color: var(--sp-lines);
  --bs-border-radius: 6px;
  --bs-primary: var(--sp-primary);
  --bs-primary-rgb: var(--sp-primary-rgb);
  --bs-success: var(--sp-success);
  --bs-success-rgb: var(--sp-success-rgb);
  --bs-link-color: var(--sp-primary-lighten);
  --bs-link-color-rgb: var(--sp-primary-rgb);
  --bs-link-hover-color: var(--sp-primary);
  --bs-emphasis-color: var(--sp-text);
}

body {
  background: var(--sp-bg);
}

.btn {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  text-transform: none;
}

.btn-primary {
  --bs-btn-bg: var(--sp-primary);
  --bs-btn-border-color: var(--sp-primary);
  --bs-btn-hover-bg: var(--sp-primary-darken);
  --bs-btn-hover-border-color: var(--sp-primary-darken);
  --bs-btn-active-bg: var(--sp-primary-darken);
  --bs-btn-active-border-color: var(--sp-primary-darken);
  --bs-btn-disabled-bg: var(--sp-primary);
  --bs-btn-disabled-border-color: var(--sp-primary);
}

.form-control,
.form-select {
  background-color: var(--sp-surface);
  border-color: var(--sp-lines);
  font-size: 0.8125rem;
}

.form-text,
.text-muted {
  color: var(--sp-text-muted) !important;
}

.card {
  --bs-card-bg: var(--sp-surface);
  --bs-card-border-color: var(--sp-divider);
}

/* ---- App shell: top bar, sidebar, main --------------------------------------------------------- */

:root {
  --sp-topbar-height: 56px;
  --sp-sidebar-width: 205px;
  --sp-sidebar-collapsed-width: 56px;
}

.sp-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: var(--sp-topbar-height);
  padding: 0 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--sp-shell);
  color: var(--sp-shell-text);
}

.sp-wordmark {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--sp-shell-text);
  text-decoration: none;
}

.sp-wordmark:hover {
  color: var(--sp-shell-text);
}

.sp-wordmark img {
  width: auto;
  height: 34px;
}

.sp-product {
  padding: 0.05rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.sp-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.sp-icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sp-shell-text);
  font-size: 1.25rem;
}

.sp-icon-button:hover,
.sp-icon-button:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

.sp-profile-menu {
  min-width: 14rem;
  font-size: 0.8125rem;
}

/* The theme switch shows the theme it will change to: a sun in dark mode, a moon in light mode. */
[data-bs-theme="dark"] .sp-icon-when-light,
[data-bs-theme="light"] .sp-icon-when-dark {
  display: none;
}

.sp-shell {
  display: flex;
  min-height: calc(100vh - var(--sp-topbar-height));
}

.sp-sidebar {
  position: sticky;
  top: var(--sp-topbar-height);
  flex: 0 0 var(--sp-sidebar-width);
  width: var(--sp-sidebar-width);
  height: calc(100vh - var(--sp-topbar-height));
  padding-top: 0.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--sp-shell);
  transition: width 0.15s, flex-basis 0.15s;
}

.sp-sidebar a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.1rem;
  color: var(--sp-drawer-text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.sp-sidebar a:hover,
.sp-sidebar a.active {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sp-shell-text);
}

.sp-sidebar a.active {
  box-shadow: inset 3px 0 0 var(--sp-primary);
}

.sp-sidebar .bi {
  flex: 0 0 auto;
  font-size: 1.15rem;
}

/* Collapsed (menu button): icons only, labels shown as tooltips through the link title. */
.sp-sidebar-collapsed .sp-sidebar {
  flex-basis: var(--sp-sidebar-collapsed-width);
  width: var(--sp-sidebar-collapsed-width);
}

.sp-sidebar-collapsed .sp-sidebar span {
  display: none;
}

/* Phones: the sidebar starts as icons only. */
@media (max-width: 767.98px) {
  .sp-sidebar {
    flex-basis: var(--sp-sidebar-collapsed-width);
    width: var(--sp-sidebar-collapsed-width);
  }

  .sp-sidebar span {
    display: none;
  }

  .sp-product {
    display: none;
  }
}

.sp-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1rem 1.25rem 2rem;
}

.sp-page-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.sp-breadcrumb {
  --bs-breadcrumb-margin-bottom: 1rem;
  --bs-breadcrumb-divider-color: var(--sp-text-muted);
  --bs-breadcrumb-item-active-color: var(--sp-text-muted);
  font-size: 0.8125rem;
}

.sp-breadcrumb a {
  color: var(--sp-text);
  text-decoration: none;
}

/* ---- Home page ------------------------------------------------------------------------------ */

.sp-tile {
  display: block;
  padding: 1.5rem 1rem;
  border-radius: 6px;
  background: var(--sp-surface);
  color: var(--sp-text);
  text-align: center;
  text-decoration: none;
  transition: background-color 0.15s;
}

.sp-tile:hover {
  background: var(--sp-bg-gray);
  color: var(--sp-text);
}

.sp-tile .bi {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1.75rem;
}

.sp-tile-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.sp-tile-subtitle {
  color: var(--sp-text-muted);
  font-size: 0.75rem;
}

/* ---- List pages ----------------------------------------------------------------------------- */

.sp-search {
  max-width: 18rem;
}

.sp-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  background: var(--sp-primary);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.sp-chip:hover {
  background: var(--sp-primary-darken);
  color: #ffffff;
}

.sp-table-card {
  overflow: hidden;
  border-radius: 6px;
  background: var(--sp-surface);
}

.sp-table {
  --bs-table-bg: var(--sp-surface);
  --bs-table-color: var(--sp-text);
  --bs-table-border-color: var(--sp-divider);
  margin: 0;
}

.sp-table thead th {
  background: var(--sp-bg-gray);
  color: var(--sp-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.sp-table td,
.sp-table th {
  padding: 0.7rem 1rem;
  vertical-align: middle;
}

.sp-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 1.25rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--sp-divider);
}

.sp-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border: 1px solid;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.sp-pill-active {
  border-color: var(--sp-success);
  color: var(--sp-success);
}

.sp-pill-inactive {
  border-color: var(--sp-lines);
  color: var(--sp-text-muted);
}

.sp-pagination a,
.sp-pagination span.sp-page-link {
  color: var(--sp-text);
  font-size: 1rem;
}

.sp-pagination span.sp-page-link {
  color: var(--sp-text-disabled);
}

/* ---- Form pages ----------------------------------------------------------------------------- */

.sp-form-card {
  max-width: 40rem;
  padding: 1.25rem;
  border-radius: 6px;
  background: var(--sp-surface);
}

/* ---- Sign-in and setup pages ---------------------------------------------------------------- */

.sp-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.sp-auth-card {
  width: 100%;
  max-width: 26rem;
  padding: 2rem;
  border-radius: 6px;
  background: var(--sp-surface);
}

.sp-auth-brand {
  margin-bottom: 1.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.sp-auth-brand img {
  margin-bottom: 0.5rem;
  border-radius: 12px;
}

/* ---- Browser autofill --------------------------------------------------------------------------- */

/* Browsers paint autofilled fields their own yellow; repaint them in the theme's colors instead. */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--sp-text);
  caret-color: var(--sp-text);
  box-shadow: 0 0 0 1000px var(--sp-surface) inset;
  transition: background-color 600000s 0s;
}
