/* ═══════════════════════════════════════════════════════════
   YA-EVENT AI Chat Widget — Styles
   ═══════════════════════════════════════════════════════════ */

#ya-chat-widget {
  --chat-accent:#b8966c;
  --chat-bg:#faf9f7;
  --chat-ink:#1a1a1a;
  --chat-muted:#71717a;
  --chat-radius:14px;
  position:fixed; bottom:0; right:0; z-index:9999;
  font-family:'Inter','Manrope',Arial,sans-serif;
}

/* ── Toggle button (default: round pill for Tilda etc.) ── */
#ya-chat-toggle {
  position:fixed; bottom:78px; right:24px;
  width:auto; height:60px; border-radius:30px;
  border:none; cursor:pointer;
  background:linear-gradient(135deg,#2a2825,#3a3733);
  color:#fafafa;
  box-shadow:0 4px 16px rgba(0,0,0,0.30);
  display:flex; align-items:center; justify-content:center; gap:10px;
  padding:0 20px 0 16px;
  transition:transform 0.2s, box-shadow 0.2s;
  z-index:10000;
}
#ya-chat-toggle:hover {
  transform:scale(1.04);
  box-shadow:0 6px 24px rgba(0,0,0,0.40);
}
#ya-chat-toggle svg { width:22px; height:22px; flex-shrink:0; }

.ya-chat-badge {
  position:absolute; top:0; right:0;
  width:12px; height:12px; border-radius:50%;
  background:#22c55e; border:2px solid #2a2825;
}

.ya-chat-toggle-label {
  font-size:14px; font-weight:600; white-space:nowrap;
  letter-spacing:0.01em;
}

/* ── Extra floating buttons (bookmark tabs, ya-event.ru only) ── */
.ya-extra-btn {
  display:none;
  position:fixed; right:0;
  height:44px;
  border:none; cursor:pointer;
  align-items:center; gap:8px;
  padding:0 16px 0 14px;
  border-radius:22px 0 0 22px;
  font-family:'Inter','Manrope',Arial,sans-serif;
  font-size:12px; font-weight:600; white-space:nowrap; letter-spacing:0.01em;
  box-shadow:-3px 2px 12px rgba(0,0,0,0.18);
  transition:transform 0.25s cubic-bezier(.4,0,.2,1), box-shadow 0.2s;
  z-index:10000;
}
.ya-extra-btn:hover { transform:translateX(-6px); box-shadow:-5px 2px 18px rgba(0,0,0,0.28); }
.ya-extra-btn svg { width:16px; height:16px; flex-shrink:0; }

#ya-date-btn {
  background:linear-gradient(135deg,#b8966c,#9a7a52);
  color:#fff;
  border-left:3px solid #d4b78f;
}
#ya-calc-btn {
  background:linear-gradient(135deg,#4a4540,#3a3733);
  color:#e8e4de;
  border-left:3px solid #b8966c;
}

/* ── Magazine (ya-event.ru): bookmark-tab override ── */
.magazine #ya-chat-toggle {
  bottom:24px; right:0;
  height:54px; border-radius:27px 0 0 27px;
  padding:0 20px 0 16px;
  box-shadow:-3px 2px 14px rgba(0,0,0,0.28);
  font-size:14px;
}
.magazine #ya-chat-toggle:hover {
  transform:translateX(-4px);
  box-shadow:-5px 2px 20px rgba(0,0,0,0.38);
}
.magazine .ya-extra-btn {
  display:flex;
}
.magazine #ya-date-btn { bottom:138px; }
.magazine #ya-calc-btn { bottom:86px; }
.magazine #ya-chat-panel { bottom:24px; right:16px; }

