/* ── DAVAR AI web chat — light tech full-screen experience ─────────────────── */

:root {
  --wc-bg: #f8fafc;
  --wc-surface: #ffffff;
  --wc-border: rgba(22, 117, 117, 0.14);
  --wc-teal: #167575;
  --wc-teal-soft: #0d9488;
  --wc-accent: #167575;
  --wc-text: #0f172a;
  --wc-muted: #64748b;
}

body.wc-home-active {
  overflow: hidden;
  height: 100dvh;
  max-height: 100dvh;
}

html:has(body.wc-home-active) {
  overflow: hidden;
  height: 100%;
}

body.wc-home-active #app {
  flex: 1;
  min-height: 0;
  max-height: 100dvh;
  overflow: hidden;
}

body.wc-home-active .footer,
body.wc-home-active .back-to-top,
body.wc-home-active .whatsapp-fab {
  display: none !important;
}

body.wc-home-active #main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.wc-home-active .header,
html.dark-mode body.wc-home-active .header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(22, 117, 117, 0.1);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

/* ── Canvas ─────────────────────────────────────────────────────────────────── */
.wc-fullscreen {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--wc-text);
  background:
    radial-gradient(ellipse 90% 60% at 50% -15%, rgba(22, 117, 117, 0.1) 0%, transparent 55%),
    radial-gradient(ellipse 45% 40% at 100% 85%, rgba(13, 148, 136, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, #f0fdfa 0%, #ffffff 42%, #f8fafc 100%);
}

.wc-tech-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  background-image:
    linear-gradient(rgba(22, 117, 117, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 117, 117, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 85% 75% at 50% 35%, black 20%, transparent 72%);
}

.wc-tech-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle 420px at 50% 18%, rgba(22, 117, 117, 0.06), transparent 65%),
    radial-gradient(circle 280px at 85% 75%, rgba(13, 148, 136, 0.05), transparent 60%);
  animation: wc-glow-shift 12s ease-in-out infinite alternate;
}

@keyframes wc-glow-shift {
  from { opacity: 0.85; transform: scale(1); }
  to { opacity: 1; transform: scale(1.03); }
}

.wc-sketches {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  opacity: 0.55;
}

.wc-sketch {
  position: absolute;
  opacity: 0.2;
  color: var(--wc-teal);
  animation: wc-sketch-float 9s ease-in-out infinite;
}

.wc-sketch svg { width: 100%; height: 100%; overflow: visible; }

.wc-sketch .wc-draw {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  animation: wc-sketch-draw 4s ease forwards, wc-sketch-pulse 6s ease-in-out 4s infinite;
}

.wc-sketch--house { width: 130px; height: 100px; top: 10%; left: 5%; }
.wc-sketch--buildings { width: 110px; height: 120px; top: 16%; right: 6%; animation-delay: -2s; }
.wc-sketch--key { width: 64px; height: 64px; bottom: 26%; left: 8%; animation-delay: -4s; }
.wc-sketch--plan { width: 92px; height: 92px; bottom: 20%; right: 10%; animation-delay: -1s; }
.wc-sketch--pin { width: 50px; height: 66px; top: 40%; left: 3%; animation-delay: -3s; }
.wc-sketch--tree { width: 72px; height: 82px; top: 52%; right: 4%; animation-delay: -5s; }

@keyframes wc-sketch-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes wc-sketch-draw { to { stroke-dashoffset: 0; } }

@keyframes wc-sketch-pulse {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.wc-fullscreen-inner {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem calc(1rem + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}

.wc-fullscreen.wc-has-chat .wc-fullscreen-inner { overflow: hidden; }

/* ── DAVAR AI brand ─────────────────────────────────────────────────────────── */
.wc-welcome {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 0.5rem;
  transition: opacity 0.45s ease, transform 0.45s ease, flex 0.5s ease, max-height 0.5s ease;
  overflow: hidden;
  min-height: 0;
}

.wc-fullscreen.wc-has-chat .wc-welcome {
  flex: 0;
  opacity: 0;
  transform: translateY(-20px);
  max-height: 0;
  padding: 0;
  pointer-events: none;
}

.wc-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
  animation: wc-fade-up 0.65s ease both;
}

.wc-brand-mark {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 14px;
  overflow: hidden;
  filter: drop-shadow(0 4px 14px rgba(22, 117, 117, 0.2));
}

.wc-brand-mark img,
.wc-brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.wc-brand-copy { text-align: start; }

.wc-brand-name {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.15rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
}

.wc-brand-davar {
  color: #0f172a;
}

.wc-brand-ai {
  margin-inline-start: 0.35rem;
  background: linear-gradient(135deg, #167575, #0d9488 55%, #14b8a6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.wc-brand-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wc-muted);
}

.wc-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.8);
  animation: wc-pulse-dot 2s ease-in-out infinite;
}

