/* Плаващ бутон */
.lama-chat-btn {
  position: fixed; bottom: 24px; padding: 8px 12px; border-radius: 22px;
  background: #111; color: #fff; cursor: pointer; z-index: 2147483647;
  display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.15);
}
.lama-chat-btn:hover { transform: translateY(-1px); }
.lama-chat-btn-icon { width: 18px; height: 18px; display: block; }
.lama-pos-right { right: 24px; }
.lama-pos-left  { left: 24px; }

/* Панел (компактен чат) */
.lama-chat-panel {
  position: fixed; bottom: 80px; width: 360px; max-width: 92vw;
  background: #fff; border: 1px solid #ddd; border-radius: 10px;
  z-index: 2147483647; box-shadow: 0 10px 30px rgba(0,0,0,.12); overflow: hidden;
  font: 14px/1.4 system-ui,-apple-system,Segoe UI,Roboto,Arial;
  pointer-events: auto;
}
.lama-chat-panel.lama-pos-right { right: 24px; }
.lama-chat-panel.lama-pos-left  { left: 24px; }

.lama-chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: #f6f6f6; border-bottom: 1px solid #eee;
}
.lama-chat-body   { height: 300px; overflow: auto; padding: 12px; background: #fafafa; }
.lama-chat-input  { display: flex; gap: 6px; padding: 10px; border-top: 1px solid #eee; }
.lama-chat-input input {
  flex: 1; padding: 10px 12px; border: 1px solid #ddd; border-radius: 20px; background: #fff;
}
.lama-chat-input button {
  padding: 10px 12px; border-radius: 18px; border: 1px solid #111; background: #111; color:#fff; cursor: pointer;
}

/* Балончета */
.lama-msg { display: flex; margin: 8px 0; }
.lama-msg .bubble {
  display: inline-block; max-width: 85%; padding: 8px 12px; border-radius: 14px;
  word-wrap: break-word; white-space: pre-wrap; line-height: 1.45;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.lama-msg.user      { justify-content: flex-end; }
.lama-msg.user  .bubble { background: #111; color:#fff; border-bottom-right-radius: 4px; }
.lama-msg.assistant .bubble { background: #fff; border: 1px solid #e8e8e8; border-bottom-left-radius: 4px; }

/* Typing indicator (пише…) */
.lama-msg.typing .bubble {
  background: #fff; border: 1px solid #e8e8e8;
  display: inline-flex; align-items: center; gap: 4px;
}
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: #999; opacity: .6;
  animation: lamaDots 1s infinite ease-in-out;
}
.typing-dots i:nth-child(2){ animation-delay: .15s; }
.typing-dots i:nth-child(3){ animation-delay: .3s; }
@keyframes lamaDots {
  0%, 80%, 100% { transform: translateY(0); opacity:.4; }
  40%          { transform: translateY(-4px); opacity:1; }
}

/* дреболии */
.lama-chat-panel * { pointer-events: auto; }

/* ===========================
   Скрито меню с история
   =========================== */
.lama-chat-history {
  position: absolute;
  top: 0;
  left: -220px; /* скрито по подразбиране */
  width: 220px;
  height: 100%;
  background: #fff;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  transition: left 0.3s ease;
  z-index: 10;
}
.lama-chat-history.open { left: 0; }

.lama-history-header {
  padding: 8px 10px;
  background: #f6f6f6;
  border-bottom: 1px solid #ddd;
  font-weight: 600;
  position: relative;
}
.lama-history-close {
  position: absolute; right: 8px; top: 6px;
  border: none; background: transparent; font-size: 18px; cursor: pointer;
}

#lama-history-list { /* контейнер за елементи от JS */ }

.lama-history-item {
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  font-size: 13px;
}
.lama-history-item:hover { background: #f5f5f5; }

/* Футър на историята с бутон „Нов разговор“ */
.lama-history-footer {
  padding: 8px 10px;
  background: #f6f6f6;
  border-top: 1px solid #ddd;
  text-align: center;
}
.lama-history-footer button {
  background: #111; color: #fff; border: none;
  padding: 6px 12px; border-radius: 4px; cursor: pointer;
}
.lama-history-footer button:hover { background: #333; }
.lama-history-footer button[disabled]{ opacity: .6; cursor: default; }

/* ===========================
   Модал „Нов разговор“
   =========================== */
.lama-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 2147483647; display: none;
  align-items: center; justify-content: center;
}
.lama-modal .lama-modal-box {
  background:#fff; padding:16px; border-radius:10px; width:360px; max-width:92vw;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
}
.lama-modal .lama-row { display:flex; gap:8px; margin-top:10px; }
.lama-modal input[type="text"] {
  flex:1; padding:8px; border:1px solid #ddd; border-radius:6px;
}
.lama-modal .button {
  padding:8px 12px; border-radius:6px; border:1px solid #111;
  background:#111; color:#fff; cursor:pointer;
}
.lama-modal .button.secondary {
  background:#f5f5f5; color:#111; border-color:#ddd;
}
.lama-modal .button[disabled]{ opacity:.6; cursor: default; }

.lama-pro-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
}
.lama-pro-box {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}
.lama-pro-box h3 {
  margin: 0 0 10px;
}
.lama-pro-box button {
  background: #111;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}
/* История (off-canvas), да НЕ пречи когато е скрита */
.lama-chat-history {
  position: absolute;
  top: 0;
  left: 0;
  width: 220px;
  height: 100%;
  background: #fff;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  transform: translateX(-100%);   /* СКРИТО */
  transition: transform .25s ease;
  z-index: 10;
  pointer-events: none;           /* <— много важно: да не прихваща кликове, когато е скрита */
}
.lama-chat-history.open {
  transform: translateX(0);       /* ПОКАЗАНО */
  pointer-events: auto;
}

/* бутонът да е по-“щедър” на клик */
#lama-chat-button {
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#lama-chat-button * { pointer-events: none; } /* целият бокс да е клик-зона */

/* Линковете в балончетата да се виждат ясно */
.lama-chat-body .bubble a {
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.lama-chat-body .bubble a:hover {
  text-decoration-thickness: 2px;
}
.lama-chat-body .bubble a:focus {
  outline: 2px dashed #555;
  outline-offset: 2px;
}
/* ===== Fix: мобилен full-screen + без изместване ===== */
@media (max-width: 680px) {
  /* когато чатът е отворен — спри скрола на страницата и скрий бутона */
  html.lama-open, body.lama-open {
    overflow: hidden;
    height: 100%;
    touch-action: none;
  }
  html.lama-open #lama-chat-button { display: none !important; }

  /* панел = истински full-screen; игнорира позиционните класове left/right */
  .lama-chat-panel {
    position: fixed !important;
    inset: 0 !important;           /* top/right/bottom/left: 0 */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;     /* стабилна височина на мобилен */
    max-width: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex;
    flex-direction: column;
    background: #fff;
    overscroll-behavior: contain;  /* спри „подскока“ на iOS */
    z-index: 2147483647;           /* винаги най-отгоре */
  }
  /* обезсилвай позиционните modifiers */
  .lama-chat-panel.lama-pos-right,
  .lama-chat-panel.lama-pos-left {
    right: 0 !important;
    left: 0 !important;
  }

  .lama-chat-header {
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    flex: 0 0 auto;
  }

  .lama-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 12px 12px 6px;
    background: #fafafa;
  }

  .lama-chat-input {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #eee;
    gap: 8px;
  }

  .lama-chat-input input {
    padding: 12px 14px;
    font-size: 16px; /* без зум на iOS */
  }

  .lama-chat-input button {
    padding: 12px 14px;
    border-radius: 20px;
    font-size: 15px;
  }

  /* off-canvas менюто с история – ширина и pointer events */
  .lama-chat-history {
    width: 80vw;
    max-width: 360px;
    pointer-events: none;
  }
  .lama-chat-history.open { pointer-events: auto; }
}
/* === Mobile drawer: full-screen меню + по-видим close === */
@media (max-width: 768px) {
  /* панелът на чата остава адаптивен */
  .lama-chat-panel {
    width: 100vw !important;
    max-width: 100vw !important;
    right: 0 !important;
    left: 0 !important;
  }

  /* drawer менюто да заема целия екран при отваряне */
  .lama-chat-panel .lama-chat-history,
  #lama-chat-history.lama-chat-history {
    width: 100vw !important;
    max-width: 100vw !important;
    transform: translateX(-100%) !important;
    box-shadow: 6px 0 20px rgba(0,0,0,.15);
    background: #fff;
    z-index: 9999 !important;
  }
  .lama-chat-panel .lama-chat-history.open,
  #lama-chat-history.lama-chat-history.open {
    transform: translateX(0) !important;
  }

  /* sticky header за темите */
  .lama-history-header {
    position: sticky;
    top: 0;
    padding: 14px 16px !important;
    font-size: 18px !important;
    background: #fff;
    z-index: 2;
  }

  /* по-голям close бутон */
  .lama-history-close {
    position: absolute;
    right: 10px !important;
    top: 6px !important;
    width: 48px !important;
    height: 48px !important;
    line-height: 48px !important;
    font-size: 32px !important;
    text-align: center !important;
    cursor: pointer;
  }

  /* по-голям ☰ бутон */
  #lama-history-toggle {
    font-size: 24px !important;
    margin-right: 8px !important;
    cursor: pointer;
  }

  /* редовете в списъка с темите */
  #lama-history-list .lama-history-item {
    font-size: 18px !important;
    padding: 14px 18px !important;
    border-bottom: 1px solid #eee;
  }
  
  
  
}

