/* ════════════════════════════════════════════════════════════
   KSDigital Assistant — Widget Styles
   Άλλαξε τα χρώματα στα :root variables για brand matching.
   ════════════════════════════════════════════════════════════ */

:root {
  --ksb-primary:        #1a73e8;   /* brand χρώμα κουμπιού/headers */
  --ksb-primary-dark:   #1559b0;
  --ksb-accent:         #00c389;   /* CTA / send button */
  --ksb-bg:             #ffffff;
  --ksb-bot-bubble:     #f1f4f9;
  --ksb-user-bubble:    #1a73e8;
  --ksb-text:           #1f2733;
  --ksb-text-light:     #ffffff;
  --ksb-muted:          #6b7785;
  --ksb-border:         #e4e9f0;
  --ksb-shadow:         0 12px 40px rgba(16, 30, 54, 0.18);

  /* Θέση: ανέβασέ το πιο ψηλά αν "πατάει" πάνω σε WhatsApp/Viber */
  --ksb-offset-bottom:  92px;
  --ksb-offset-right:   20px;
}

/* ── Floating button ──────────────────────────────────────── */
.ksb-launcher {
  position: fixed;
  bottom: var(--ksb-offset-bottom);
  right: var(--ksb-offset-right);
  width: 60px; height: 60px;
  border: none; border-radius: 50%;
  background: var(--ksb-primary);
  color: var(--ksb-text-light);
  cursor: pointer;
  box-shadow: var(--ksb-shadow);
  display: flex; align-items: center; justify-content: center;
  z-index: 99998;
  transition: transform .2s ease, background .2s ease;
}
.ksb-launcher:hover { transform: scale(1.07); background: var(--ksb-primary-dark); }
.ksb-launcher svg { width: 28px; height: 28px; }
.ksb-launcher .ksb-close-icon { display: none; }
.ksb-launcher.ksb-open .ksb-chat-icon  { display: none; }
.ksb-launcher.ksb-open .ksb-close-icon { display: block; }

/* μικρό badge ειδοποίησης */
.ksb-launcher .ksb-badge {
  position: absolute; top: -2px; right: -2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--ksb-accent); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ── Panel ────────────────────────────────────────────────── */
