/* =========================================================
   KasiLink SA — Stylesheet
   South African plumbing services marketplace
   ========================================================= */

:root {
  /* South African flag colour palette */
  --sa-black: #000000;
  --sa-green: #007749;
  --sa-gold: #FFB81C;
  --sa-red: #E03C31;
  --sa-blue: #001489;
  --sa-white: #FFFFFF;

  /* Derived tones used for surfaces and hover states */
  --sa-green-dark: #00532f;
  --sa-blue-dark: #000d5e;
  --sa-gray-bg: #f4f4f2;
  --sa-gray-line: #d8d8d4;
  --sa-text: #1a1a1a;

  /* Type */
  --font-main: "Courier New", Courier, monospace;

  /* Layout */
  --max-width: 1140px;
  --radius: 4px;
  --header-height: 76px;
}

/* -------------------- Reset -------------------- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-main);
  color: var(--sa-text);
  background: var(--sa-white);
  line-height: 1.6;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--sa-blue);
  text-decoration: none;
}

a:hover {
  color: var(--sa-green);
}

h1, h2, h3, h4 {
  font-family: var(--font-main);
  line-height: 1.25;
  margin: 0 0 0.6em 0;
}

p {
  margin: 0 0 1em 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

button {
  font-family: var(--font-main);
  cursor: pointer;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Visible keyboard focus for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--sa-gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* -------------------- Buttons -------------------- */
.btn {
  display: inline-block;
  font-family: var(--font-main);
  font-size: 0.95rem;
  padding: 12px 22px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: var(--sa-green);
  color: var(--sa-white);
  border-color: var(--sa-green);
}

.btn-primary:hover {
  background: var(--sa-gold);
  border-color: var(--sa-gold);
  color: var(--sa-black);
}

.btn-secondary {
  background: transparent;
  color: var(--sa-white);
  border-color: var(--sa-white);
}

.btn-secondary:hover {
  background: var(--sa-white);
  color: var(--sa-black);
}

.btn-blue {
  background: var(--sa-blue);
  color: var(--sa-white);
  border-color: var(--sa-blue);
}

.btn-blue:hover {
  background: var(--sa-gold);
  border-color: var(--sa-gold);
  color: var(--sa-black);
}

.btn-outline {
  background: transparent;
  color: var(--sa-blue);
  border-color: var(--sa-blue);
}

.btn-outline:hover {
  background: var(--sa-blue);
  color: var(--sa-white);
}

.btn-emergency {
  background: var(--sa-red);
  color: var(--sa-white);
  border-color: var(--sa-red);
}

.btn-emergency:hover {
  background: var(--sa-gold);
  border-color: var(--sa-gold);
  color: var(--sa-black);
}

.btn-block {
  width: 100%;
  text-align: center;
}

/* -------------------- Header -------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--sa-black);
  border-bottom: 3px solid var(--sa-green);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-height);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--sa-white);
}

.brand img {
  height: 48px;
  width: 48px;
  object-fit: contain;
  background: var(--sa-black);
  border-radius: 50%;
}

.brand-name {
  font-weight: bold;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  color: var(--sa-white);
}

.main-nav {
  display: flex;
}

.main-nav ul {
  display: flex;
  gap: 22px;
}

.main-nav a {
  color: var(--sa-white);
  font-size: 0.92rem;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
  color: var(--sa-gold);
  border-bottom-color: var(--sa-gold);
}

.header-cta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 2px solid var(--sa-white);
  color: var(--sa-white);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 1rem;
}

@media (max-width: 900px) {
  .header-cta .btn-secondary {
    display: none;
  }
}

@media (max-width: 800px) {
  .nav-toggle {
    display: inline-block;
  }

  .main-nav {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--sa-black);
    border-bottom: 3px solid var(--sa-green);
    display: none;
  }

  .main-nav.open {
    display: block;
  }

  .main-nav ul {
    flex-direction: column;
    gap: 0;
    padding: 8px 24px 16px;
  }

  .main-nav a {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid #1c1c1c;
  }

  .header-cta {
    display: none;
  }
}

/* -------------------- Hero -------------------- */
.hero {
  background: var(--sa-black);
  color: var(--sa-white);
  padding: 64px 0;
  border-bottom: 6px solid var(--sa-gold);
}

.hero-inner {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}

