/* =========================================================
   PBX1 ELITE - CHAT & AGENT SUPPORT STYLES
   (Scoped & Perfectly Aligned with layout.css)
========================================================= */

/* Support Page Viewport Container Override */
body.support-page .pbx-game-viewport {
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  top: var(--header-calc-h) !important;
  bottom: 0 !important;
  overflow: hidden !important;
}

/* Chat Viewport Layout Alignment */
body.support-page .chat-card {
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

/* 1. Main Chat Card Wrapper */
.chat-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: var(--panel-dark, #060c1a);
  position: relative;
  overflow: hidden;
}

/* 2. Chat Scroll Area */
.chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 10px calc(var(--chat-footer-space, 75px) + env(safe-area-inset-bottom, 0px)) 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 3. Base Message Bubbles */
.msg {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: auto;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
  animation: fadeInMsg 0.2s ease-out;
}

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

/* Bot Message - Full Width Clean Rectangle Card */
.msg.bot {
  align-self: stretch;
  width: 100%;
  background: var(--card-bg, #091226);
  border: 1px solid var(--card-border, rgba(0, 212, 255, 0.18));
  color: var(--text-main, #ffffff);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* User Message - Compact Right-Aligned Bubble */
.msg.user {
  align-self: flex-end;
  width: fit-content;
  max-width: 85%;
  background: linear-gradient(135deg, var(--accent-blue, #0055ff) 0%, #003db3 100%);
  color: #ffffff;
  border-radius: 14px 14px 2px 14px;
  box-shadow: 0 3px 10px rgba(0, 85, 255, 0.25);
}

/* Admin / Live Agent Message */
.msg.admin {
  align-self: stretch;
  width: 100%;
  background: #0d1e3a;
  border: 1px solid rgba(0, 212, 255, 0.35);
  color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.1);
}

/* Image Inside Message Bubble */
.msg-img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  margin-top: 6px;
}

/* 4. Quick-Options & Action Buttons */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}

.option-btn {
  background: #060c1a;
  border: 1px solid var(--card-border, rgba(0, 212, 255, 0.2));
  color: var(--accent-cyan, #00d4ff);
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.15s ease, transform 0.1s ease;
  touch-action: manipulation;
}

.option-btn:active {
  transform: scale(0.98);
  background: rgba(0, 212, 255, 0.12);
}

/* Action Buttons */
.action-btn.btn-success {
  background: rgba(0, 192, 109, 0.12);
  border-color: var(--accent-green, #00c06d);
  color: var(--accent-green, #00c06d);
}

.action-btn.btn-agent {
  background: rgba(0, 212, 255, 0.12);
  border-color: var(--accent-cyan, #00d4ff);
  color: var(--accent-cyan, #00d4ff);
}

/* 5. Information Cards / Rules Container */
.pill-card {
  background: rgba(4, 8, 20, 0.6);
  border-left: 3px solid var(--accent-cyan, #00d4ff);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
  display: block;
  margin-top: 6px;
  word-break: break-word;
}

/* 6. Inline Close Chat Button */
.inline-close-bar {
  display: flex;
  justify-content: center;
  margin: 8px 0;
  width: 100%;
}

.global-close-chat-btn {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--accent-red, #ef4444);
  color: var(--accent-red, #ef4444);
  font-size: 12px;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.global-close-chat-btn:active {
  transform: scale(0.95);
  background: rgba(239, 68, 68, 0.25);
}

/* 7. Agent Profile Header */
.agent-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.agent-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}

.agent-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 212, 255, 0.15);
  border: 1px solid var(--accent-cyan, #00d4ff);
  color: var(--accent-cyan, #00d4ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* 8. Live Agent Input Footer */
.chat-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-dark, #040814);
  border-top: 1px solid rgba(0, 212, 255, 0.18);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  box-sizing: border-box;
  flex-shrink: 0;
}

.chat-input-bar {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  background: var(--card-bg, #091226);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 25px;
  padding: 4px 6px 4px 12px;
  min-height: 44px;
}

.chat-input-bar input[type="text"] {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 13.5px;
}

.send-btn {
  background: var(--accent-cyan, #00d4ff);
  color: #040814;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.send-btn:active {
  transform: scale(0.92);
}

/* 9. Typing Animation Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--card-bg, #091226);
  border-radius: 14px;
  width: fit-content;
  border: 1px solid var(--card-border, rgba(0, 212, 255, 0.18));
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan, #00d4ff);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

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

/* 10. Star Rating Box */
.rating-box {
  background: var(--card-bg, #091226);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.rating-box .stars {
  display: flex;
  gap: 8px;
}

.rating-box .star {
  font-size: 22px;
  color: #334155;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.1s ease;
}

.rating-box .star.active {
  color: #f59e0b;
}

.submit-feedback-btn {
  background: linear-gradient(135deg, var(--accent-cyan, #00d4ff) 0%, var(--accent-blue, #0055ff) 100%);
  color: #ffffff;
  border: none;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
