html, body {
  margin: 0;
  padding: 0;
  background: transparent;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow: hidden;
  height: 100%;
}

.bubble {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 166px;
  height: 56px;
  box-sizing: border-box;
  border: 1px solid rgba(96, 165, 250, 0.38);
  border-radius: 15px;
  background:
    linear-gradient(90deg, #2563eb 0 3px, transparent 3px),
    linear-gradient(135deg, #111c31, #0b1324);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 13px 7px 12px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(2, 8, 23, 0.48), inset 0 1px 0 rgba(255,255,255,.04);
  user-select: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  animation: cd-bubble-pulse 2.6s ease-in-out infinite;
}

.bubble:hover {
  transform: translateY(-2px);
  border-color: rgba(96, 165, 250, 0.8);
  box-shadow: 0 15px 34px rgba(2, 8, 23, 0.58), 0 0 0 3px rgba(37, 99, 235, .12);
  animation-play-state: paused;
}

@keyframes cd-bubble-pulse {
  0%, 100% {
    box-shadow: 0 12px 28px rgba(2, 8, 23, 0.48), 0 0 0 0 rgba(37, 99, 235, .22);
  }
  50% {
    box-shadow: 0 12px 28px rgba(2, 8, 23, 0.48), 0 0 0 7px rgba(37, 99, 235, 0);
  }
}

.bubble.hidden {
  display: none;
}

.bubble-mark {
  position: relative;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid rgba(96, 165, 250, .42);
  border-radius: 11px;
  background: linear-gradient(145deg, #2563eb, #1d4ed8);
  display: grid;
  place-items: center;
  box-shadow: 0 5px 14px rgba(37, 99, 235, .3);
}

.bubble-logo {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  object-fit: cover;
}

.bubble-logo.hidden {
  display: none;
}

.bubble-icon {
  width: 23px;
  height: 23px;
  fill: #fff;
}

.bubble-icon.hidden {
  display: none;
}

.bubble-status-dot {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 9px;
  height: 9px;
  border: 2px solid #0d1729;
  border-radius: 50%;
  background: #64748b;
}

.bubble-status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .13);
}

.bubble-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.bubble-copy strong {
  overflow: hidden;
  color: #f8fafc;
  font-size: 13px;
  letter-spacing: .01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bubble-copy small {
  margin-top: 4px;
  overflow: hidden;
  color: #93c5fd;
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes cd-panel-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.panel {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 380px;
  height: 600px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cd-panel-in 0.16s ease;
}

.panel.hidden {
  display: none;
}

.panel-header {
  position: relative;
  background: linear-gradient(135deg, #3b82f6, #4f46e5);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header-logo {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
}

.header-logo.hidden {
  display: none;
}

#brandNameText {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  padding: 6px 9px;
  line-height: 1;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.icon-btn.hidden {
  display: none;
}

.end-chat-confirm {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.end-chat-confirm.hidden {
  display: none;
}

.end-chat-confirm-box {
  background: #fff;
  border-radius: 14px;
  padding: 22px 20px;
  width: 260px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.end-chat-confirm-text {
  font-size: 14px;
  color: #111827;
  font-weight: 600;
  margin-bottom: 18px;
  line-height: 1.5;
}

.end-chat-confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.end-chat-confirm-end {
  border: none;
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.end-chat-confirm-end:hover {
  background: #fecaca;
}

.end-chat-confirm-continue {
  border: none;
  background: linear-gradient(135deg, #3b82f6, #4f46e5);
  color: #fff;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.3);
  transition: transform 0.15s ease;
}

.end-chat-confirm-continue:hover {
  transform: translateY(-1px);
}

.agents-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.agents-bar.hidden {
  display: none;
}

.agents-avatars {
  display: flex;
  flex-shrink: 0;
}

.agent-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #f8fafc;
  margin-left: -9px;
}

.agent-avatar:first-child {
  margin-left: 0;
}

.agents-info {
  min-width: 0;
}

.agents-names {
  font-size: 12px;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agents-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #6b7280;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
}

.status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f3f4f6;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.messages.hidden {
  display: none;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12px;
  color: #6b7280;
  background: #f3f4f6;
  flex-shrink: 0;
}

.typing-indicator.hidden {
  display: none;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: cd-typing-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes cd-typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.prechat {
  flex: 1;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.prechat::-webkit-scrollbar {
  width: 6px;
}

.prechat::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.prechat.hidden {
  display: none;
}

.waiting-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  background: #fff;
}

.waiting-screen.hidden {
  display: none;
}

.waiting-screen.offline-success::before {
  content: "✓";
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  border: 1px solid #86efac;
  border-radius: 50%;
  background: #f0fdf4;
  color: #16a34a;
  font-size: 26px;
  font-weight: 900;
}

.offline-done-btn {
  margin-top: 18px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  padding: 11px 18px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.offline-done-btn.hidden {
  display: none;
}

.waiting-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #e5e7eb;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: cd-spin 0.8s linear infinite;
}

@keyframes cd-spin {
  to {
    transform: rotate(360deg);
  }
}

.waiting-text {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
}

.prechat-title {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
}

.prechat-subtitle {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: 20px;
}

.prechat input,
.prechat select,
.prechat textarea {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  font-family: inherit;
  background: #fff;
  color: #111827;
}

.prechat select:invalid {
  color: #6b7280;
}

.prechat input:focus,
.prechat select:focus,
.prechat textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.offline-message-input {
  min-height: 92px;
  resize: vertical;
  font-family: inherit;
}

.offline-message-input.hidden {
  display: none;
}

.start-chat-btn {
  margin-top: 8px;
  border: none;
  background: linear-gradient(135deg, #3b82f6, #4f46e5);
  color: #fff;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.start-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(79, 70, 229, 0.4);
}

.prechat-error {
  color: #dc2626;
  font-size: 12px;
  min-height: 16px;
  margin: 8px 0 0;
}

@keyframes cd-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  animation: cd-msg-in 0.2s ease;
}

.msg.visitor {
  align-self: flex-end;
  background: linear-gradient(135deg, #3b82f6, #4f46e5);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg.admin {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 5px;
}

.msg-sender {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin-bottom: 4px;
}

.msg.visitor .msg-sender {
  color: rgba(255, 255, 255, 0.95);
}

.msg.admin .msg-sender {
  color: #2563eb;
}

.msg-time {
  font-size: 10px;
  opacity: 0.65;
  margin-top: 4px;
}

.msg.visitor .msg-time {
  text-align: right;
}

.msg.admin .msg-time {
  text-align: left;
}

.msg.system {
  align-self: center;
  background: #eef2f7;
  color: #6b7280;
  font-size: 11px;
  text-align: center;
  max-width: 90%;
  padding: 4px 12px;
  border-radius: 999px;
}

.rating-panel {
  padding: 18px 16px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  text-align: center;
  animation: cd-panel-in 0.18s ease;
}

.rating-panel.hidden {
  display: none;
}

.rating-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 10px;
}

.stars {
  font-size: 30px;
  letter-spacing: 8px;
  margin-bottom: 12px;
}

.star {
  color: #d1d5db;
  cursor: pointer;
  display: inline-block;
  transition: color 0.15s ease, transform 0.15s ease;
}

.star:hover {
  transform: scale(1.15);
}

.star.active {
  color: #f59e0b;
  transform: scale(1.15);
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.rating-submit {
  border: none;
  background: linear-gradient(135deg, #3b82f6, #4f46e5);
  color: #fff;
  padding: 9px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rating-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(79, 70, 229, 0.4);
}

.rating-submit:disabled {
  background: #d1d5db;
  box-shadow: none;
  opacity: 0.5;
  cursor: not-allowed;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.input-row.hidden {
  display: none;
}

.input-row input {
  flex: 1;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 24px;
  padding: 11px 18px;
  font-size: 14px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-row input:focus {
  background: #fff;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.input-row input::placeholder {
  color: #9ca3af;
}

.input-row button {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #4f46e5);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.input-row button:hover {
  transform: scale(1.06);
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.45);
}
