/* StockPulse admin — Bootstrap 5 companion, AdminMart-inspired light theme */
:root {
  --sp-sidebar-width: 260px;
  --sp-sidebar-bg: #1e2a3a;
  --sp-sidebar-text: #a7b1c2;
  --sp-sidebar-active: #ffffff;
  --sp-sidebar-accent: #5d87ff;
  --sp-topbar-h: 64px;
  --sp-body-bg: #f0f5f9;
  --sp-card-radius: 0.75rem;
  --sp-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.06);
}

html, body {
  height: 100%;
}

body.sp-body {
  background: var(--sp-body-bg);
  color: #2a3547;
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 0.925rem;
}

/* —— App shell —— */
.sp-shell {
  min-height: 100vh;
  display: flex;
}

.sp-sidebar {
  width: var(--sp-sidebar-width);
  background: var(--sp-sidebar-bg);
  color: var(--sp-sidebar-text);
  flex: 0 0 var(--sp-sidebar-width);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1030;
  transition: transform 0.2s ease;
}

.sp-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.15rem 1.25rem;
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sp-brand span { color: var(--sp-sidebar-accent); }
.sp-brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #5d87ff, #49beff);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.95rem;
}

.sp-nav {
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}
.sp-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  border-radius: 0.55rem;
  color: var(--sp-sidebar-text);
  text-decoration: none;
  font-weight: 500;
}
.sp-nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.sp-nav a.active {
  background: rgba(93, 135, 255, 0.18);
  color: var(--sp-sidebar-active);
}
.sp-nav a i { font-size: 1.15rem; opacity: 0.9; }

.sp-sidebar-foot {
  padding: 0.85rem 1rem 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
}

.sp-main {
  margin-left: var(--sp-sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sp-topbar {
  height: var(--sp-topbar-h);
  background: #fff;
  border-bottom: 1px solid #ebf1f6;
  box-shadow: var(--sp-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.sp-content {
  padding: 1.35rem 1.35rem 2.5rem;
}

.sp-page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #2a3547;
  margin: 0 0 0.25rem;
}
.sp-page-lead {
  color: #5a6a85;
  margin: 0 0 1.15rem;
}

/* —— Cards / tables —— */
.sp-card {
  background: #fff;
  border: 1px solid #ebf1f6;
  border-radius: var(--sp-card-radius);
  box-shadow: var(--sp-shadow);
  margin-bottom: 1.15rem;
}
.sp-card-body { padding: 1.15rem 1.25rem; }
.sp-card-header {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid #ebf1f6;
  font-weight: 600;
  color: #2a3547;
  background: #fff;
  border-radius: var(--sp-card-radius) var(--sp-card-radius) 0 0;
}

.sp-stat {
  background: #fff;
  border: 1px solid #ebf1f6;
  border-radius: var(--sp-card-radius);
  box-shadow: var(--sp-shadow);
  padding: 1rem 1.1rem;
  height: 100%;
}
.sp-stat .label {
  color: #5a6a85;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.sp-stat .value {
  font-size: 1.45rem;
  font-weight: 700;
  margin-top: 0.35rem;
  color: #2a3547;
}

.table-sp {
  margin: 0;
  font-size: 0.9rem;
}
.table-sp thead th {
  background: #f8fafc;
  color: #5a6a85;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  border-bottom-width: 1px;
  white-space: nowrap;
}
.table-sp td, .table-sp th {
  vertical-align: middle;
  padding: 0.7rem 0.85rem;
}
.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: 0.86rem; }

.badge-sp {
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.35em 0.55em;
  border-radius: 0.35rem;
}
.badge-ok { background: #e6fffa; color: #0f766e; }
.badge-fail { background: #fee2e2; color: #b91c1c; }
.badge-warn { background: #fff7ed; color: #c2410c; }
.badge-open { background: #eff6ff; color: #1d4ed8; }
.badge-ack { background: #fef9c3; color: #a16207; }
.badge-resolved { background: #ecfdf5; color: #047857; }
.badge-muted { background: #f1f5f9; color: #475569; }

.lang-switch {
  display: inline-flex;
  gap: 0.2rem;
  background: #f0f5f9;
  border-radius: 0.5rem;
  padding: 0.2rem;
}
.lang-switch a {
  color: #5a6a85;
  text-decoration: none;
  padding: 0.25rem 0.55rem;
  border-radius: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
}
.lang-switch a.active {
  background: #fff;
  color: #5d87ff;
  box-shadow: var(--sp-shadow);
}

.flash-sp {
  border-radius: 0.55rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}
.flash-sp.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.test-status.ok { color: #0f766e; font-weight: 600; }
.test-status.err { color: #b91c1c; font-weight: 600; }
.test-status.muted { color: #64748b; }

.err-full {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.78rem;
  color: #b91c1c;
}

/* Secret reveal */
.secret-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.secret-field .form-control { flex: 1; }
.btn-reveal {
  box-sizing: border-box;
  flex: 0 0 2.4rem;
  width: 2.4rem;
  height: 2.4rem;
  min-width: 2.4rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  color: #475569;
  border: 1px solid #dbe3ee;
  border-radius: 0.45rem;
  cursor: pointer;
  line-height: 1;
  font-size: 1.15rem;
  appearance: none;
}
.btn-reveal:hover { background: #eef2f7; color: #1e293b; }
.btn-reveal[aria-pressed="true"] {
  color: #5d87ff;
  border-color: #5d87ff;
  background: #eef3ff;
}
.btn-reveal:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-reveal .reveal-icon { display: block; line-height: 1; }

/* Login */
body.sp-login {
  background:
    radial-gradient(900px 480px at 10% -10%, rgba(93, 135, 255, 0.18), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(73, 190, 255, 0.14), transparent 50%),
    var(--sp-body-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.sp-login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid #ebf1f6;
  border-radius: 1rem;
  box-shadow: 0 0.75rem 2rem rgba(30, 42, 58, 0.08);
  padding: 1.75rem 1.6rem 1.5rem;
}
.sp-login-brand {
  text-align: center;
  font-size: 1.65rem;
  font-weight: 750;
  margin-bottom: 0.25rem;
}
.sp-login-brand span { color: #5d87ff; }

.btn-primary {
  --bs-btn-bg: #5d87ff;
  --bs-btn-border-color: #5d87ff;
  --bs-btn-hover-bg: #4a74ef;
  --bs-btn-hover-border-color: #4a74ef;
  --bs-btn-active-bg: #3f67e0;
  --bs-btn-active-border-color: #3f67e0;
}

.sp-menu-toggle {
  display: none;
  border: 1px solid #dbe3ee;
  background: #fff;
  border-radius: 0.45rem;
  width: 2.3rem;
  height: 2.3rem;
  align-items: center;
  justify-content: center;
}

@media (max-width: 991.98px) {
  .sp-sidebar {
    transform: translateX(-105%);
  }
  body.sp-sidebar-open .sp-sidebar {
    transform: translateX(0);
  }
  .sp-main { margin-left: 0; }
  .sp-menu-toggle { display: inline-flex; }
  .sp-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1025;
  }
  body.sp-sidebar-open .sp-sidebar-backdrop { display: block; }
}