.hero-label {
  display: inline-block;
  color: var(--sa-gold);
  font-size: 0.85rem;
  letter-spacing: 1px;
  border: 1px solid var(--sa-gold);
  padding: 4px 10px;
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.hero h1 {
  font-size: 2.4rem;
  margin-bottom: 18px;
}

.hero p {
  color: #d8d8d8;
  max-width: 46ch;
  margin-bottom: 26px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-art {
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-art svg {
  width: 100%;
  max-width: 360px;
  height: auto;
}

.hero-logo {
  width: 100%;
  max-width: 320px;
  height: auto;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.18));
}

@media (max-width: 860px) {
  .hero-inner {
    grid-template-columns: 1fr;
  }

  .hero-art {
    order: -1;
  }
}

/* -------------------- Page header (non-home) -------------------- */
.page-hero {
  background: var(--sa-black);
  color: var(--sa-white);
  padding: 46px 0;
  border-bottom: 6px solid var(--sa-gold);
}

.page-hero .hero-label {
  margin-bottom: 12px;
}

.page-hero h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.page-hero p {
  color: #d8d8d8;
  max-width: 62ch;
  margin: 0;
}

/* -------------------- Sections -------------------- */
.section {
  padding: 64px 0;
}

.section-alt {
  background: var(--sa-gray-bg);
}

.section-title {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.section-sub {
  color: #4b4b4b;
  max-width: 62ch;
  margin-bottom: 36px;
}

/* -------------------- How it works -------------------- */
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
}

.step-card {
  background: var(--sa-white);
  border: 1px solid var(--sa-gray-line);
  border-top: 4px solid var(--sa-green);
  border-radius: var(--radius);
  padding: 22px;
}

.step-num {
  font-weight: bold;
  color: var(--sa-green);
  font-size: 1.4rem;
  margin-bottom: 10px;
}

.step-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.step-card p {
  font-size: 0.92rem;
  color: #4b4b4b;
  margin: 0;
}

@media (max-width: 900px) {
  .steps {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .steps {
    grid-template-columns: 1fr;
  }
}

/* -------------------- Benefits -------------------- */
.benefits-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
}

.benefit-panel {
  background: var(--sa-white);
  border: 1px solid var(--sa-gray-line);
  border-radius: var(--radius);
  padding: 26px;
}

.benefit-panel.customer {
  border-top: 5px solid var(--sa-blue);
}

.benefit-panel.plumber {
  border-top: 5px solid var(--sa-green);
}

.benefit-panel h3 {
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.benefit-panel li {
  padding: 7px 0 7px 26px;
  position: relative;
  font-size: 0.94rem;
  border-bottom: 1px solid var(--sa-gray-line);
}

.benefit-panel li:last-child {
  border-bottom: none;
}

.benefit-panel.customer li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--sa-blue);
  font-weight: bold;
}

.benefit-panel.plumber li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--sa-green);
  font-weight: bold;
}

@media (max-width: 760px) {
  .benefits-grid {
    grid-template-columns: 1fr;
  }
}

/* -------------------- Find a Plumber search -------------------- */
.search-panel {
  background: var(--sa-white);
  border: 1px solid var(--sa-gray-line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 6px 0 var(--sa-black);
}

.search-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.82rem;
  color: #4b4b4b;
}

.field input,
.field select {
  font-family: var(--font-main);
  padding: 11px 12px;
  border: 1px solid var(--sa-gray-line);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--sa-white);
}

@media (max-width: 760px) {
  .search-form {
    grid-template-columns: 1fr;
  }
}

#search-results {
  margin-top: 26px;
}

#search-status {
  font-size: 0.9rem;
  color: #4b4b4b;
  margin-bottom: 14px;
}

/* -------------------- Plumber cards -------------------- */
.plumber-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

@media (max-width: 900px) {
  .plumber-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .plumber-grid {
    grid-template-columns: 1fr;
  }
}

.plumber-card {
  background: var(--sa-white);
  border: 1px solid var(--sa-gray-line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.plumber-photo {
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sa-black);
  color: var(--sa-white);
  font-size: 1.8rem;
  font-weight: bold;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.plumber-photo::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--sa-green) 0 33%, var(--sa-gold) 33% 66%, var(--sa-red) 66% 100%);
}

.plumber-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.plumber-name {
  font-size: 1.05rem;
  font-weight: bold;
  margin: 0;
}

.plumber-spec {
  color: var(--sa-blue);
  font-size: 0.85rem;
}

