/* =========================================================
   DIS AI Chatbot — Premium Stylesheet
   ========================================================= */

/* ---------- CSS Variables ---------- */
:root {
  --dis-primary: #3763f4;
  --dis-primary-dark: #2c4fc3;
  --dis-primary-light: rgba(55,99,244,0.12);
  --dis-success: #00b779;
  --dis-bg: #ffffff;
  --dis-surface: #f8f9fb;
  --dis-border: rgba(0,0,0,0.06);
  --dis-text: #1a1d23;
  --dis-text-secondary: #4e5d78;
  --dis-text-muted: #8b95a5;
  --dis-shadow-sm: 0 2px 8px rgba(55,99,244,0.08);
  --dis-shadow-md: 0 8px 32px rgba(55,99,244,0.12);
  --dis-shadow-lg: 0 20px 60px rgba(0,0,0,0.18);
  --dis-radius: 20px;
  --dis-radius-sm: 14px;
  --dis-radius-xs: 10px;
  --dis-transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Floating Bubble ---------- */
.chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 998;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--dis-primary) 0%, var(--dis-primary-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 4px 20px rgba(55,99,244,0.35),
    0 0 0 4px rgba(55,99,244,0.08);
  transition: var(--dis-transition);
  animation: dis-bubbleFloat 3s ease-in-out infinite;
}

.chat-bubble::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(55,99,244,0.2), transparent 60%);
  z-index: -1;
  animation: dis-bubblePulse 2s ease-in-out infinite;
}

.chat-bubble:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow:
    0 8px 30px rgba(55,99,244,0.45),
    0 0 0 6px rgba(55,99,244,0.1);
}

.chat-bubble:active {
  transform: scale(0.95);
}

.chat-bubble svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

@keyframes dis-bubbleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes dis-bubblePulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 0.2; transform: scale(1.15); }
}

/* ---------- Chat Panel ---------- */
.chat-panel {
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: 999;
  width: 420px;
  max-height: 580px;
  background: rgba(255,255,255,0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: var(--dis-radius);
  display: flex;
  flex-direction: column;
  box-shadow:
    var(--dis-shadow-lg),
    0 0 0 1px rgba(0,0,0,0.03);
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.92);
  transform-origin: bottom right;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

#disChatPanel.chat-panel.open {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateY(0) scale(1) !important;
}

/* ---------- Header ---------- */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--dis-primary) 0%, var(--dis-primary-dark) 100%);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}

.chat-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.chat-header h4 {
  font-family: 'Inter','Source Sans Pro',sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  position: relative;
  z-index: 1;
}

.chat-header h4::before {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--dis-success);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(0,183,121,0.25);
  animation: dis-dotPulse 2.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes dis-dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.chat-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--dis-radius-xs);
  transition: var(--dis-transition);
  line-height: 1;
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-close:hover {
  background: rgba(255,255,255,0.3);
  transform: rotate(90deg);
}

/* ---------- Messages Area ---------- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 380px;
  background: linear-gradient(180deg, var(--dis-surface) 0%, var(--dis-bg) 100%);
  scrollbar-width: thin;
  scrollbar-color: rgba(55,99,244,0.2) transparent;
}

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

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(55,99,244,0.2);
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(55,99,244,0.35);
}

/* ---------- Message Bubbles ---------- */
.chat-msg {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: var(--dis-radius-sm);
  font-size: 0.9rem;
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
  animation: dis-msgIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  box-shadow: var(--dis-shadow-sm);
}

@keyframes dis-msgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-msg.bot {
  background: var(--dis-bg);
  border: 1px solid var(--dis-border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  color: var(--dis-text);
  margin-right: auto;
}

.chat-msg.bot::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: -6px;
  width: 12px;
  height: 12px;
  background: var(--dis-bg);
  border-left: 1px solid var(--dis-border);
  border-bottom: 1px solid var(--dis-border);
  border-radius: 0 0 0 4px;
  transform: skewX(-20deg);
}

