/**
 * University of Shendi Theme - AI Chatbot & Live Agent Support System
 * Modern, responsive, university-branded styling.
 * @package USH_Theme
 */

:root {
  --ush-chat-primary: #0D2C54;
  --ush-chat-primary-dark: #071C35;
  --ush-chat-primary-light: #1B4965;
  --ush-chat-accent: #C0392B;
  --ush-chat-gold: #D4AF37;
  --ush-chat-online: #10B981;
  --ush-chat-ai: #3B82F6;
  --ush-chat-bg: #FFFFFF;
  --ush-chat-surface: #F8FAFC;
  --ush-chat-border: #E2E8F0;
  --ush-chat-text: #1E293B;
  --ush-chat-text-muted: #64748B;
  --ush-chat-shadow: 0 20px 45px rgba(13, 44, 84, 0.2), 0 4px 12px rgba(0, 0, 0, 0.06);
  --ush-chat-radius: 18px;
  --ush-chat-transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Chatbot Floating Container */
.ush-chat-widget {
  position: fixed;
  bottom: 25px;
  left: 25px;
  z-index: 9998;
  font-family: inherit;
  box-sizing: border-box;
}

[dir="rtl"] .ush-chat-widget {
  left: 25px;
  right: auto;
}

[dir="ltr"] .ush-chat-widget {
  right: auto;
  left: 25px;
}

.ush-chat-widget * {
  box-sizing: border-box;
}

/* Launcher Button */
.ush-chat-launcher {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ush-chat-primary), var(--ush-chat-primary-light));
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(13, 44, 84, 0.35);
  position: relative;
  transition: var(--ush-chat-transition);
  outline: none;
  padding: 0;
}

.ush-chat-launcher:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 28px rgba(13, 44, 84, 0.45);
}

.ush-chat-launcher:active {
  transform: translateY(0) scale(0.98);
}

.ush-chat-launcher-icons {
  position: relative;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ush-chat-launcher-icons .ush-icon-open,
.ush-chat-launcher-icons .ush-icon-close {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.ush-chat-launcher-icons .ush-icon-close {
  opacity: 0;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-90deg);
}

.ush-chat-widget.active .ush-icon-open {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(90deg);
}

.ush-chat-widget.active .ush-icon-close {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) rotate(0deg);
}

/* Status Dot Indicator */
.ush-chat-status-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
}

.ush-chat-status-dot.online {
  background-color: var(--ush-chat-online);
}

.ush-chat-status-dot.ai {
  background-color: var(--ush-chat-ai);
}

/* Pulse Ripple */
.ush-chat-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--ush-chat-primary-light);
  opacity: 0.8;
  animation: ushChatPulse 2.4s infinite cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}

@keyframes ushChatPulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  70% {
    transform: scale(1.45);
    opacity: 0;
  }
  100% {
    transform: scale(1.45);
    opacity: 0;
  }
}

/* Chat Dialog Window */
.ush-chat-window {
  position: absolute;
  bottom: 80px;
  left: 0;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 590px;
  max-height: calc(100vh - 120px);
  background: var(--ush-chat-bg);
  border-radius: var(--ush-chat-radius);
  box-shadow: var(--ush-chat-shadow);
  border: 1px solid var(--ush-chat-border);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  animation: ushChatSlideIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[dir="rtl"] .ush-chat-window {
  left: 0;
  right: auto;
}

.ush-chat-widget.active .ush-chat-window {
  display: flex;
}

@keyframes ushChatSlideIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Chat Header */
.ush-chat-header {
  background: linear-gradient(135deg, var(--ush-chat-primary), var(--ush-chat-primary-dark));
  color: #FFFFFF;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.ush-chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ush-chat-gold);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}

.ush-chat-header-text h4 {
  margin: 0 0 3px;
  font-size: 1.05rem;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.2;
}

.ush-chat-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
}

.ush-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.ush-status-indicator.online {
  background-color: var(--ush-chat-online);
  box-shadow: 0 0 6px var(--ush-chat-online);
}

.ush-status-indicator.ai {
  background-color: var(--ush-chat-ai);
  box-shadow: 0 0 6px var(--ush-chat-ai);
}

.ush-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ush-chat-act-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #FFFFFF;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--ush-chat-transition);
  font-size: 18px;
  line-height: 1;
}

.ush-chat-act-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

/* Chat Body */
.ush-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: var(--ush-chat-surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: #CBD5E1 transparent;
}

.ush-chat-body::-webkit-scrollbar {
  width: 5px;
}

.ush-chat-body::-webkit-scrollbar-thumb {
  background-color: #CBD5E1;
  border-radius: 4px;
}

/* Welcome Card */
.ush-chat-intro-card {
  background: #FFFFFF;
  border: 1px solid var(--ush-chat-border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.ush-intro-icon {
  font-size: 26px;
  margin-bottom: 6px;
}

.ush-chat-intro-card h5 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ush-chat-primary);
}

.ush-chat-intro-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ush-chat-text-muted);
  line-height: 1.4;
}

/* Suggestion Chips */
.ush-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 8px;
}

.ush-chip-btn {
  background: #FFFFFF;
  border: 1px solid var(--ush-chat-border);
  color: var(--ush-chat-primary);
  padding: 7px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--ush-chat-transition);
  text-align: right;
  line-height: 1.3;
}

[dir="ltr"] .ush-chip-btn {
  text-align: left;
}

.ush-chip-btn:hover {
  background: var(--ush-chat-primary);
  color: #FFFFFF;
  border-color: var(--ush-chat-primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(13, 44, 84, 0.15);
}

/* Messages Stream */
.ush-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ush-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: ushMsgFade 0.2s ease-out;
}

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

