/* Pilgrim WebChat v3.0.0 - No redesign beyond required UI behaviors */
:root{
  --pwc-bg:#ffffff;
  --pwc-text:#0f172a;
  --pwc-muted:#5b6b7b;
  --pwc-line:rgba(15,23,42,.12);
  --pwc-shadow: 0 18px 50px rgba(15,23,42,.16);
  --pwc-radius: 16px;
  --pwc-accent:#ff7800;
  --pwc-accent2:#ffc107;
  --pwc-danger:#dc3545;
  --pwc-font: system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}

.pwc-theme-saffron{ --pwc-accent:#ff7800; --pwc-accent2:#ffc107; --pwc-bg:#ffffff; --pwc-text:#0f172a; }
.pwc-theme-ocean{ --pwc-accent:#0ea5e9; --pwc-accent2:#22c55e; --pwc-bg:#ffffff; --pwc-text:#0f172a; }
.pwc-theme-emerald{ --pwc-accent:#10b981; --pwc-accent2:#84cc16; --pwc-bg:#ffffff; --pwc-text:#0f172a; }
.pwc-theme-midnight{ --pwc-accent:#6366f1; --pwc-accent2:#0ea5e9; --pwc-bg:#0b1220; --pwc-text:#e5e7eb; --pwc-muted:#94a3b8; --pwc-line:rgba(148,163,184,.22); }
.pwc-theme-royal{ --pwc-accent:#7c3aed; --pwc-accent2:#f59e0b; --pwc-bg:#ffffff; --pwc-text:#0f172a; }

.pwc-root{ position:relative; z-index:999999; }

/* Launcher button */
.pwc-launcher{
  position:fixed;
  bottom:18px;
  right:18px;
  width:56px;
  height:56px;
  border-radius:999px;
  border:0;
  background:var(--pwc-accent);
  box-shadow:var(--pwc-shadow);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
}
.pwc-launcher svg{ width:24px; height:24px; fill:currentColor; }

.pwc-launcher.pwc-left{ right:auto; left:18px; }

/* Panel (desktop sidebar / mobile full screen) */
.pwc-panel{
  position:fixed;
  bottom:18px;
  right:18px;
  width:360px;
  height:520px;
  background:var(--pwc-bg);
  color:var(--pwc-text);
  border:1px solid var(--pwc-line);
  border-radius:var(--pwc-radius);
  box-shadow:var(--pwc-shadow);
  overflow:hidden;
  display:none;
}
.pwc-panel.pwc-open{ display:block; }
.pwc-panel.pwc-left{ right:auto; left:18px; }

.pwc-head{
  height:56px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 12px;
  border-bottom:1px solid var(--pwc-line);
  background: linear-gradient(0deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 100%), var(--pwc-bg);
}
.pwc-head .pwc-title{
  display:flex;
  align-items:center;
  gap:10px;
  font-family:var(--pwc-font);
}
.pwc-badge{
  width:34px; height:34px;
  border-radius:10px;
  background:var(--pwc-accent);
  display:flex; align-items:center; justify-content:center;
  color:#fff; font-weight:700;
}
.pwc-actions{ display:flex; gap:6px; }
.pwc-iconbtn{
  border:1px solid var(--pwc-line);
  background:transparent;
  color:var(--pwc-text);
  border-radius:10px;
  width:34px; height:34px;
  cursor:pointer;
}

.pwc-body{ height:calc(100% - 56px); display:flex; flex-direction:column; }

/* Channel chooser */
.pwc-chooser{
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.pwc-chooser .pwc-greeting{
  font-family:var(--pwc-font);
  font-size:14px;
  color:var(--pwc-muted);
}
.pwc-grid{
  display:grid;
  grid-template-columns:repeat(2, 1fr);
  gap:10px;
}
.pwc-card{
  border:1px solid var(--pwc-line);
  border-radius:14px;
  padding:12px;
  display:flex;
  align-items:center;
  gap:10px;
  cursor:pointer;
  user-select:none;
  transition: transform .12s ease, border-color .12s ease;
}
.pwc-card:hover{ transform: translateY(-1px); border-color: rgba(15,23,42,.20); }
.pwc-card .pwc-ico{ width:34px; height:34px; border-radius:12px; display:flex; align-items:center; justify-content:center; color:#fff; }
.pwc-card .pwc-ico svg{ width:18px; height:18px; display:block; }
.pwc-card .pwc-label{ font-family:var(--pwc-font); font-weight:600; font-size:14px; }
.pwc-sub{ font-family:var(--pwc-font); font-size:12px; color:var(--pwc-muted); margin-top:2px; }

.pwc-ico-web{ background:var(--pwc-accent); }
.pwc-ico-wa{ background:#25D366; }
.pwc-ico-ms{ background:#0084FF; }
.pwc-ico-ig{ background:#E1306C; }

.pwc-cancel{
  margin-top:8px;
  border:1px solid var(--pwc-line);
  background:transparent;
  border-radius:12px;
  padding:10px;
  cursor:pointer;
}

/* Mobile-app style chooser (bigger icons + centered) */
.pwc-chooser-screen{
  background: radial-gradient(1200px 600px at 70% 30%, rgba(255,255,255,.18), rgba(255,255,255,0) 55%),
              linear-gradient(135deg, rgba(79,70,229,.95), rgba(14,165,233,.90));
}
.pwc-chooser-screen .pwc-chooser{
  height:100%;
  justify-content:center;
  align-items:center;
  padding:22px 18px;
  gap:16px;
}
.pwc-chooser-screen .pwc-greeting{
  color:rgba(255,255,255,.92);
  font-size:22px;
  font-weight:700;
  text-align:center;
  line-height:1.25;
}
.pwc-chooser-screen .pwc-grid{ gap:14px; width:min(520px, 100%); }
.pwc-chooser-screen .pwc-card{
  background: rgba(255,255,255,.14);
  border:1px solid rgba(255,255,255,.20);
  padding:18px 12px;
  flex-direction:column;
  text-align:center;
  gap:10px;
}
.pwc-chooser-screen .pwc-card:hover{ transform: translateY(-2px); border-color: rgba(255,255,255,.35); }
.pwc-chooser-screen .pwc-card .pwc-ico{
  width:92px;
  height:92px;
  border-radius:999px;
  box-shadow: 0 10px 28px rgba(0,0,0,.20);
}
.pwc-chooser-screen .pwc-card .pwc-ico svg{ width:44px; height:44px; }
.pwc-chooser-screen .pwc-card .pwc-label{ color:#fff; font-size:16px; }
.pwc-chooser-screen .pwc-sub{ color:rgba(255,255,255,.75); }
.pwc-chooser-screen .pwc-cancel{
  width:min(520px, 100%);
  background: rgba(255,255,255,.18);
  border:1px solid rgba(255,255,255,.22);
  color:#fff;
  font-weight:600;
}

/* Smooth animation between chooser and chat */
.pwc-view{ position:relative; height:100%; }
.pwc-screen{ position:absolute; inset:0; opacity:0; transform: translateX(8px); pointer-events:none; transition: opacity .18s ease, transform .18s ease; }
.pwc-panel.pwc-left .pwc-screen{ transform: translateX(-8px); }
.pwc-screen.pwc-active{ opacity:1; transform: translateX(0); pointer-events:auto; }

/* Chat view */
.pwc-chat{
  display:flex;
  flex-direction:column;
  height:100%;
}
.pwc-chat-top{
  padding:10px 12px;
  border-bottom:1px solid var(--pwc-line);
  display:flex;
  align-items:center;
  gap:8px;
}
.pwc-back{
  border:1px solid var(--pwc-line);
  background:transparent;
  border-radius:10px;
  width:34px;
  height:34px;
  cursor:pointer;
}
.pwc-chat-title{ font-family:var(--pwc-font); font-weight:700; font-size:14px; }
.pwc-chat-sub{ font-family:var(--pwc-font); font-size:12px; color:var(--pwc-muted); }

.pwc-messages{
  flex:1;
  overflow:auto;
  padding:12px;
  background:rgba(0,0,0,0.02);
}

.pwc-msg{
  max-width:85%;
  margin:8px 0;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--pwc-line);
  font-family:var(--pwc-font);
  font-size:14px;
  line-height:1.35;
  white-space:pre-wrap;
  word-wrap:break-word;
}
.pwc-msg.pwc-me{ margin-left:auto; background:var(--pwc-accent); color:#fff; border-color: rgba(0,0,0,0); }
.pwc-msg.pwc-bot{ margin-right:auto; background:var(--pwc-bg); }

/* typing indicator removed */

.pwc-newpill{
  position:sticky;
  bottom:8px;
  margin:0 auto;
  width:fit-content;
  background:rgba(0,0,0,0.72);
  color:#fff;
  border-radius:999px;
  padding:6px 10px;
  font-family:var(--pwc-font);
  font-size:12px;
  cursor:pointer;
  display:none;
}
.pwc-newpill.pwc-show{ display:block; }

.pwc-input{
  border-top:1px solid var(--pwc-line);
  padding:10px;
  display:flex;
  gap:8px;
  background:var(--pwc-bg);
}
.pwc-input textarea{
  flex:1;
  resize:none;
  height:38px;
  max-height:120px;
  padding:9px 10px;
  border-radius:12px;
  border:1px solid var(--pwc-line);
  font-family:var(--pwc-font);
  font-size:14px;
  outline:none;
  color:var(--pwc-text);
  background:transparent;
}
.pwc-send{
  width:42px;
  height:42px;
  border-radius:12px;
  border:0;
  background:var(--pwc-accent);
  color:#fff;
  cursor:pointer;
}

.pwc-attach{
  width:42px;
  height:42px;
  border-radius:12px;
  border:1px solid var(--pwc-line);
  background:transparent;
  color:var(--pwc-text);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}
.pwc-attach svg{ width:20px; height:20px; }

.pwc-teaser{
  position:fixed;
  z-index:99998;
  max-width: min(320px, calc(100vw - 40px));
  background: rgba(15,23,42,.92);
  color:#fff;
  padding:10px 12px;
  border-radius:14px;
  box-shadow: 0 14px 36px rgba(0,0,0,.22);
  font-size:13px;
  line-height:1.25;
  opacity:0;
  transform: translateY(6px);
  pointer-events:none;
  transition: opacity .18s ease, transform .18s ease;
}
.pwc-teaser.pwc-show{ opacity:1; transform: translateY(0); }
.pwc-teaser:after{
  content:"";
  position:absolute;
  bottom:-8px;
  right:18px;
  width:0;height:0;
  border-left:8px solid transparent;
  border-right:8px solid transparent;
  border-top:8px solid rgba(15,23,42,.92);
}
.pwc-teaser.pwc-left:after{ right:auto; left:18px; }

/* Mobile full screen */
@media (max-width: 720px){
  .pwc-panel{
    left:0 !important;
    right:0 !important;
    bottom:0 !important;
    top:0 !important;
    width:100% !important;
    height:100% !important;
    border-radius:0 !important;
  }
  .pwc-launcher{ bottom:18px; }
}

/* External edit modal (only template text editable) */
.pwc-edit-overlay{position:fixed;inset:0;z-index:2147483646;background:rgba(15,23,42,.55);display:flex;align-items:center;justify-content:center;padding:16px}
.pwc-edit-box{width:min(520px,100%);background:var(--pwc-card,#fff);border-radius:18px;box-shadow:0 20px 60px rgba(0,0,0,.25);padding:14px;border:1px solid rgba(15,23,42,.10)}
.pwc-edit-head{font-weight:900;font-size:15px;margin-bottom:10px;color:var(--pwc-text,#0f172a)}
.pwc-edit-text{width:100%;min-height:120px;resize:vertical;border-radius:14px;border:1px solid rgba(15,23,42,.15);padding:12px;font-size:14px;line-height:1.4;outline:none}
.pwc-edit-note{margin-top:8px;font-size:12px;color:var(--pwc-muted,#5b6b7b)}
.pwc-edit-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:12px}
.pwc-btn{border:0;border-radius:14px;padding:10px 14px;font-weight:800;cursor:pointer}
.pwc-btn-ghost{background:rgba(15,23,42,.06);color:var(--pwc-text,#0f172a)}
.pwc-btn-primary{background:var(--pwc-accent,#ff7800);color:#fff}
