/* ── LinguaBot Chat Widget ── */
:root {
  --lb-color: #2d6a4f;
  --lb-radius: 16px;
  --lb-shadow: 0 8px 32px rgba(0,0,0,0.18);
  --lb-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#linguabot-widget {
  position: fixed;
  z-index: 999999;
  font-family: var(--lb-font);
  box-sizing: border-box;
}
#linguabot-widget *, #linguabot-widget *::before, #linguabot-widget *::after {
  box-sizing: border-box;
}

/* Position variants */
.lb-bottom-right { bottom: 24px; right: 24px; }
.lb-bottom-left  { bottom: 24px; left: 24px; }

/* ── Toggle button ── */
.lb-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--lb-color);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--lb-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  color: #fff;
}
.lb-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.lb-toggle-icon svg { width: 26px; height: 26px; }
.lb-unread-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 12px;
  height: 12px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ── Panel ── */
.lb-panel {
  position: absolute;
  bottom: 70px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: #ffffff;
  border-radius: var(--lb-radius);
  box-shadow: var(--lb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: lb-slide-up 0.25s cubic-bezier(.34,1.56,.64,1);
}
.lb-bottom-right .lb-panel { right: 0; }
.lb-bottom-left  .lb-panel { left: 0; }

@keyframes lb-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
.lb-header {
  background: var(--lb-color);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.lb-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.lb-avatar svg { width: 22px; height: 22px; fill: #fff; }
.lb-bot-name { font-weight: 700; font-size: 14px; }
.lb-status {
  font-size: 11px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 4px;
}
.lb-dot {
  width: 7px;
  height: 7px;
  background: #52e085;
  border-radius: 50%;
  display: inline-block;
}
.lb-minimize {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
}
.lb-minimize:hover { color: #fff; background: rgba(255,255,255,0.1); }
.lb-minimize svg { width: 18px; height: 18px; }

/* ── Messages ── */
.lb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.lb-messages::-webkit-scrollbar { width: 4px; }
.lb-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.lb-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: lb-msg-in 0.2s ease;
}
@keyframes lb-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lb-msg.lb-bot  { align-self: flex-start; }
.lb-msg.lb-user { align-self: flex-end; flex-direction: row-reverse; }

.lb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--lb-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}
.lb-msg-avatar svg { width: 16px; height: 16px; }

.lb-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}
.lb-bot  .lb-bubble {
  background: #f0f0f0;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}
.lb-user .lb-bubble {
  background: var(--lb-color);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Markdown bold support */
.lb-bubble strong { font-weight: 700; }

/* Typing indicator */
.lb-typing .lb-bubble {
  display: flex;
  gap: 5px;
  padding: 13px 16px;
  align-items: center;
}
.lb-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #999;
  animation: lb-bounce 1.2s infinite;
}
.lb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.lb-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes lb-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Categories / Quick replies ── */
.lb-categories {
  padding: 8px 14px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex-shrink: 0;
  border-top: 1px solid #f0f0f0;
}
.lb-cat-btn {
  background: #f5f5f5;
  border: 1.5px solid #e0e0e0;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-family: var(--lb-font);
  cursor: pointer;
  transition: all 0.15s;
  color: #333;
  white-space: nowrap;
}
.lb-cat-btn:hover {
  background: var(--lb-color);
  border-color: var(--lb-color);
  color: #fff;
}

/* ── Input area ── */
.lb-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
  background: #fff;
}
.lb-input {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-family: var(--lb-font);
  outline: none;
  transition: border-color 0.15s;
  background: #fafafa;
  color: #1a1a1a;
}
.lb-input:focus { border-color: var(--lb-color); background: #fff; }
.lb-input::placeholder { color: #aaa; }

.lb-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--lb-color);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
  color: #fff;
}
.lb-send:hover { transform: scale(1.08); }
.lb-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.lb-send svg { width: 18px; height: 18px; }

/* ── Footer ── */
.lb-footer {
  text-align: center;
  font-size: 10px;
  color: #bbb;
  padding: 4px 0 8px;
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 420px) {
  .lb-panel {
    width: calc(100vw - 20px);
    bottom: 68px;
  }
  .lb-bottom-right { right: 10px; }
  .lb-bottom-left  { left: 10px; }
}

/* ── Order Card ── */
.lb-order-msg { max-width: 92% !important; }

.lb-order-card {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  min-width: 240px;
  max-width: 300px;
}

.lb-order-header {
  background: var(--lb-color);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.lb-order-num {
  font-weight: 700;
  font-size: 13px;
}
.lb-order-status {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.lb-status-done      { background: rgba(255,255,255,0.25); }
.lb-status-active    { background: rgba(255,255,255,0.20); }
.lb-status-cancelled { background: rgba(255,60,60,0.35); }

.lb-order-body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.lb-order-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}
.lb-order-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #9ca3af;
  min-width: 58px;
  flex-shrink: 0;
  padding-top: 1px;
}
.lb-order-items span { color: #4b5563; font-size: 12px; }
.lb-order-row.lb-muted span { color: #9ca3af; font-style: italic; }

/* Tracking link */
.lb-order-row.lb-tracking { align-items: center; }
.lb-track-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--lb-color);
  color: #fff !important;
  text-decoration: none !important;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.15s;
  word-break: break-all;
}
.lb-track-link:hover { opacity: 0.85; transform: translateY(-1px); }
.lb-track-arrow { font-size: 10px; }
