/* ══════════════════════════════════════════════════════════
   SCOOP Supplier Portal — self-contained styles.
   Deliberately not sharing assets/css/theme.css or client-portal/css/portal.css:
   this folder has no dependency on the internal app's code (or the client
   portal's) at all, so isolation holds even if either's styling/tokens
   change shape later. Same brand tokens as client-portal/css/portal.css,
   just re-declared under an sp- prefix for this folder's own scope. The
   Material Symbols import below is the one exception — same font, imported
   separately here rather than pulled from theme.css, so the sign-out icon
   can match the internal app's without creating that dependency.
══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined');

:root {
  --sp-bg:        #f4f5f7;
  --sp-surface:   #ffffff;
  --sp-border:    rgba(15,23,42,0.10);
  --sp-text:      #14181f;
  --sp-text-sub:  #5b6472;
  --sp-brand:     #981e32;
  --sp-brand-600: #7a1828;
  --sp-brand-wash: rgba(152,30,50,0.08);
  --sp-success:   #1f9d63;
  --sp-warning:   #c98a1a;
  --sp-info:      #2f6fed;
  --sp-danger:    #d9403f;
  --sp-radius:    16px;
  --sp-shadow:    0 8px 28px rgba(15,23,42,0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --sp-bg:        #0f1216;
    --sp-surface:   #1a1e24;
    --sp-border:    rgba(255,255,255,0.08);
    --sp-text:      #eef1f5;
    --sp-text-sub:  #99a2ae;
    --sp-brand:     #e0596e;
    --sp-brand-600: #c9435a;
    --sp-brand-wash: rgba(224,89,110,0.12);
    --sp-shadow:    0 8px 28px rgba(0,0,0,0.4);
  }
}
:root[data-sp-theme="dark"] {
  --sp-bg: #0f1216; --sp-surface:#1a1e24; --sp-border:rgba(255,255,255,0.08);
  --sp-text:#eef1f5; --sp-text-sub:#99a2ae; --sp-brand:#e0596e; --sp-brand-600:#c9435a;
  --sp-brand-wash: rgba(224,89,110,0.12); --sp-shadow:0 8px 28px rgba(0,0,0,0.4);
}
:root[data-sp-theme="light"] {
  --sp-bg:#f4f5f7; --sp-surface:#ffffff; --sp-border:rgba(15,23,42,0.10);
  --sp-text:#14181f; --sp-text-sub:#5b6472; --sp-brand:#981e32; --sp-brand-600:#7a1828;
  --sp-brand-wash: rgba(152,30,50,0.08); --sp-shadow:0 8px 28px rgba(15,23,42,0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh;
  background: var(--sp-bg); color: var(--sp-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

.sp-theme-toggle {
  position: fixed; top: 16px; right: 16px; z-index: 20;
  width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--sp-border);
  background: var(--sp-surface); color: var(--sp-text-sub); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-appearance: none; appearance: none;
}
.sp-theme-toggle:hover { color: var(--sp-brand); border-color: var(--sp-brand); }

/* ── Login page — same visual language as the internal app's login.html/
   login.css: pearl-island background photo, card entrance animation, icon-
   prefixed fields, arrow CTA button. Literal values/sp- prefixed classes
   instead of importing login.css directly, same isolation reasoning as
   the rest of this file. ── */