.chat-msg.user {
  background: linear-gradient(135deg, var(--dis-primary) 0%, var(--dis-primary-dark) 100%);
  border: none;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  color: #ffffff;
  margin-left: auto;
  text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.chat-msg.user::before {
  content: '';
  position: absolute;
  bottom: 0;
  right: -6px;
  width: 12px;
  height: 12px;
  background: var(--dis-primary-dark);
  border-radius: 0 0 4px 0;
  transform: skewX(20deg);
}

.chat-msg.bot strong,
.chat-msg.user strong {
  font-weight: 700;
}

/* ---------- Typing Indicator ---------- */
.chat-msg.typing {
  background: var(--dis-bg);
  border: 1px solid var(--dis-border);
  color: var(--dis-text-secondary);
  font-style: italic;
  box-shadow: none;
  padding: 14px 18px;
}

.chat-msg.typing .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--dis-primary);
  border-radius: 50%;
  margin: 0 2px;
  animation: dis-dotB 1.4s infinite ease-in-out both;
  vertical-align: middle;
}

.chat-msg.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-msg.typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dis-dotB {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---------- Input Area ---------- */
.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--dis-border);
  background: var(--dis-bg);
  position: relative;
}

.chat-input-area::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(180deg, transparent, var(--dis-bg));
  pointer-events: none;
}

.chat-input {
  flex: 1;
  background: var(--dis-surface);
  border: 1.5px solid var(--dis-border);
  border-radius: var(--dis-radius-xs);
  padding: 12px 16px;
  color: var(--dis-text);
  font-size: 0.9rem;
  font-family: 'Inter','Source Sans Pro',sans-serif;
  outline: none;
  transition: var(--dis-transition);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
}

.chat-input:focus {
  border-color: var(--dis-primary);
  box-shadow:
    0 0 0 3px rgba(55,99,244,0.1),
    inset 0 1px 3px rgba(0,0,0,0.04);
  background: var(--dis-bg);
}

.chat-input::placeholder {
  color: var(--dis-text-muted);
  font-size: 0.88rem;
}

.chat-send {
  background: linear-gradient(135deg, var(--dis-primary) 0%, var(--dis-primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: var(--dis-radius-xs);
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--dis-transition);
  box-shadow: 0 2px 8px rgba(55,99,244,0.25);
  flex-shrink: 0;
}

.chat-send:hover {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 4px 16px rgba(55,99,244,0.35);
}

.chat-send:active {
  transform: scale(0.95);
}

.chat-send svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Mobile Responsive ---------- */
@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 88px;
    max-height: 50vh;
    border-radius: var(--dis-radius-sm);
  }

  .chat-bubble {
    width: 56px;
    height: 56px;
    bottom: 20px;
    right: 16px;
  }

  .chat-bubble svg {
    width: 24px;
    height: 24px;
  }

  .chat-header {
    padding: 14px 18px;
  }

  .chat-header h4 {
    font-size: 0.92rem;
  }

  .chat-messages {
    padding: 14px 16px;
    gap: 10px;
    max-height: 280px;
  }

  .chat-msg {
    max-width: 88%;
    padding: 10px 14px;
    font-size: 0.87rem;
  }

  .chat-input-area {
    padding: 10px 14px;
    gap: 8px;
  }

  .chat-input {
    padding: 10px 12px;
    font-size: 0.88rem;
  }

  .chat-send {
    padding: 10px 12px;
  }

  .chat-send svg {
    width: 18px;
    height: 18px;
  }
}

/* Keyboard open state (mobile) */
#disChatPanel.chat-panel.keyboard-open {
  max-height: 50vh !important;
  bottom: 12px !important;
  transition: max-height 0.25s ease, bottom 0.25s ease;
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .chat-bubble,
  .chat-panel,
  .chat-close,
  .chat-send,
  .chat-msg,
  .chat-input {
    transition: none !important;
    animation: none !important;
  }

  .chat-bubble::before {
    animation: none !important;
  }

  .chat-msg {
    animation: none !important;
  }
}