@keyframes wc-pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(0.92); }
}

.wc-welcome-title {
  font-size: clamp(1.5rem, 4.2vw, 2.35rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: #0f172a;
  margin: 0 0 0.75rem;
  max-width: 560px;
  animation: wc-fade-up 0.7s ease 0.1s both;
}

.wc-welcome-sub {
  font-size: clamp(0.95rem, 2.4vw, 1.08rem);
  color: var(--wc-muted);
  margin: 0;
  max-width: 520px;
  line-height: 1.6;
  animation: wc-fade-up 0.7s ease 0.18s both;
}

@keyframes wc-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Suggestions ────────────────────────────────────────────────────────────── */
.wc-chat-stage {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wc-fullscreen:not(.wc-has-chat) .wc-chat-stage { flex: 0 0 auto; }
.wc-fullscreen.wc-has-chat .wc-chat-stage { flex: 1; min-height: 0; }

.wc-suggestions-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  width: 100%;
  padding: 0 0 0.85rem;
  flex-shrink: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.wc-fullscreen.wc-has-chat .wc-suggestions-wrap {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

.wc-chip {
  border: 1px solid var(--wc-border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  color: #334155;
  border-radius: 999px;
  padding: 0.55rem 1.05rem;
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s, background 0.2s;
  animation: wc-fade-up 0.5s ease both;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.wc-chip:nth-child(2) { animation-delay: 0.06s; }
.wc-chip:nth-child(3) { animation-delay: 0.12s; }
.wc-chip:nth-child(4) { animation-delay: 0.18s; }

.wc-chip:hover {
  background: #fff;
  border-color: rgba(22, 117, 117, 0.45);
  color: #167575;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(22, 117, 117, 0.12);
}

.wc-chip--link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.wc-browse-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.85rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--wc-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.wc-browse-link:hover { color: var(--wc-teal); }

/* ── Chat shell ─────────────────────────────────────────────────────────────── */
.wc-chat {
  background: var(--wc-surface);
  border: 1px solid var(--wc-border);
  border-radius: 20px;
  overflow: hidden;
  text-align: start;
  width: 100%;
}

.wc-chat--fullscreen {
  background: transparent;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.wc-chat--fullscreen .wc-input-row,
.wc-chat--fullscreen .wc-disclaimer,
.wc-chat--fullscreen .wc-phone-row {
  flex-shrink: 0;
}

.wc-messages {
  min-height: 160px;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.wc-chat--fullscreen .wc-messages {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  padding: 0.35rem 0.15rem 0.75rem;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.wc-chat--fullscreen .wc-messages::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.wc-chat--compact .wc-messages {
  min-height: 160px;
  max-height: 280px;
}

/* ── Messages ───────────────────────────────────────────────────────────────── */
.wc-msg {
  display: flex;
  gap: 0.65rem;
  animation: wc-msg-in 0.35s ease both;
}

@keyframes wc-msg-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.wc-msg--user {
  justify-content: flex-end;
}

.wc-msg--bot { align-items: flex-start; }

.wc-msg-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(22, 117, 117, 0.12), rgba(13, 148, 136, 0.08));
  border: 1px solid rgba(22, 117, 117, 0.22);
  box-shadow: 0 2px 8px rgba(22, 117, 117, 0.1);
}

.wc-avatar-img {
  width: 28px;
  height: 28px;
  display: block;
  object-fit: contain;
  border-radius: 6px;
}

.wc-avatar--pulse {
  animation: wc-avatar-glow 1.4s ease-in-out infinite;
}

@keyframes wc-avatar-glow {
  0%, 100% { box-shadow: 0 2px 8px rgba(22, 117, 117, 0.1); border-color: rgba(22, 117, 117, 0.22); }
  50% { box-shadow: 0 0 18px rgba(22, 117, 117, 0.28); border-color: rgba(22, 117, 117, 0.5); }
}

.wc-msg-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  max-width: min(92%, 640px);
}

.wc-msg--user .wc-msg-body { max-width: 88%; align-items: flex-end; }

.wc-msg-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(22, 117, 117, 0.75);
  padding-inline-start: 0.15rem;
}

.wc-bubble {
  padding: 0.8rem 1rem;
  border-radius: 16px;
  font-size: 0.94rem;
  line-height: 1.58;
  word-break: break-word;
}

.wc-msg--user .wc-bubble {
  background: linear-gradient(135deg, #167575, #0d9488);
  color: #fff;
  border: 1px solid rgba(22, 117, 117, 0.2);
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 16px rgba(22, 117, 117, 0.22);
}

[dir="rtl"] .wc-msg--user .wc-bubble {
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 6px;
}

.wc-msg--bot .wc-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

[dir="rtl"] .wc-msg--bot .wc-bubble {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 6px;
}

.wc-bubble--typing {
  padding: 0.85rem 1.1rem;
  min-width: 64px;
}

.wc-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 10px;
}

.wc-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wc-teal);
  animation: wc-dot-bounce 1.25s infinite ease-in-out;
}

.wc-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.wc-typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes wc-dot-bounce {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.35; }
  35% { transform: translateY(-5px); opacity: 1; }
}

.wc-msg--typing { opacity: 0.95; }

.wc-chat--agent-turn .wc-input-row {
  opacity: 0.72;
  pointer-events: none;
}

/* ── Input ──────────────────────────────────────────────────────────────────── */
.wc-phone-row { padding: 0 0.25rem 0.5rem; }

.wc-phone-label {
  display: block;
  font-size: 0.72rem;
  color: var(--wc-muted);
  margin-bottom: 0.25rem;
}

.wc-phone-input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  background: #fff;
  color: var(--wc-text);
}