.sp-login-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: url('../../images/the_pearl.jpg') center/cover no-repeat;
  opacity: 0.28;
}
:root[data-sp-theme="light"] .sp-login-bg { opacity: 1; }
.sp-login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  position: relative; z-index: 1;
}
.sp-login-card {
  width: 100%; max-width: 380px;
  background: var(--sp-surface); border: 1px solid var(--sp-border); border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow); padding: 32px 28px;
  position: relative; z-index: 1;
  animation: spCardIn 0.5s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes spCardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.sp-login-title { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.sp-login-sub { margin: 0 0 24px; color: var(--sp-text-sub); font-size: 13px; }
.sp-field { margin-bottom: 14px; }
.sp-field label { display: block; font-size: 12px; font-weight: 600; color: var(--sp-text-sub); margin-bottom: 6px; }
.sp-field-wrap { position: relative; display: flex; align-items: center; }
.sp-field-icon {
  position: absolute; left: 14px; color: var(--sp-text-sub); font-size: 18px;
  pointer-events: none; z-index: 1;
}
.sp-field-wrap:focus-within .sp-field-icon { color: var(--sp-brand); }
.sp-field-input {
  width: 100%; height: 44px; padding: 0 14px 0 44px; border-radius: 10px;
  border: 1px solid var(--sp-border); background: var(--sp-bg); color: var(--sp-text);
  font-size: 15px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.sp-field-input:focus { border-color: var(--sp-brand); box-shadow: 0 0 0 3px var(--sp-brand-wash); }
.sp-has-toggle .sp-field-input { padding-right: 40px; }
.sp-pw-toggle {
  position: absolute; right: 12px; background: none; border: none; cursor: pointer;
  color: var(--sp-text-sub); padding: 4px; display: flex; align-items: center; justify-content: center; z-index: 1;
}
.sp-pw-toggle:hover { color: var(--sp-text); }
.sp-pw-toggle .material-symbols-outlined { font-size: 18px; }
.sp-login-btn {
  width: 100%; height: 46px; margin-top: 6px; border: none; border-radius: 10px; cursor: pointer;
  background: var(--sp-brand); color: #fff; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.2s, transform 0.2s;
}
.sp-login-btn:hover { background: var(--sp-brand-600); transform: translateY(-1px); }
.sp-login-btn:disabled { opacity: 0.6; cursor: default; transform: none; }
/* Hidden by default until the username field passes checkEmailDomain() —
   see js/portal-login.js. */
.sp-login-btn-hidden { display: none; }
.sp-btn-arrow {
  width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center; font-size: 11px; transition: transform 0.2s;
}
.sp-login-btn:hover .sp-btn-arrow { transform: translateX(3px); }
.sp-login-msg { min-height: 18px; margin: 10px 0 0; font-size: 13px; color: var(--sp-danger); }

/* ── Dashboard shell ──────────────────────────────── */
.sp-shell { max-width: 1200px; margin: 0 auto; padding: 20px 20px 60px; }
.sp-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0 20px;
}
.sp-brand-mark { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; color: var(--sp-text); }
.sp-who { display: flex; align-items: center; gap: 12px; }
.sp-who-name { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-size: 13px; color: var(--sp-text-sub); }
.sp-who-supplier { font-size: 15px; font-weight: 600; color: var(--sp-text); line-height: 1.3; }
.sp-who-contact  { font-size: 13px; color: var(--sp-text-sub); line-height: 1.3; }
.sp-signout-btn {
  width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--sp-border);
  background: var(--sp-surface); color: var(--sp-text-sub); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
/* Same icon + hover-red treatment as the internal app's
   .user-dropdown-item--signout (assets/css/navigation.css). */
.sp-signout-btn .material-symbols-outlined { font-size: 18px; }
.sp-signout-btn:hover { border-color: var(--sp-danger); color: var(--sp-danger); background: rgba(217,64,63,0.08); }

.sp-card { background: var(--sp-surface); border: 1px solid var(--sp-border); border-radius: var(--sp-radius); padding: 20px; }
.sp-card-title { margin: 0 0 6px; font-size: 15px; font-weight: 800; }
.sp-empty { color: var(--sp-text-sub); font-size: 13px; padding: 30px 0; text-align: center; }
.sp-loading { display: flex; align-items: center; justify-content: center; padding: 60px 0; }
.sp-spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid var(--sp-border);
  border-top-color: var(--sp-brand);
  animation: spSpin 0.8s linear infinite;
}
@keyframes spSpin { to { transform: rotate(360deg); } }

