/* Namespace all rules under .azrah-chat-* or #azrah-chat-* to avoid conflict */

:root {
  --azrah-chat-primary: #0d9488;
  --azrah-chat-primary-hover: #0f766e;
  --azrah-chat-bg-gradient: linear-gradient(135deg, #ffffff, #f8fafc);
  --azrah-chat-glass-bg: rgba(0, 0, 0, 0.03);
  --azrah-chat-glass-border: rgba(0, 0, 0, 0.08);
  --azrah-chat-text: #1e293b;
  --azrah-chat-text-muted: #64748b;
  --azrah-chat-bubble-customer: linear-gradient(135deg, #0d9488, #14b8a6);
  --azrah-chat-bubble-admin: #f1f5f9;
  --azrah-chat-bubble-system: #f8fafc;
  --azrah-chat-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
  --azrah-chat-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Floating Action Button */
.azrah-chat-wrapper {
  position: fixed;
  bottom: 24px;
  z-index: 999999;
  font-family: var(--azrah-chat-font);
}

.azrah-chat-pos-bottom-right {
  right: 24px;
  bottom: 80px;
}

@media (min-width: 481px) {
  .azrah-chat-pos-bottom-right {
    right: calc(50% - 230px + 18px);
    bottom: 80px;
  }
}

.azrah-chat-pos-bottom-left {
  left: 24px;
}

.azrah-chat-trigger-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.azrah-chat-unread-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  z-index: 10;
  line-height: 1;
}

.azrah-chat-trigger-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.azrah-chat-trigger-btn:active {
  transform: translateY(0);
}

.azrah-chat-icon-svg {
  width: 56px;
  height: 56px;
  display: block;
}

/* Chat Window Box */
.azrah-chat-window-box {
  position: absolute;
  bottom: 70px;
  width: 360px;
  height: 420px;
  background: var(--azrah-chat-bg-gradient);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--azrah-chat-glass-border);
  border-radius: 20px;
  box-shadow: var(--azrah-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1;
  transform: translateY(0) scale(1);
}

.azrah-chat-pos-bottom-right .azrah-chat-window-box {
  right: 0;
  transform-origin: bottom right;
}

.azrah-chat-pos-bottom-left .azrah-chat-window-box {
  left: 0;
  transform-origin: bottom left;
}

/* Hidden state with clean fade-scale transition */
.azrah-chat-window-box.azrah-chat-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.9);
}

/* Header */
.azrah-chat-header {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--azrah-chat-glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.azrah-chat-header-avatar {
  font-size: 24px;
  background: var(--azrah-chat-glass-bg);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--azrah-chat-glass-border);
}

.azrah-chat-header-title {
  margin: 0;
  color: var(--azrah-chat-text);
  font-size: 15px;
  font-weight: 600;
}

.azrah-chat-header-status {
  font-size: 11px;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 4px;
}

.azrah-chat-header-status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: #10b981;
  border-radius: 50%;
}

.azrah-chat-close-btn {
  background: transparent;
  border: none;
  color: var(--azrah-chat-text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s ease;
}

.azrah-chat-close-btn:hover {
  color: var(--azrah-chat-text);
}

/* Body and Views */
.azrah-chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.azrah-chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}

.azrah-chat-view.azrah-chat-hidden {
  display: none !important;
}

/* Form View Styling */
.azrah-chat-intro {
  color: var(--azrah-chat-text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin-top: 0;
  margin-bottom: 24px;
}

.azrah-chat-form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.azrah-chat-form-group label {
  color: var(--azrah-chat-text);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.azrah-chat-input {
  background: var(--azrah-chat-glass-bg);
  border: 1px solid var(--azrah-chat-glass-border);
  color: var(--azrah-chat-text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s ease;
  outline: none;
}

.azrah-chat-input:focus {
  border-color: var(--azrah-chat-primary);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.azrah-chat-btn {
  background: var(--azrah-chat-bubble-customer);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.azrah-chat-btn:hover {
  filter: brightness(1.1);
}

.azrah-chat-btn:disabled {
  background: var(--azrah-chat-text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Error/Alert Alert */
.azrah-chat-error-alert {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 16px;
}

.azrah-chat-error-alert.azrah-chat-hidden {
  display: none;
}

/* Message View / Chat Area */
.azrah-chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

/* Custom Scrollbar */
.azrah-chat-messages-container::-webkit-scrollbar,
.azrah-chat-view::-webkit-scrollbar {
  width: 5px;
}

.azrah-chat-messages-container::-webkit-scrollbar-track,
.azrah-chat-view::-webkit-scrollbar-track {
  background: transparent;
}

.azrah-chat-messages-container::-webkit-scrollbar-thumb,
.azrah-chat-view::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* Message Bubble */
.azrah-chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  animation: azrahChatFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.azrah-chat-bubble-customer {
  align-self: flex-end;
  background: var(--azrah-chat-bubble-customer);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.azrah-chat-bubble-admin {
  align-self: flex-start;
  background: var(--azrah-chat-bubble-admin);
  color: var(--azrah-chat-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--azrah-chat-glass-border);
}

.azrah-chat-bubble-system {
  align-self: center;
  background: var(--azrah-chat-bubble-system);
  color: var(--azrah-chat-text-muted);
  font-size: 12px;
  border-radius: 12px;
  text-align: center;
  max-width: 90%;
  padding: 6px 12px;
  border: 1px solid var(--azrah-chat-glass-border);
}

/* Message Input Area */
.azrah-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 0 0 0;
  border-top: 1px solid var(--azrah-chat-glass-border);
  background: transparent;
}

.azrah-chat-input-area textarea {
  flex: 1;
  background: var(--azrah-chat-glass-bg);
  border: 1px solid var(--azrah-chat-glass-border);
  color: var(--azrah-chat-text);
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 80px;
  font-family: inherit;
  transition: border-color 0.2s ease;
  line-height: 1.3;
}

.azrah-chat-input-area textarea:focus {
  border-color: var(--azrah-chat-primary);
}

.azrah-chat-send-btn {
  background: var(--azrah-chat-bubble-customer);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.azrah-chat-send-btn:hover {
  transform: scale(1.05);
}

.azrah-chat-send-svg {
  width: 18px;
  height: 18px;
  fill: #ffffff;
}

/* Helper hidden class */
.azrah-chat-hidden {
  display: none !important;
}

@keyframes azrahChatFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive constraints */
@media (max-width: 480px) {
  .azrah-chat-window-box {
    width: calc(100vw - 32px);
    height: 420px;
    max-height: calc(100vh - 120px);
    bottom: 64px;
  }
  .azrah-chat-pos-bottom-right {
    right: 16px;
  }
  .azrah-chat-pos-bottom-left {
    left: 16px;
  }
}

/* Typing Indicator */
.azrah-chat-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--azrah-chat-bubble-admin);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  max-width: 60px;
  border: 1px solid var(--azrah-chat-glass-border);
  margin-bottom: 8px;
  align-self: flex-start;
}

.azrah-chat-typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--azrah-chat-text-muted);
  border-radius: 50%;
  animation: azrahChatBounce 1.4s infinite ease-in-out both;
}

.azrah-chat-typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.azrah-chat-typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes azrahChatBounce {
  0%, 80%, 100% { 
    transform: scale(0);
  } 40% { 
    transform: scale(1.0);
  }
}
