/* ========================================
   Deskium Chatbot Widget — "Kira"
   ======================================== */

/* Bubble */
.cb-bubble {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 90;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.cb-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.45);
  animation: none;
}

@keyframes cb-pulse {
  0% { box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35), 0 0 0 0 rgba(245, 158, 11, 0.5); }
  70% { box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35), 0 0 0 14px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35), 0 0 0 0 rgba(245, 158, 11, 0); }
}

.cb-bubble:not(.cb-bubble--hidden) {
  animation: cb-pulse 2s ease-out infinite;
}

.cb-bubble--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* Panel */
.cb-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 95;
  width: 360px;
  max-height: 520px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}

.cb-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .cb-bubble, .cb-panel {
    transition: none;
  }
  .cb-panel--open {
    transform: none;
  }
}

/* Header */
.cb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
}

.cb-header-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.cb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.cb-header-info strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
}

.cb-status {
  display: block;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
}

.cb-header-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}

.cb-header-close:hover {
  color: #ffffff;
}

/* Messages */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 280px;
  max-height: 360px;
}

.cb-msg {
  max-width: 85%;
  animation: cb-fade-in 0.2s ease-out;
}

.cb-msg--bot {
  align-self: flex-start;
}

.cb-msg--user {
  align-self: flex-end;
}

.cb-msg p {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.cb-msg--bot p {
  background: #f3f4f6;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}

.cb-msg--user p {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

@keyframes cb-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typing indicator */
.cb-typing {
  display: flex;
  gap: 4px;
  padding: 0.65rem 0.85rem;
  background: #f3f4f6;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.cb-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: cb-typing-dot 1.2s infinite;
}

.cb-typing span:nth-child(2) { animation-delay: 0.2s; }
.cb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cb-typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Actions */
.cb-actions {
  display: flex;
  gap: 0.45rem;
  padding: 0 0.6rem 0.55rem;
  border-top: 1px solid #f3f4f6;
}

.cb-action-btn,
.cb-action-link {
  flex: 1;
  height: 34px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 600;
  text-align: center;
}

.cb-action-btn {
  border: 1px solid #f59e0b;
  background: #ffffff;
  color: #b45309;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.cb-action-btn:hover:not([disabled]) {
  background: #fffbeb;
  border-color: #f97316;
  color: #9a3412;
}

.cb-action-btn[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}

.cb-action-link {
  display: grid;
  place-items: center;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}

.cb-action-link:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

/* Input */
.cb-input-form {
  display: flex;
  padding: 0.6rem;
  border-top: 1px solid #e5e7eb;
  gap: 0.4rem;
}

.cb-input {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 0.85rem;
  font-family: inherit;
  background: #f9fafb;
  color: #1f2937;
  outline: none;
  transition: border-color 0.2s;
}

.cb-input:focus {
  border-color: #f59e0b;
}

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

.cb-send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: #f59e0b;
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.cb-send:hover {
  background: #f97316;
}

/* Mobile */
@media (max-width: 479px) {
  .cb-panel {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    width: auto;
    max-height: calc(100dvh - 1rem);
  }

  .cb-bubble {
    bottom: 1rem;
    right: 1rem;
  }
}