.plumber-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #4b4b4b;
  border-top: 1px dashed var(--sa-gray-line);
  border-bottom: 1px dashed var(--sa-gray-line);
  padding: 8px 0;
}

.plumber-rating {
  color: var(--sa-gold);
  font-weight: bold;
}

.plumber-rating span.count {
  color: #4b4b4b;
  font-weight: normal;
  font-size: 0.82rem;
}

.plumber-review {
  font-size: 0.85rem;
  font-style: italic;
  color: #4b4b4b;
  background: var(--sa-gray-bg);
  padding: 8px 10px;
  border-radius: var(--radius);
}

.review-tag {
  display: inline-block;
  font-style: normal;
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  background: var(--sa-gold);
  color: var(--sa-black);
  padding: 2px 6px;
  border-radius: var(--radius);
  margin-bottom: 6px;
}

.plumber-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

.plumber-actions .btn {
  flex: 1;
  padding: 9px 10px;
  font-size: 0.85rem;
  text-align: center;
}

.emergency-badge {
  display: inline-block;
  background: var(--sa-red);
  color: var(--sa-white);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: var(--radius);
}

.demo-note {
  font-size: 0.78rem;
  color: #6b6b6b;
  border-left: 3px solid var(--sa-gold);
  padding: 8px 12px;
  background: var(--sa-gray-bg);
  margin-bottom: 30px;
}

/* -------------------- Services list -------------------- */
.service-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

@media (max-width: 900px) {
  .service-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .service-grid {
    grid-template-columns: 1fr;
  }
}

.service-card {
  background: var(--sa-white);
  border: 1px solid var(--sa-gray-line);
  border-left: 5px solid var(--sa-green);
  border-radius: var(--radius);
  padding: 20px;
}

.service-card.emergency {
  border-left-color: var(--sa-red);
}

.service-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.service-card p {
  font-size: 0.88rem;
  color: #4b4b4b;
  margin: 0;
}

.service-card .service-price {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--sa-blue);
}

.service-card.emergency .service-price {
  color: var(--sa-red);
}

/* -------------------- Persona cards -------------------- */
.persona-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
}

@media (max-width: 800px) {
  .persona-grid {
    grid-template-columns: 1fr;
  }
}

.persona-card {
  background: var(--sa-white);
  border: 1px solid var(--sa-gray-line);
  border-radius: var(--radius);
  overflow: hidden;
}

.persona-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  color: var(--sa-white);
}

.persona-head.customer-head {
  background: var(--sa-blue);
}

.persona-head.plumber-head {
  background: var(--sa-green);
}

.persona-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.persona-head h3 {
  margin: 0;
  font-size: 1.1rem;
}

.persona-head p {
  margin: 0;
  font-size: 0.82rem;
  opacity: 0.9;
}

.persona-body {
  padding: 20px;
}

.persona-body dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  row-gap: 10px;
  column-gap: 10px;
  margin: 0 0 16px 0;
  font-size: 0.88rem;
}

.persona-body dt {
  color: #6b6b6b;
}

.persona-body dd {
  margin: 0;
}

.persona-body h4 {
  font-size: 0.88rem;
  margin: 14px 0 8px;
  color: var(--sa-black);
  border-bottom: 2px solid var(--sa-gold);
  display: inline-block;
  padding-bottom: 2px;
}

.persona-body ul li {
  font-size: 0.86rem;
  padding: 4px 0 4px 18px;
  position: relative;
}

.persona-body ul li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--sa-gold);
}

/* -------------------- Revenue model -------------------- */
.revenue-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

@media (max-width: 900px) {
  .revenue-grid {
    grid-template-columns: 1fr;
  }
}

.revenue-card {
  background: var(--sa-white);
  border: 1px solid var(--sa-gray-line);
  border-radius: var(--radius);
  padding: 22px;
  border-top: 4px solid var(--sa-blue);
}

.revenue-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.revenue-card p {
  font-size: 0.88rem;
  color: #4b4b4b;
  margin: 0;
}