.ksb-panel {
  position: fixed;
  bottom: calc(var(--ksb-offset-bottom) + 72px);
  right: var(--ksb-offset-right);
  width: 380px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 160px);
  background: var(--ksb-bg);
  border-radius: 16px;
  box-shadow: var(--ksb-shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  opacity: 0; transform: translateY(16px) scale(.98);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.ksb-panel.ksb-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* ── Header ───────────────────────────────────────────────── */
.ksb-header {
  background: var(--ksb-primary);
  color: var(--ksb-text-light);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 12px;
}
.ksb-header .ksb-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.ksb-header .ksb-title { font-weight: 700; font-size: 15px; }
.ksb-header .ksb-status { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 5px; }
.ksb-header .ksb-status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ksb-accent);
}
.ksb-header-close {
  margin-left: auto;
  width: 32px; height: 32px; flex: 0 0 32px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff;
  font-size: 15px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.ksb-header-close:hover { background: rgba(255,255,255,.32); }

/* ── Body (περιέχει συνομιλία + φόρμα overlay) ─────────────── */
.ksb-body {
  position: relative;       /* offset parent για το lead form overlay */
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ── Messages ─────────────────────────────────────────────── */
.ksb-messages {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px; background: #fafbfc;
  display: flex; flex-direction: column; gap: 10px;
}
.ksb-msg {
  max-width: 85%;
  padding: 10px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.5; color: var(--ksb-text);
  white-space: pre-wrap; word-wrap: break-word;
}
.ksb-msg.ksb-bot  { background: var(--ksb-bot-bubble); border-bottom-left-radius: 4px; align-self: flex-start; }
.ksb-msg.ksb-user { background: var(--ksb-user-bubble); color: var(--ksb-text-light); border-bottom-right-radius: 4px; align-self: flex-end; }
.ksb-msg a { color: inherit; text-decoration: underline; }
.ksb-msg strong { font-weight: 700; }
.ksb-msg code {
  background: rgba(0,0,0,.06); padding: 1px 5px;
  border-radius: 4px; font-size: 13px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* typing indicator */
.ksb-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.ksb-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ksb-muted); opacity: .5;
  animation: ksb-bounce 1.2s infinite ease-in-out;
}
.ksb-typing span:nth-child(2) { animation-delay: .15s; }
.ksb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ksb-bounce { 0%,60%,100%{transform:translateY(0);opacity:.5;} 30%{transform:translateY(-5px);opacity:1;} }

/* ── Quick actions ────────────────────────────────────────── */
.ksb-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }
.ksb-quick button {
  background: #fff; border: 1px solid var(--ksb-border);
  color: var(--ksb-primary); font-size: 13px;
  padding: 8px 12px; border-radius: 18px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.ksb-quick button:hover { background: var(--ksb-bot-bubble); border-color: var(--ksb-primary); }

/* CTA "άσε στοιχεία" μέσα στη συνομιλία */
.ksb-cta { align-self: flex-start; }
.ksb-cta-btn {
  background: var(--ksb-accent); color: #fff; border: none;
  padding: 9px 14px; border-radius: 18px; font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.ksb-cta-btn:hover { filter: brightness(.95); }

/* ── Lead form (overlay μόνο πάνω στη συνομιλία) ───────────── */
.ksb-leadform {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;   /* καλύπτει το .ksb-body, όχι το header */
  background: #fff; z-index: 20;
  padding: 16px; gap: 10px;
  display: none; flex-direction: column;
  overflow-y: auto;                        /* scroll αν δεν χωράει */
}
.ksb-leadform.ksb-show { display: flex; }
.ksb-lead-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 2px;
}
.ksb-lead-title { font-size: 15px; font-weight: 700; color: var(--ksb-text); }
.ksb-lead-close {
  flex: 0 0 30px; width: 30px; height: 30px;
  border: none; border-radius: 50%; background: #eef1f5; color: var(--ksb-muted);
  font-size: 14px; line-height: 1; cursor: pointer;
}
.ksb-lead-close:hover { background: #e2e6ec; }
.ksb-leadform input, .ksb-leadform textarea {
  border: 1px solid var(--ksb-border); border-radius: 8px;
  padding: 9px 11px; font-size: 13px; font-family: inherit; width: 100%; box-sizing: border-box;
}
.ksb-leadform textarea { resize: vertical; min-height: 54px; }
.ksb-leadform .ksb-lead-actions { display: flex; gap: 8px; }
.ksb-leadform .ksb-lead-actions button {
  flex: 1; border: none; border-radius: 8px; padding: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.ksb-leadform .ksb-lead-send   { background: var(--ksb-accent); color: #fff; }
.ksb-leadform .ksb-lead-cancel { background: #eef1f5; color: var(--ksb-muted); }

/* όσο η φόρμα είναι ανοιχτή, κρύψε το input bar για να μην μπερδεύει */
.ksb-panel.ksb-form-open .ksb-inputbar { display: none; }

/* ── Input bar ────────────────────────────────────────────── */
.ksb-inputbar {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 14px; border-top: 1px solid var(--ksb-border); background: #fff;
}
.ksb-inputbar textarea {
  flex: 1; resize: none; border: 1px solid var(--ksb-border);
  border-radius: 20px; padding: 10px 14px;
  font-size: 14px; font-family: inherit; max-height: 110px; line-height: 1.4;
  box-sizing: border-box;
}
.ksb-inputbar textarea:focus { outline: none; border-color: var(--ksb-primary); }
.ksb-send {
  width: 42px; height: 42px; flex: 0 0 42px; border: none; border-radius: 50%;
  background: var(--ksb-primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.ksb-send:disabled { opacity: .45; cursor: default; }
.ksb-send svg { width: 20px; height: 20px; }

/* ── Footer branding ──────────────────────────────────────── */
.ksb-footer {
  text-align: center; font-size: 11px; color: var(--ksb-muted);
  padding: 6px; background: #fff; border-top: 1px solid var(--ksb-border);
}
.ksb-footer a { color: var(--ksb-primary); text-decoration: none; font-weight: 600; }

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ksb-panel {
    width: 100vw; max-width: 100vw;
    left: 0; right: 0; top: 0; bottom: 0;   /* καρφωμένο πάνω+κάτω = γεμίζει την ορατή οθόνη */
    height: 100dvh; max-height: 100dvh;      /* dvh: σέβεται τη μπάρα του browser (iOS fix) */
    border-radius: 0;
  }
}

/* fallback για browsers χωρίς dvh */
@supports not (height: 100dvh) {
  @media (max-width: 480px) {
    .ksb-panel { height: 100vh; max-height: 100vh; }
  }
}