.ush-chat-msg.visitor {
  align-self: flex-start;
}

[dir="rtl"] .ush-chat-msg.visitor {
  align-self: flex-start;
}

.ush-chat-msg.visitor .ush-bubble {
  background: linear-gradient(135deg, var(--ush-chat-primary), var(--ush-chat-primary-light));
  color: #FFFFFF;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  box-shadow: 0 2px 6px rgba(13, 44, 84, 0.15);
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

[dir="rtl"] .ush-chat-msg.visitor .ush-bubble {
  border-radius: 16px 16px 16px 4px;
}

.ush-chat-msg.bot,
.ush-chat-msg.agent {
  align-self: flex-end;
}

[dir="rtl"] .ush-chat-msg.bot,
[dir="rtl"] .ush-chat-msg.agent {
  align-self: flex-end;
}

.ush-chat-msg.bot .ush-bubble {
  background: #FFFFFF;
  color: var(--ush-chat-text);
  border: 1px solid var(--ush-chat-border);
  border-radius: 16px 16px 16px 4px;
  padding: 12px 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}

[dir="rtl"] .ush-chat-msg.bot .ush-bubble {
  border-radius: 16px 16px 4px 16px;
}

.ush-chat-msg.agent .ush-bubble {
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
  border-radius: 16px 16px 16px 4px;
  padding: 12px 14px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.08);
  font-size: 0.88rem;
  line-height: 1.5;
}

[dir="rtl"] .ush-chat-msg.agent .ush-bubble {
  border-radius: 16px 16px 4px 16px;
}

.ush-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--ush-chat-text-muted);
}

.ush-chat-msg.visitor .ush-msg-meta {
  justify-content: flex-start;
}

.ush-chat-msg.bot .ush-msg-meta,
.ush-chat-msg.agent .ush-msg-meta {
  justify-content: flex-end;
}

.ush-sender-tag {
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.ush-sender-tag.agent {
  color: #059669;
}

.ush-sender-tag.bot {
  color: var(--ush-chat-ai);
}

/* Typing Indicator */
.ush-typing-indicator {
  display: none;
  align-self: flex-end;
  background: #FFFFFF;
  border: 1px solid var(--ush-chat-border);
  padding: 8px 12px;
  border-radius: 14px;
  gap: 4px;
  align-items: center;
}

.ush-typing-indicator.active {
  display: flex;
}

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

.ush-typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.ush-typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes ushTypingDot {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.3;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Offline Lead Capture Form */
.ush-chat-lead-form {
  background: #FFFFFF;
  border-top: 1px solid var(--ush-chat-border);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F8FAFC;
}

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

.ush-lead-icon {
  font-size: 22px;
}

.ush-lead-header h6 {
  margin: 0 0 2px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ush-chat-primary);
}

.ush-lead-header small {
  color: var(--ush-chat-text-muted);
  font-size: 0.78rem;
}

.ush-lead-field {
  margin-bottom: 8px;
}

.ush-lead-field input,
.ush-lead-field select,
.ush-lead-field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--ush-chat-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--ush-chat-text);
  background: #FFFFFF;
  outline: none;
  transition: var(--ush-chat-transition);
}

.ush-lead-field input:focus,
.ush-lead-field select:focus,
.ush-lead-field textarea:focus {
  border-color: var(--ush-chat-primary);
  box-shadow: 0 0 0 3px rgba(13, 44, 84, 0.1);
}

.ush-lead-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ush-btn-lead-submit {
  flex: 1;
  background: var(--ush-chat-primary);
  color: #FFFFFF;
  border: none;
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--ush-chat-transition);
}

.ush-btn-lead-submit:hover {
  background: var(--ush-chat-primary-light);
}

.ush-btn-lead-cancel {
  background: transparent;
  color: var(--ush-chat-text-muted);
  border: 1px solid var(--ush-chat-border);
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.ush-btn-lead-cancel:hover {
  background: #E2E8F0;
  color: var(--ush-chat-text);
}

/* Chat Footer / Input Row */
.ush-chat-footer {
  padding: 12px 14px;
  background: #FFFFFF;
  border-top: 1px solid var(--ush-chat-border);
}

.ush-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.ush-chat-input-row input {
  flex: 1;
  border: 1px solid var(--ush-chat-border);
  background: var(--ush-chat-surface);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--ush-chat-text);
  outline: none;
  transition: var(--ush-chat-transition);
}

.ush-chat-input-row input:focus {
  background: #FFFFFF;
  border-color: var(--ush-chat-primary);
  box-shadow: 0 0 0 3px rgba(13, 44, 84, 0.1);
}

.ush-chat-input-row button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--ush-chat-primary);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--ush-chat-transition);
  outline: none;
  padding: 0;
  flex-shrink: 0;
}

[dir="rtl"] .ush-chat-input-row button svg {
  transform: rotate(180deg);
}

.ush-chat-input-row button:hover {
  background: var(--ush-chat-primary-light);
  transform: scale(1.06);
}

/* Responsive Mobile Styles */
@media (max-width: 600px) {
  .ush-chat-widget {
    bottom: 18px;
    left: 18px;
  }

  [dir="rtl"] .ush-chat-widget {
    left: 18px;
    right: auto;
  }

  .ush-chat-launcher {
    width: 56px;
    height: 56px;
  }

  .ush-chat-window {
    width: calc(100vw - 36px);
    height: calc(100vh - 110px);
    bottom: 74px;
    left: 0;
  }
}