/* ── Tabs (same pattern as client-portal's .cp-tabs/.cp-tab) ─────────── */
.sp-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.sp-tab {
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--sp-border); background: var(--sp-surface);
  color: var(--sp-text-sub); font-size: 13px; font-weight: 700; cursor: pointer;
}
.sp-tab.active { background: var(--sp-brand); border-color: var(--sp-brand); color: #fff; }

/* ── Static Bookings stat cards — same visual language as the internal
   app's .stats-grid/.stat-card (assets/css/dashboard.css: gradient stat
   value, corner glow orb, colored hover border), adapted onto this portal's
   solid --sp-surface cards instead of the main app's transparent+blurred
   ones (there's no photo/gradient background here for a blur to show). ── */
.sp-stats-grid { display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
.sp-completed-card { max-height: 500px; display: flex; flex-direction: column; }
.sp-completed-total {
  margin-top: 20px; font-size: 12.5px; font-weight: 400; color: var(--sp-text-sub);
  text-align: left; flex-shrink: 0;
}

/* Same look as the client portal's .cp-table. */
.sp-table-wrap { overflow: auto; flex: 1; min-height: 0; }
.sp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sp-table th {
  text-align: left; padding: 10px 12px; color: var(--sp-text-sub); font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--sp-border);
  white-space: nowrap; position: sticky; top: 0; background: var(--sp-surface);
}
.sp-table td { padding: 12px; border-bottom: 1px solid var(--sp-border); vertical-align: top; }
.sp-table tr:last-child td { border-bottom: none; }
.sp-stat-card {
  background: var(--sp-surface); border: 1px solid var(--sp-border); border-radius: var(--sp-radius);
  padding: 20px; position: relative; overflow: hidden; max-height: 700px;
  display: flex; flex-direction: column;
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.sp-stat-card:hover {
  transform: translateY(-4px); border-color: var(--sp-card-accent);
  box-shadow: 0 16px 40px rgba(0,0,0,0.12), 0 0 0 1px var(--sp-card-accent);
}
.sp-stat-card-glow {
  position: absolute; top: -30px; right: -30px; width: 100px; height: 100px; border-radius: 50%;
  background: var(--sp-card-accent); opacity: 0.12; filter: blur(36px); transition: opacity 0.25s;
}
.sp-stat-card:hover .sp-stat-card-glow { opacity: 0.22; }
.sp-stat-label {
  font-size: 11px; font-weight: 700; color: var(--sp-text-sub); letter-spacing: 0.06em;
  text-transform: uppercase; margin-bottom: 10px; position: relative;
}
.sp-stat-value {
  font-size: 40px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--sp-text), var(--sp-card-accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; position: relative;
}
.sp-stat-sub { font-size: 12.5px; color: var(--sp-text-sub); position: relative; }

.sp-stat-divider { height: 1px; background: var(--sp-border); margin: 16px 0 12px; position: relative; flex-shrink: 0; }
.sp-stat-list {
  display: flex; flex-direction: column; gap: 12px; overflow-y: auto;
  position: relative; white-space: normal; flex: 1; min-height: 0;
  /* Right padding + scrollbar-gutter keep the scrollbar from sitting flush
     against the row content — otherwise the thumb overlaps the pill/text. */
  padding-right: 12px; scrollbar-gutter: stable;
}
.sp-stat-list::-webkit-scrollbar { width: 6px; }
.sp-stat-list::-webkit-scrollbar-track { margin: 4px 0; }
.sp-stat-list::-webkit-scrollbar-thumb { background: var(--sp-border); border-radius: 999px; border: 2px solid var(--sp-surface); }
.sp-stat-empty { font-size: 12px; color: var(--sp-text-sub); text-align: center; padding: 8px 0; }
/* align-items:flex-start — a plain flex column defaults to stretch, which
   would otherwise force the status pill span to the row's full width
   instead of hugging its own text. */
.sp-stat-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 100%; }
/* Separator between rows — not on the first, so it doesn't double up with
   .sp-stat-divider right above the list. */
.sp-stat-row:not(:first-child) { border-top: 1px solid var(--sp-border); padding-top: 12px; }
.sp-stat-row-meta { width: 100%; }
.sp-stat-row-pills { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sp-stat-row-brand { font-size: 13px; font-weight: 600; color: var(--sp-text); }
.sp-stat-row-meta {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: 11.5px; color: var(--sp-text-sub);
}
.sp-stat-row-circuit { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-stat-row-dates { flex-shrink: 0; }

/* ── Map summary chips — clickable, toggle that category's markers ──── */
.sp-map-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.sp-summary-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--sp-border); background: var(--sp-bg); cursor: pointer;
  font-size: 12.5px; font-weight: 400; color: var(--sp-text); transition: opacity 0.2s, border-color 0.2s;
}
.sp-summary-chip:hover { border-color: var(--sp-chip-color, var(--sp-brand)); }
.sp-summary-chip .sp-chip-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sp-chip-color); flex-shrink: 0; }
/* Toggled off — dimmed + strikethrough, so it still reads as "this category
   exists" rather than disappearing, since clicking again brings it back. */
