/* ---------------------------------------
   TABBY MAIN ORB
----------------------------------------*/
#tabby-shell {
  position: fixed;
  width: 64px;
  height: 64px;
  right: 16px;
  bottom: 20px;
  cursor: grab;
  z-index: 9999;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow .15s ease, transform .12s ease;
  pointer-events: auto;
}

#tabby-shell.dragging {
  cursor: grabbing;
  box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}

#tabby {
  width: 100%;
  height: 100%;
  pointer-events: none;
}


/* ---------------------------------------
   TABBY FLOATING BUBBLE
----------------------------------------*/
.tabby-bubble {
  position: fixed;
  max-width: 200px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff;
  color: #000;
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  z-index: 9998;
  font-family: Inter, system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.3;
  pointer-events: none;
  animation: tabbyFade 4s ease forwards;
}

@keyframes tabbyFade {
  0% { opacity: 0; transform: translateY(6px); }
  10%, 90% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-6px); }
}


/* ---------------------------------------
   CHATBOX UI
----------------------------------------*/
/* FORCE TABBY CHAT TO CENTER ALWAYS */
#tabby-chat {

  position: fixed !important;

  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;

  width: 320px !important;
  height: 380px !important;

  background: #ffffff !important;
  border-radius: 12px !important;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.12) !important;
  border: 1px solid rgba(15,23,42,0.04) !important;

  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;

  font-family: Inter, system-ui, sans-serif !important;
  z-index: 999999 !important;
}


/* Header */
#tabby-chat .tabby-header {
  height: 48px;
  display:flex;
  align-items:center;
  gap:8px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(15,23,42,0.04);
}
#tabby-chat .tabby-title {
  font-weight: 600;
  font-size: 15px;
  color: #0f172a;
  flex: 1;
}
#tabby-chat .tabby-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #475569;
}

/* Body (messages) */
#tabby-chat .tabby-body {
  padding: 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f9fafb;
}

.msg-row { display:flex; gap:8px; align-items:flex-end; }
.msg-row.user { justify-content: flex-end; }

.msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.3;
  box-shadow: 0 6px 18px rgba(2,6,23,.04);
}

.msg.tabby {
  background: #f1f5f9;
  color: #0b1220;
  align-self: flex-start;
}

.msg.user {
  background: #0b78ff;
  color: #fff;
  align-self: flex-end;
}

.msg.tabby,
.msg.user {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Footer / input */
#tabby-chat .tabby-input {
  padding: 10px;
  display:flex;
  gap:8px;
  border-top: 1px solid rgba(15,23,42,0.04);
}
#tabby-input-box {
  flex:1;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.06);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}
#tabby-send-btn {
  background: #0b78ff;
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(11,120,255,0.16);
}

/* Typing text */
.tabby-typing {
  font-size: 13px;
  color: #94a3b8;
  padding-left: 6px;
}


/* ---------------------------------------
   MOBILE
----------------------------------------*/
@media (max-width: 600px) {
  #tabby-shell {
    width: 54px;
    height: 54px;
    right: 12px;
    bottom: 75px;
  }
}

/* ------------------------
   MESSAGE ROWS
-------------------------*/
.msg-row {
  display: flex;
  align-items: flex-end;
}

.msg-row.user {
  justify-content: flex-end !important;
}

.msg-row:not(.user) {
  justify-content: flex-start !important;
}


/* ------------------------
   MESSAGE BUBBLES
-------------------------*/
.msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.3;
  font-family: Inter, system-ui, sans-serif;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}

.msg.user {
  background: #000;
  color: #fff;
  border: 1px solid #000;
  align-self: flex-end;
}

.msg.tabby {
  background: #f1f1f1;
  color: #111;
  border: 1px solid #e5e5e5;
  align-self: flex-start;
}


.msg {
  animation: msgPop .15s ease-out;
}

@keyframes msgPop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}


/* ---------------------------------------
   TABBY CHAT — CLEAN INTER DESIGN
----------------------------------------*/

/* Reset internal styles safely */
#tabby-chat {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  height: 380px;

  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
  border: 1px solid #e5e5e5;

  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;

  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: #1f2937;
}

/* ---------------------------------------
   HEADER
----------------------------------------*/
#tabby-chat .tabby-header {
  height: 48px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}

#tabby-chat .tabby-title {
  font-weight: 600;
  font-size: 15px;
  color: #111;
}

#tabby-chat .tabby-close {
  margin-left: auto;
  background: transparent;
  border: none;
  font-size: 20px;
  color: #555;
  cursor: pointer;
  transition: 0.2s ease;
}

#tabby-chat .tabby-close:hover {
  color: #000;
  transform: scale(1.15);
}

/* ---------------------------------------
   BODY (MESSAGES)
----------------------------------------*/
#tabby-chat .tabby-body {
  flex: 1;
  background: #fafafa;
  padding: 12px;
  overflow-y: auto;

  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Row wrappers */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.msg-row.user { justify-content: flex-end; }
.msg-row.tabby { justify-content: flex-start; }

/* Bubble base */
.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 400;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  animation: msgPop .18s ease-out;
}

/* Tabby bubble */
.msg.tabby {
  background: #f1f1f1;
  color: #222;
  border: 1px solid #ececec;
}

/* User bubble */
.msg.user {
  background: #000000;
  color: #ffffff;
  border: 1px solid #000;
}

/* Smooth pop animation */
@keyframes msgPop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Typing indicator */
.tabby-typing {
  font-size: 12px;
  color: #888;
  padding-left: 6px;
}

/* ---------------------------------------
   FOOTER / INPUT
----------------------------------------*/
#tabby-chat .tabby-input {
  padding: 10px;
  display: flex;
  gap: 8px;
  border-top: 1px solid #f0f0f0;
  background: #ffffff;
}

#tabby-input-box {
  flex: 1;
  padding: 9px 14px;
  border-radius: 20px;
  border: 1px solid #e0e0e0;
  background: #fafafa;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

#tabby-input-box:focus {
  border-color: #000;
}

#tabby-send-btn {
  background: #000;
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: 0.2s ease;
}

#tabby-send-btn:hover {
  background: #333;
}

/* ---------------------------------------
   MOBILE RESPONSIVE
----------------------------------------*/
@media (max-width: 480px) {
  #tabby-chat {
    width: 92vw;
    height: 360px;
    font-size: 13px;
  }

  .msg {
    font-size: 13px;
    padding: 9px 12px;
  }
}


/* Responsive font sizes for chat */
#tabby-chat {
  font-size: clamp(13px, 2.8vw, 15px);
}

#tabby-chat .msg {
  font-size: clamp(12px, 2.6vw, 14px);
}

#tabby-input-box,
#tabby-send-btn {
  font-size: clamp(12px, 2.6vw, 14px);
}

.tabby-typing {
  font-size: clamp(11px, 2.2vw, 13px);
}

#tabby-chat .tabby-title {
  font-size: clamp(14px, 3vw, 16px);
}

#tabby-lock-timer {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
  display: none;
  text-align: right;
  padding-right: 6px;
}

.tabby-header-buttons {
  display: flex;
  gap: 6px;
}

/* Clear Chat Button */
.tabby-clear {
  background: #ffefc2;
  border: none;
  padding: 4px 8px;
  font-size: 14px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 4px rgba(255, 194, 0, 0.35);
  color: #6a4800;
}


.tabby-clear:hover {
  background: #ffd970;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(255, 199, 80, 0.6);
}

.tabby-clear:active {
  transform: scale(0.94);
}

.tabby-clear:focus {
  outline: 3px solid rgba(255, 200, 60, 0.5);
  outline-offset: 2px;
}
