/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg:          #ffffff;
  --bg-2:        #f7f6f5;
  --bg-3:        #f0eeed;
  --taupe:       #BAAEA2;
  --taupe-dark:  #9a9088;
  --taupe-light: #d4ccc6;
  --text:        #1f2937;
  --text-light:  #6b7280;
  --border:      #e5e2df;
  --black:       #1a1a1a;
  --font-body:   'Inter', 'Helvetica Neue', Arial, sans-serif;
  --radius:      6px;
  --shadow:      0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.14);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--taupe); }
a:hover { color: var(--taupe-dark); text-decoration: underline; }

/* ── Nav ───────────────────────────────────────────────────────────────────── */
.nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

.nav__logo {
  max-height: 40px;
  width: auto;
}

.nav__demo-badge {
  background: var(--taupe);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav__phone-btn {
  margin-left: auto;
  background: var(--black);
  color: #ffffff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 9999px;
  letter-spacing: 0.02em;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  white-space: nowrap;
}
.nav__phone-btn:hover {
  background: var(--taupe);
  color: #ffffff;
  text-decoration: none;
  transform: scale(1.04);
}

/* ── Hero ──────────────────────────────────────────────────────────────────── */
.hero {
  background: url('https://www.lsbyggsnickeri.se/images/IMG_1245.webp') center/cover no-repeat;
  min-height: 680px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  position: relative;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
}

.hero__content {
  position: relative;
  z-index: 1;
  padding: 100px 24px;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.hero__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.7);
  font-size: 15px;
  font-weight: 600;
}

.hero__title {
  font-weight: 700;
  font-size: clamp(38px, 6vw, 68px);
  color: #ffffff;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero__subtitle {
  font-size: 22px;
  color: rgba(255,255,255,0.85);
  max-width: 560px;
  margin-bottom: 4px;
}

.hero__cta {
  background: var(--black);
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  padding: 16px 38px;
  font-size: 22px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.hero__cta:hover { background: var(--taupe); transform: scale(1.04); }

.hero__link {
  color: var(--taupe);
  text-decoration: none;
  font-size: 15px;
  transition: color 0.2s;
}
.hero__link:hover { color: var(--taupe-dark); text-decoration: underline; }

/* ── Main / Cards ──────────────────────────────────────────────────────────── */
.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 24px 72px;
}

.main__intro {
  text-align: center;
  font-size: 18px;
  max-width: 620px;
  margin: 0 auto 44px;
  color: var(--text);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 28px;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.card__icon {
  font-size: 40px;
  padding: 24px 24px 0;
}

.card__body {
  padding: 16px 24px 24px;
  flex: 1;
}

.card__title {
  font-weight: 700;
  font-size: 20px;
  color: var(--taupe-dark);
  margin-bottom: 8px;
}

.card__text {
  font-size: 15px;
  color: var(--text-light);
  line-height: 1.6;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.footer {
  background: var(--black);
  border-top: none;
  text-align: center;
  padding: 20px 24px;
  font-size: 14px;
  color: rgba(255,255,255,0.75);
}
.footer a { color: var(--taupe-light); }
.footer a:hover { color: #ffffff; text-decoration: underline; }
.footer__sub {
  font-size: 12px;
  margin-top: 6px;
  color: rgba(255,255,255,0.45);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* CHAT WIDGET                                                                 */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* ── FAB (floating action button) ─────────────────────────────────────────── */
#chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--taupe);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(186,174,162,0.50);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow: hidden;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  animation: pulse-fab 2.5s ease-in-out 1s 3;
}
#chat-fab:hover {
  background: var(--taupe-dark);
  transform: scale(1.10);
  box-shadow: 0 6px 24px rgba(186,174,162,0.70);
}
#chat-fab:active { transform: scale(0.93); }
#chat-fab svg { width: 26px; height: 26px; position: relative; z-index: 1; }

/* Ripple burst */
.fab-ripple {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0);
  animation: fab-ripple 0.55s ease-out forwards;
  pointer-events: none;
}
@keyframes fab-ripple {
  to { transform: scale(3.2); opacity: 0; }
}

@keyframes pulse-fab {
  0%   { box-shadow: 0 4px 16px rgba(186,174,162,0.50); }
  50%  { box-shadow: 0 4px 28px rgba(186,174,162,0.80), 0 0 0 10px rgba(186,174,162,0.12); }
  100% { box-shadow: 0 4px 16px rgba(186,174,162,0.50); }
}

/* ── Panel ─────────────────────────────────────────────────────────────────── */
#chat-panel {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 380px;
  height: 540px;
  background: var(--bg);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 999;
  overflow: hidden;
  transform: scale(0.6) translateY(60px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.22s ease;
  border: 1px solid var(--border);
}
#chat-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
  animation: panel-shine 0.6s ease forwards;
}

@keyframes panel-shine {
  0%   { box-shadow: 0 0 0 0 rgba(186,174,162,0.0), var(--shadow-lg); }
  40%  { box-shadow: 0 0 0 6px rgba(186,174,162,0.15), var(--shadow-lg); }
  100% { box-shadow: 0 0 0 0 rgba(186,174,162,0.0), var(--shadow-lg); }
}

/* ── Header ────────────────────────────────────────────────────────────────── */
#chat-header {
  background: var(--bg-2);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

#chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

#chat-logo {
  height: 28px;
  width: auto;
}

#chat-title {
  color: var(--taupe-dark);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
}

#reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-light);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  transition: background 0.2s;
}
#reset-btn:hover { background: var(--bg-3); }
#reset-btn svg { width: 14px; height: 14px; }

/* ── Messages area ─────────────────────────────────────────────────────────── */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
  scroll-behavior: smooth;
}

/* Welcome */
.chat-welcome {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
  max-width: 90%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  animation: welcome-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s both;
}

@keyframes welcome-in {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Suggestion chips */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.chip {
  background: #ffffff;
  border: 1.5px solid var(--taupe);
  color: var(--taupe-dark);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s, color 0.15s;
  line-height: 1.3;
}
.chip:hover {
  background: var(--taupe);
  color: #ffffff;
}

/* Message bubbles */
.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  animation: msg-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes msg-pop {
  from { transform: scale(0.82) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0);        opacity: 1; }
}
.msg--user {
  background: var(--taupe);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  font-weight: 500;
}
.msg--assistant {
  background: var(--bg-2);
  color: var(--text);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}
.msg--error {
  background: #fff5f5;
  color: #c0392b;
  border: 1px solid #fcd0cc;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* Markdown rendering inside assistant bubbles */
.msg--assistant strong { font-weight: bold; color: var(--taupe-dark); }
.msg--assistant em { font-style: italic; }
.msg--assistant ul { padding-left: 18px; margin: 6px 0; }
.msg--assistant li { margin: 2px 0; }
.msg--assistant a { color: var(--taupe); }
.msg--assistant p + p { margin-top: 6px; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--taupe-light);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); background: var(--taupe-light); }
  30%            { transform: translateY(-6px); background: var(--taupe); }
}

/* ── Input area ────────────────────────────────────────────────────────────── */
#chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 9px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}
#chat-input:focus { border-color: var(--taupe); }
#chat-input::placeholder { color: var(--text-light); }

#send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--taupe);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
#send-btn:hover { background: var(--taupe-dark); }
#send-btn:disabled { background: var(--border); cursor: default; }
#send-btn svg { width: 18px; height: 18px; }

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 85vh;
    border-radius: 20px 20px 0 0;
    transform-origin: bottom center;
  }
  #chat-fab {
    bottom: 20px;
    right: 20px;
  }
}