.calculator {
  background: var(--sa-black);
  color: var(--sa-white);
  border-radius: var(--radius);
  padding: 30px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

@media (max-width: 800px) {
  .calculator {
    grid-template-columns: 1fr;
  }
}

.calculator h3 {
  color: var(--sa-gold);
  font-size: 1.05rem;
  margin-bottom: 16px;
}

.calc-form .field label {
  color: #cfcfcf;
}

.calc-form .field {
  margin-bottom: 16px;
}

.calc-form input,
.calc-form select {
  width: 100%;
}

.calc-results {
  border-left: 1px solid #333;
  padding-left: 30px;
}

@media (max-width: 800px) {
  .calc-results {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid #333;
    padding-top: 20px;
  }
}

.calc-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed #333;
  font-size: 0.92rem;
}

.calc-row.total {
  border-bottom: none;
  padding-top: 14px;
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--sa-gold);
}

.calc-row .value.positive {
  color: var(--sa-green);
}

.calc-row .value.negative {
  color: var(--sa-red);
}

/* -------------------- Forms (booking / contact / rating) -------------------- */
.form-card {
  background: var(--sa-white);
  border: 1px solid var(--sa-gray-line);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 560px;
}

.form-card .field {
  margin-bottom: 16px;
}

.form-card input,
.form-card select,
.form-card textarea {
  width: 100%;
  font-family: var(--font-main);
  padding: 11px 12px;
  border: 1px solid var(--sa-gray-line);
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.form-card textarea {
  resize: vertical;
  min-height: 110px;
}

.form-msg {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  display: none;
}

.form-msg.success {
  display: block;
  background: #e6f4ec;
  color: var(--sa-green-dark);
  border: 1px solid var(--sa-green);
}

.form-msg.error {
  display: block;
  background: #fbeceb;
  color: var(--sa-red);
  border: 1px solid var(--sa-red);
}

/* Star rating */
.star-rating {
  display: flex;
  gap: 6px;
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.star-rating button {
  background: none;
  border: none;
  color: var(--sa-gray-line);
  padding: 0;
  line-height: 1;
}

.star-rating button.filled {
  color: var(--sa-gold);
}

/* -------------------- Contact page -------------------- */
.contact-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 34px;
  align-items: start;
}

@media (max-width: 860px) {
  .contact-layout {
    grid-template-columns: 1fr;
  }
}

.contact-info-card {
  background: var(--sa-black);
  color: var(--sa-white);
  border-radius: var(--radius);
  padding: 28px;
}

.contact-info-card h3 {
  color: var(--sa-gold);
  font-size: 1.05rem;
}

.contact-info-card ul li {
  padding: 10px 0;
  border-bottom: 1px solid #262626;
  font-size: 0.92rem;
}

.contact-info-card ul li:last-child {
  border-bottom: none;
}

.contact-info-card .label {
  display: block;
  color: #9a9a9a;
  font-size: 0.75rem;
  margin-bottom: 2px;
}

/* -------------------- CTA band -------------------- */
.cta-band {
  background: var(--sa-blue);
  color: var(--sa-white);
  padding: 48px 0;
  text-align: center;
}

.cta-band h2 {
  color: var(--sa-white);
  font-size: 1.5rem;
}

.cta-band p {
  color: #d7d7ec;
  margin-bottom: 22px;
}

.cta-band .btn-group {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* -------------------- Footer -------------------- */
.site-footer {
  background: var(--sa-black);
  color: #cfcfcf;
  padding: 40px 0 20px;
  border-top: 6px solid var(--sa-green);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 26px;
  margin-bottom: 26px;
}

@media (max-width: 760px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.footer-brand img {
  height: 34px;
  width: 34px;
  border-radius: 50%;
}

.footer-brand span {
  color: var(--sa-white);
  font-weight: bold;
}

.footer-tagline {
  font-size: 0.85rem;
  color: #9a9a9a;
}

.site-footer h4 {
  color: var(--sa-white);
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.site-footer ul li {
  margin-bottom: 8px;
  font-size: 0.86rem;
}

.site-footer a {
  color: #cfcfcf;
}

.site-footer a:hover {
  color: var(--sa-gold);
}

.footer-bottom {
  border-top: 1px solid #262626;
  padding-top: 16px;
  font-size: 0.78rem;
  color: #7a7a7a;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* -------------------- Utility -------------------- */
.text-center {
  text-align: center;
}

.mt-0 {
  margin-top: 0;
}

.badge-flag {
  display: inline-flex;
  gap: 3px;
  vertical-align: middle;
}

.badge-flag span {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* -------------------------------------------------------
   AI ASSISTANT CHAT WIDGET (rule-based, vanilla JS only)
   ------------------------------------------------------- */
.chat-toggle {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--sa-green);
  color: var(--sa-white);
  border: 3px solid var(--sa-black);
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-toggle:hover {
  background: var(--sa-gold);
  color: var(--sa-black);
}

.chat-panel {
  position: fixed;
  right: 22px;
  bottom: 90px;
  z-index: 200;
  width: 320px;
  max-width: calc(100vw - 44px);
  max-height: 70vh;
  background: var(--sa-white);
  border: 2px solid var(--sa-black);
  border-radius: var(--radius);
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.chat-panel.open {
  display: flex;
}

.chat-head {
  background: var(--sa-black);
  color: var(--sa-white);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--sa-green);
}

.chat-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.chat-head-title img {
  height: 26px;
  width: 26px;
  border-radius: 50%;
}

.chat-close {
  background: none;
  border: none;
  color: var(--sa-white);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
}

.chat-close:hover {
  color: var(--sa-gold);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--sa-gray-bg);
}

.chat-msg {
  max-width: 85%;
  padding: 9px 11px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.45;
}

.chat-msg.bot {
  background: var(--sa-white);
  border: 1px solid var(--sa-gray-line);
  align-self: flex-start;
}

.chat-msg.user {
  background: var(--sa-blue);
  color: var(--sa-white);
  align-self: flex-end;
}

.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
  background: var(--sa-gray-bg);
}

.chat-quick-replies button {
  background: var(--sa-white);
  border: 1px solid var(--sa-blue);
  color: var(--sa-blue);
  font-size: 0.75rem;
  padding: 5px 9px;
  border-radius: 12px;
}

.chat-quick-replies button:hover {
  background: var(--sa-blue);
  color: var(--sa-white);
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--sa-gray-line);
  background: var(--sa-white);
}

.chat-form input {
  flex: 1;
  font-family: var(--font-main);
  padding: 9px 10px;
  border: 1px solid var(--sa-gray-line);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.chat-form button {
  background: var(--sa-green);
  color: var(--sa-white);
  border: none;
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 0.85rem;
}

.chat-form button:hover {
  background: var(--sa-gold);
  color: var(--sa-black);
}

.chat-disclaimer {
  font-size: 0.68rem;
  color: #7a7a7a;
  padding: 6px 12px 10px;
  background: var(--sa-white);
  text-align: center;
}

@media (max-width: 420px) {
  .chat-panel {
    right: 12px;
    left: 12px;
    width: auto;
  }
  .chat-toggle {
    right: 16px;
    bottom: 16px;
  }
}

/* =========================================================
   ADDED — plumber contact actions, profile modal, status text
   ========================================================= */

.plumber-contact-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.plumber-contact-actions .btn-small {
  flex: 1;
  text-align: center;
}

.btn-small {
  display: inline-block;
  padding: 7px 8px;
  font-size: 0.75rem;
  border: 1px solid var(--sa-blue);
  border-radius: var(--radius);
  color: var(--sa-blue);
  background: var(--sa-white);
}

.btn-small:hover {
  background: var(--sa-blue);
  color: var(--sa-white);
}

#search-status,
#directory-status,
#availability-status {
  font-size: 0.85rem;
  color: #5a5a5a;
  margin: 0 0 14px;
}

/* -------------------- Plumber profile modal -------------------- */
.profile-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.profile-modal.open {
  display: flex;
}

.profile-modal-card {
  background: var(--sa-white);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px;
  position: relative;
}

.profile-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--sa-text);
}

.profile-photo {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--sa-black);
  color: var(--sa-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: bold;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

/* Real plumber photos (once uploaded to images/plumbers/) sit on top of
   the initials as a background fallback — see plumberAvatarHtml() in
   js/script.js. If the image 404s, its onerror handler removes the <img>
   and the initials show through automatically. */
.plumber-photo img,
.profile-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

.plumber-photo-fallback {
  position: relative;
  z-index: 1;
}

.plumber-photo.has-photo::after {
  z-index: 3;
}

.profile-modal-card h2 {
  margin: 0 0 4px;
}

.profile-spec {
  color: var(--sa-blue);
  margin: 0 0 10px;
}

.profile-list {
  list-style: none;
  padding: 0;
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.profile-background {
  font-size: 0.88rem;
  color: #4b4b4b;
  background: var(--sa-gray-bg);
  padding: 10px 12px;
  border-radius: var(--radius);
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.profile-actions .btn-primary {
  flex: 1 1 100%;
}