/* ── Panel ── */
#ya-chat-panel {
  position:fixed; bottom:78px; right:24px;
  width:380px; max-width:calc(100vw - 32px);
  height:520px; max-height:calc(100dvh - 48px);
  border-radius:var(--chat-radius);
  background:var(--chat-bg);
  box-shadow:
    0 4px 16px rgba(0,0,0,0.18),
    0 16px 56px rgba(0,0,0,0.35),
    inset 0 0 0 1px rgba(255,255,255,0.12);
  display:flex; flex-direction:column;
  overflow:hidden;
  transition:opacity 0.25s ease, transform 0.25s cubic-bezier(.4,0,.2,1);
  z-index:10001;
}
#ya-chat-panel.ya-chat-closed {
  opacity:0; pointer-events:none;
  transform:translateY(16px) scale(0.95);
}
#ya-chat-panel.ya-chat-open {
  opacity:1; pointer-events:auto;
  transform:translateY(0) scale(1);
}

/* ── Header ── */
.ya-chat-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 18px 14px;
  background:linear-gradient(135deg,#2a2825,#3a3733);
  color:#fafafa;
  flex-shrink:0;
}
.ya-chat-header-info strong {
  display:block; font-size:15px; font-weight:700;
  font-family:'Cormorant Garamond',Georgia,serif;
  letter-spacing:-0.01em;
}
.ya-chat-header-info span {
  font-size:11px; color:rgba(255,255,255,0.5); font-weight:400;
}
.ya-chat-close {
  background:none; border:none; color:rgba(255,255,255,0.5);
  font-size:22px; cursor:pointer; padding:0 4px;
  line-height:1; transition:color 0.15s;
}
.ya-chat-close:hover { color:#fff; }

/* ── Messages area ── */
#ya-chat-messages {
  flex:1 1 0; overflow-y:auto; padding:16px 16px 8px;
  display:flex; flex-direction:column; gap:8px;
  scrollbar-width:thin; scrollbar-color:rgba(0,0,0,0.1) transparent;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.018'/%3E%3C/svg%3E"),
    linear-gradient(180deg,#faf9f7,#f7f5f2);
}
#ya-chat-messages::-webkit-scrollbar { width:4px; }
#ya-chat-messages::-webkit-scrollbar-thumb { background:rgba(0,0,0,0.1); border-radius:2px; }

.ya-chat-actions {
  display:flex; align-items:center; gap:10px;
  padding:10px 12px 0;
  background:#fff;
  flex-shrink:0;
}

#ya-chat-manager-btn {
  border:none;
  background:#2a2825;
  color:#fff;
  border-radius:999px;
  padding:8px 12px;
  font-size:12px;
  font-weight:600;
  cursor:pointer;
  transition:opacity 0.15s, transform 0.15s;
}

#ya-chat-manager-btn:hover {
  transform:translateY(-1px);
}

#ya-chat-manager-btn:disabled {
  opacity:0.55;
  cursor:default;
  transform:none;
}

#ya-chat-manager-status {
  font-size:12px;
  color:var(--chat-muted);
  line-height:1.35;
}

/* ── Message bubbles ── */
.ya-chat-msg {
  max-width:82%; padding:10px 14px;
  font-size:14px; line-height:1.55;
  border-radius:14px;
  word-break:break-word;
  animation:chatFadeIn 0.2s ease;
}
@keyframes chatFadeIn {
  from { opacity:0; transform:translateY(6px); }
  to { opacity:1; transform:translateY(0); }
}

