/* =============================================================================
   CLARITLY CUSTOM SUPPORT CHATBOX WIDGET
   Ultra-Clean Modern Aesthetic: Minimalist White, Deep Black & Warm Orange
   ============================================================================= */

:root {
  --claritly-white: #ffffff;
  --claritly-surface: #fafafa;
  --claritly-border: #e5e7eb;
  --claritly-border-subtle: #f0f0f2;
  
  --claritly-black: #09090b;
  --claritly-text-secondary: #52525b;
  --claritly-text-muted: #a1a1aa;
  
  --claritly-orange: #ff6b00;
  --claritly-orange-hover: #e05e00;
  --claritly-orange-subtle: #fff7ed;
  --claritly-orange-border: #ffedd5;
  
  --claritly-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Floating Launcher Button */
.claritly-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  height: 46px;
  width: auto;
  padding: 0 18px 0 14px;
  border-radius: 999px;
  background: var(--claritly-black);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  z-index: 999998;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, background-color 0.2s;
  user-select: none;
}

.claritly-chat-launcher:hover {
  transform: translateY(-2px) scale(1.025);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
  background: #000000;
}

.claritly-chat-launcher svg {
  width: 19px;
  height: 19px;
  color: #ffffff;
  flex-shrink: 0;
}

.claritly-chat-launcher-text {
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.claritly-chat-badge {
  position: absolute;
  top: -4px;
  right: 2px;
  background: var(--claritly-orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--claritly-white);
  box-shadow: 0 2px 6px rgba(255, 107, 0, 0.4);
}

/* Chat Window Box */
.claritly-chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 375px;
  height: 520px;
  max-height: calc(100vh - 110px);
  background: var(--claritly-white);
  border: 1px solid var(--claritly-border);
  border-radius: 18px;
  box-shadow: var(--claritly-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.claritly-chat-window.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Ultra Clean Header */
.claritly-chat-header {
  padding: 15px 18px;
  background: var(--claritly-white);
  border-bottom: 1px solid var(--claritly-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.claritly-chat-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.claritly-chat-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--claritly-black);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--claritly-orange);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.claritly-chat-online-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid var(--claritly-white);
}

.claritly-chat-title {
  color: var(--claritly-black);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.claritly-chat-close-btn {
  background: transparent;
  border: none;
  color: var(--claritly-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.claritly-chat-close-btn:hover {
  color: var(--claritly-black);
  background: #f4f4f5;
}

/* Message Feed Body */
.claritly-chat-messages {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background: #fafafa;
}

.claritly-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.claritly-chat-messages::-webkit-scrollbar-thumb {
  background: #d4d4d8;
  border-radius: 4px;
}

/* Message Bubbles */
.claritly-msg-group {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

.claritly-msg-group.user {
  align-self: flex-end;
  align-items: flex-end;
}

.claritly-msg-group.admin {
  align-self: flex-start;
  align-items: flex-start;
}

.claritly-msg-bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

/* User Bubble (Outgoing) */
.claritly-msg-group.user .claritly-msg-bubble {
  background: var(--claritly-black);
  color: #ffffff;
  border-bottom-right-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Support Admin Bubble (Incoming / Welcome) */
.claritly-msg-group.admin .claritly-msg-bubble {
  background: var(--claritly-white);
  color: var(--claritly-black);
  border: 1px solid var(--claritly-border);
  border-bottom-left-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.claritly-msg-image {
  margin-top: 6px;
  max-width: 200px;
  max-height: 160px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  border: 1px solid var(--claritly-border);
  transition: transform 0.15s;
}

.claritly-msg-image:hover {
  transform: scale(1.02);
}

.claritly-msg-meta {
  font-size: 10.5px;
  color: var(--claritly-text-muted);
  margin-top: 4px;
  padding: 0 2px;
}

/* Image Preview in Composer */
.claritly-chat-img-preview {
  position: relative;
  display: inline-block;
  margin: 6px 14px 0 14px;
  border-radius: 6px;
  overflow: hidden;
  max-width: 70px;
  max-height: 70px;
  border: 1px solid var(--claritly-orange);
}

.claritly-chat-img-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.claritly-chat-img-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat Input Footer */
.claritly-chat-footer {
  padding: 12px 14px;
  background: var(--claritly-white);
  border-top: 1px solid var(--claritly-border-subtle);
}

.claritly-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--claritly-surface);
  border: 1px solid var(--claritly-border);
  border-radius: 10px;
  padding: 4px 6px 4px 10px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.claritly-chat-form:focus-within {
  background: var(--claritly-white);
  border-color: var(--claritly-orange);
  box-shadow: 0 0 0 2px var(--claritly-orange-subtle);
}

.claritly-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--claritly-black);
  font-size: 13.5px;
  padding: 8px 0;
  outline: none;
  font-family: inherit;
}

.claritly-chat-input::placeholder {
  color: var(--claritly-text-muted);
}

.claritly-chat-btn-icon {
  background: transparent;
  border: none;
  color: var(--claritly-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.claritly-chat-btn-icon:hover {
  color: var(--claritly-black);
  background: #f4f4f5;
}

.claritly-chat-send-btn {
  background: var(--claritly-orange);
  color: #ffffff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(255, 107, 0, 0.25);
  flex-shrink: 0;
}

.claritly-chat-send-btn:hover {
  background: var(--claritly-orange-hover);
  transform: scale(1.04);
}

.claritly-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .claritly-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}