.wc-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  padding: 0.75rem 1rem 0.5rem;
  border-top: 1px solid #e2e8f0;
}

.wc-chat--fullscreen .wc-input-row {
  border-top: none;
  padding: 0.55rem 0.45rem 0.55rem 0.85rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(22, 117, 117, 0.16);
  border-radius: 18px;
  box-shadow:
    0 8px 28px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: border-color 0.25s, box-shadow 0.25s, opacity 0.25s;
}

.wc-chat--fullscreen .wc-input-row:focus-within {
  border-color: rgba(22, 117, 117, 0.45);
  box-shadow:
    0 10px 32px rgba(22, 117, 117, 0.12),
    0 0 0 3px rgba(22, 117, 117, 0.08);
}

.wc-input {
  flex: 1;
  border: none;
  resize: none;
  font: inherit;
  font-size: 0.98rem;
  line-height: 1.45;
  max-height: 120px;
  background: transparent;
  color: #0f172a;
  outline: none;
  padding: 0.55rem 0;
}

.wc-input::placeholder { color: #94a3b8; }

.wc-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #167575, #0d9488);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.15s;
  box-shadow: 0 4px 14px rgba(22, 117, 117, 0.28);
}

.wc-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(22, 117, 117, 0.32);
}

.wc-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wc-disclaimer {
  margin: 0;
  padding: 0.45rem 0.35rem 0;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  color: #64748b;
  text-align: center;
}

/* ── Floating widget (other pages) ─────────────────────────────────────────── */
#web-chat-root {
  position: fixed;
  z-index: 9990;
  inset-inline-end: 1.25rem;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

.wc-fab {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: linear-gradient(145deg, #0f766e, #115e59);
  color: #fff;
  box-shadow: 0 8px 28px rgba(22, 117, 117, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.wc-fab:hover { transform: scale(1.05); }

.wc-panel {
  position: absolute;
  inset-inline-end: 0;
  bottom: calc(100% + 12px);
  width: min(380px, calc(100vw - 2rem));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.14);
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.wc-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #115e59, #0f766e);
  color: #fff;
}

.wc-panel-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.wc-panel-body .wc-chat {
  border: none;
  border-radius: 0;
  background: #f8fafc;
}

.wc-panel-body .wc-msg--bot .wc-bubble {
  background: #fff;
}

body.wc-home-active .wc-fab { display: none; }

@media (max-width: 640px) {
  .wc-fullscreen-inner { padding-inline: 0.85rem; }
  .wc-brand { flex-direction: column; text-align: center; gap: 0.75rem; }
  .wc-brand-copy { text-align: center; }
  .wc-brand-status { justify-content: center; }
  .wc-sketch--key, .wc-sketch--plan, .wc-sketch--pin, .wc-sketch--tree { display: none; }
  .wc-msg-body { max-width: 94%; }
}

@media (prefers-reduced-motion: reduce) {
  .wc-sketch, .wc-sketch .wc-draw, .wc-brand, .wc-welcome-title, .wc-welcome-sub,
  .wc-chip, .wc-msg, .wc-tech-glow, .wc-status-dot, .wc-avatar--pulse, .wc-typing-dots span {
    animation: none !important;
  }
  .wc-sketch .wc-draw { stroke-dashoffset: 0; }
}