.sp-summary-chip.sp-chip-off { opacity: 0.45; text-decoration: line-through; }

/* ── Map ──────────────────────────────────────────── */
.sp-map-wrap {
  position: relative; width: 100%; height: 68vh; min-height: 420px;
  border-radius: 12px; overflow: hidden; border: 1px solid var(--sp-border);
}
.sp-map-wrap .maplibregl-map { width: 100%; height: 100%; }
/* Multi-category pie marker (circuit with more than one status active at
   once — see buildPieBackground() in portal-map.js). Sized to match the
   circle-layer markers' 9px radius (18px diameter) + the same 1.5px white
   stroke look. */
.sp-pie-marker {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid #ffffff; box-shadow: 0 1px 3px rgba(0,0,0,0.35); cursor: pointer;
}
.sp-map-legend {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  background: var(--sp-surface); border: 1px solid var(--sp-border); border-radius: 10px;
  padding: 8px 12px; font-size: 12px; color: var(--sp-text-sub); box-shadow: var(--sp-shadow);
}
#spMapNotices {
  position: absolute; bottom: 12px; left: 12px; z-index: 5;
  display: flex; flex-direction: column; gap: 6px; max-width: 60%;
}
.sp-map-notice-item {
  background: var(--sp-surface); border: 1px solid var(--sp-border); border-radius: 10px;
  padding: 6px 10px; font-size: 11.5px; color: var(--sp-danger); box-shadow: var(--sp-shadow);
}

/* ── Popup content (rendered inside a maplibregl.Popup) ──────────────── */
.sp-map-popup .maplibregl-popup-content {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding: 12px 14px; border-radius: 12px;
}
.sp-popup-name { font-weight: 800; font-size: 13px; margin-bottom: 6px; color: #14181f; }
.sp-popup-booking { padding: 6px 0; border-top: 1px solid rgba(15,23,42,0.08); }
.sp-popup-booking:first-of-type { border-top: none; }
.sp-popup-brand { font-weight: 700; font-size: 12px; color: #14181f; }
.sp-popup-client { font-size: 11px; color: #5b6472; }
.sp-popup-dates { font-size: 11px; color: #5b6472; margin-top: 2px; }
/* Same look/colors as the internal app's .status-pill/.pill-* and the
   client portal's .cp-pill/.cp-pill-* — literal hex values, same reasoning
   as elsewhere in this file. */
.sp-popup-pill {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap; flex-shrink: 0;
}
.sp-popup-pill::before { content: "•"; }
.sp-popup-pill-live      { background: rgba(53,179,126,0.15); color: #35B37E; }
.sp-popup-pill-signed    { background: rgba(229,72,77,0.15);  color: #E5484D; }
.sp-popup-pill-pending   { background: rgba(224,161,58,0.15); color: #E0A13A; }
.sp-popup-pill-completed { background: rgba(4,150,255,0.15);  color: #0496FF; }
.sp-popup-pill-cancelled { background: rgba(100,100,100,0.15);color: #75787C; }
/* Light red — a campaign still occupying its slot past its own scheduled
   End Date; lighter than .sp-popup-pill-signed's red so it doesn't read as
   the same "Booked" status. */
.sp-popup-pill-extended  { background: rgba(248,113,113,0.15); color: #F87171; }
.sp-popup-empty { font-size: 11.5px; color: #5b6472; }

@media (max-width: 720px) {
  .sp-shell { padding: 14px 12px 40px; }
  .sp-who-name { display: none; }
  .sp-map-wrap { height: 60vh; }
  .sp-stats-grid { grid-template-columns: 1fr; }
}