.ya-chat-user {
  align-self:flex-end;
  background:linear-gradient(135deg,var(--chat-accent),#a07c5a);
  color:#fff;
  border-bottom-right-radius:4px;
}
.ya-chat-bot {
  align-self:flex-start;
  background:#fff;
  color:var(--chat-ink);
  border:1px solid rgba(0,0,0,0.06);
  border-bottom-left-radius:4px;
  box-shadow:0 1px 3px rgba(0,0,0,0.04);
}

.ya-chat-manager {
  align-self:flex-start;
  background:#f4ede2;
  color:#33291d;
  border:1px solid rgba(184,150,108,0.35);
  border-bottom-left-radius:4px;
  box-shadow:0 1px 3px rgba(0,0,0,0.04);
}

/* ── Typing indicator ── */
.ya-chat-typing {
  display:flex; align-items:center; gap:4px;
  padding:12px 18px;
}
.ya-chat-typing span {
  width:7px; height:7px; border-radius:50%;
  background:var(--chat-accent); opacity:0.4;
  animation:chatDot 1.2s infinite;
}
.ya-chat-typing span:nth-child(2) { animation-delay:0.15s; }
.ya-chat-typing span:nth-child(3) { animation-delay:0.3s; }
@keyframes chatDot {
  0%,60%,100% { opacity:0.3; transform:scale(0.85); }
  30% { opacity:1; transform:scale(1.1); }
}

/* ── Form ── */
#ya-chat-form {
  display:flex; gap:0; padding:10px 12px 12px;
  border-top:1px solid rgba(0,0,0,0.06);
  background:#fff;
  flex-shrink:0;
}
#ya-chat-input {
  flex:1; border:1px solid rgba(0,0,0,0.1);
  border-radius:10px 0 0 10px;
  padding:10px 14px; font-size:14px;
  font-family:inherit; outline:none;
  background:#faf9f7;
  transition:border-color 0.15s;
}
#ya-chat-input:focus { border-color:var(--chat-accent); }
#ya-chat-input::placeholder { color:rgba(0,0,0,0.3); }
#ya-chat-form button[type="submit"] {
  border:none; cursor:pointer;
  background:var(--chat-accent);
  color:#fff;
  padding:0 14px;
  border-radius:0 10px 10px 0;
  display:flex; align-items:center; justify-content:center;
  transition:background 0.15s;
}
#ya-chat-form button[type="submit"]:hover { background:#a07c5a; }

/* ── Mobile ── */
@media(max-width:480px){
  #ya-chat-panel {
    bottom:0; right:0; left:0;
    width:100%; max-width:100%;
    height:100dvh; max-height:100dvh;
    border-radius:0;
  }
  #ya-chat-toggle {
    bottom:72px; right:16px;
    width:48px; height:48px;
    padding:0;
    border-radius:50%;
  }
  #ya-chat-toggle .ya-chat-toggle-label { display:none; }
  #ya-chat-toggle svg { width:22px; height:22px; }
}
/* ── Magazine mobile (matches magazine 960px breakpoint) ── */
@media(max-width:960px){
  .magazine #ya-chat-toggle {
    bottom:90px; right:0;
    width:auto; height:44px;
    padding:0 14px 0 12px;
    border-radius:22px 0 0 22px;
  }
  .magazine #ya-chat-toggle .ya-chat-toggle-label { display:none; }
  .magazine .ya-extra-btn { height:38px; padding:0 12px 0 10px; font-size:11px; border-radius:19px 0 0 19px; }
  .magazine #ya-date-btn { bottom:184px; }
  .magazine #ya-calc-btn { bottom:142px; }
}
@media(min-width:481px){
  #ya-chat-toggle .ya-chat-toggle-label { display:inline; }
}

/* ── Quick action buttons ── */
.ya-chat-quick {
  display:flex; flex-wrap:wrap; gap:6px;
  padding:4px 0 8px;
  animation:chatFadeIn 0.3s ease;
}
.ya-chat-quick-btn {
  padding:7px 14px;
  border:1.5px solid var(--chat-accent);
  border-radius:18px;
  background:transparent;
  color:var(--chat-accent);
  font-size:13px; font-weight:600;
  font-family:inherit;
  cursor:pointer;
  transition:background 0.15s, color 0.15s;
}
.ya-chat-quick-btn:hover {
  background:var(--chat-accent);
  color:#fff;
}
.ya-callback-form {
  display:flex;gap:6px;
}
.ya-callback-form input {
  flex:1;padding:6px 10px;border:1px solid rgba(184,150,108,0.3);border-radius:6px;
  font-size:13px;font-family:inherit;background:#fff;
}
.ya-callback-form button {
  padding:6px 14px;border:none;border-radius:6px;
  background:var(--chat-accent,#b8966c);color:#fff;font-size:12px;
  font-family:inherit;cursor:pointer;white-space:nowrap;
}
