/* ==========================================================================
   MODULE: TRỢ LÝ AI CHUYÊN SÂU (#tab-ai)
   ========================================================================== */

#tab-ai {
  padding-top: 50px !important;
  padding-bottom: 60px;
}

.ai-studio-container {
  max-width: 1200px;
  margin: 0 auto;
}

.ai-studio-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  min-height: 720px;
}

/* 1. SIDEBAR HỖ TRỢ */
.ai-studio-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ai-expert-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.ai-avatar-glow {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
  border: 2px solid #2563EB;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  position: relative;
  margin-bottom: 14px;
  box-shadow: 0 0 16px rgba(37, 99, 235, 0.2);
}

.live-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  background: #16A34A;
  border: 2px solid #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 0 8px #16A34A;
}

.expert-name {
  font-size: 17px;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 2px;
}

.expert-role {
  font-size: 12px;
  font-weight: 700;
  color: #2563EB;
  display: block;
  margin-bottom: 10px;
}

.expert-desc {
  font-size: 13px;
  color: #64748B;
  line-height: 1.55;
}

/* Emergency Box */
.ai-emergency-box {
  background: linear-gradient(135deg, #FFF1F2 0%, #FFE4E6 100%);
  border: 1px solid #FECDD3;
  border-radius: 18px;
  padding: 18px;
}

.emergency-badge {
  font-size: 11px;
  font-weight: 900;
  color: #E11D48;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.emergency-text {
  font-size: 12.5px;
  color: #881337;
  line-height: 1.5;
  margin-bottom: 12px;
}

.btn-call-111 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: #E11D48;
  color: #FFFFFF;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 800;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25);
}

.btn-call-111:hover {
  background: #BE123C;
  transform: translateY(-2px);
}

/* Topics list */
.ai-topics-section {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 20px;
  padding: 20px;
  flex-grow: 1;
}

.topics-heading {
  font-size: 13.5px;
  font-weight: 800;
  color: #334155;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topics-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic-chip-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 13px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.topic-chip-btn:hover {
  background: #EFF6FF;
  border-color: #93C5FD;
  color: #1D4ED8;
  transform: translateX(3px);
}

.topic-icon {
  font-size: 16px;
}

.btn-reset-studio-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  color: #64748B;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reset-studio-chat:hover {
  background: #F1F5F9;
  color: #0F172A;
  border-color: #94A3B8;
}

/* 2. CHAT CANVAS (CỘT PHẢI) */
.ai-studio-canvas {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.05);
  overflow: hidden;
  height: 720px;
}

.studio-canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #F8FAFC;
  border-bottom: 1px solid #E2E8F0;
}

.canvas-header-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.canvas-header-title {
  font-size: 15px;
  font-weight: 800;
  color: #0F172A;
}

.canvas-header-status {
  font-size: 12px;
  color: #16A34A;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: #16A34A;
  border-radius: 50%;
  box-shadow: 0 0 6px #16A34A;
}

.canvas-header-tag {
  font-size: 11px;
  font-weight: 800;
  color: #2563EB;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}

/* Messages Stream */
.studio-messages-stream {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: #FAFCFF;
}

.studio-msg-row {
  display: flex;
  gap: 12px;
  max-width: 85%;
}

.studio-msg-row.bot {
  align-self: flex-start;
}

.studio-msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #EFF6FF;
  border: 1px solid #DBEAFE;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.studio-msg-row.user .msg-avatar {
  background: #1E293B;
  color: #FFFFFF;
  border: none;
  font-size: 14px;
  font-weight: 800;
}

.msg-content-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-sender-name {
  font-size: 12px;
  font-weight: 700;
  color: #64748B;
}

.studio-msg-row.user .msg-sender-name {
  text-align: right;
}

.msg-bubble {
  padding: 16px 20px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.6;
}

.studio-msg-row.bot .msg-bubble {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  color: #1E293B;
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.studio-msg-row.user .msg-bubble {
  background: #2563EB;
  color: #FFFFFF;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.msg-bubble p {
  margin: 0 0 10px 0;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble ul, .msg-bubble ol {
  margin: 8px 0 10px 20px;
  padding: 0;
}

.msg-bubble li {
  margin-bottom: 6px;
}

.msg-bubble strong {
  color: #0F172A;
}

.studio-msg-row.user .msg-bubble strong {
  color: #FFFFFF;
}

.msg-time {
  font-size: 11px;
  color: #94A3B8;
  margin-top: 2px;
}

.studio-msg-row.user .msg-time {
  text-align: right;
}

/* Studio Suggestions */
.studio-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.studio-sug-chip {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: #1D4ED8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.studio-sug-chip:hover {
  background: #DBEAFE;
  transform: translateY(-1px);
}

/* Typing indicator */
.studio-typing-indicator {
  padding: 8px 24px;
  background: #FAFCFF;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #64748B;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: #2563EB;
  border-radius: 50%;
  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); }
}

.typing-text {
  margin-left: 6px;
}

/* Input Container */
.studio-input-container {
  padding: 18px 24px;
  background: #FFFFFF;
  border-top: 1px solid #E2E8F0;
}

.studio-input-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F8FAFC;
  border: 1.5px solid #CBD5E1;
  border-radius: 16px;
  padding: 8px 14px;
  transition: all 0.2s ease;
}

.studio-input-bar:focus-within {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: #FFFFFF;
}

.studio-textarea {
  flex-grow: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14.5px;
  color: #0F172A;
  font-family: inherit;
  resize: none;
  max-height: 120px;
}

.btn-studio-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #2563EB;
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-studio-send:hover {
  background: #1D4ED8;
  transform: scale(1.05);
}

.studio-input-note {
  font-size: 11.5px;
  color: #94A3B8;
  margin-top: 8px;
  text-align: center;
}

@media (max-width: 900px) {
  .ai-studio-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .ai-studio-canvas {
    height: 580px;
  }
}
