/* =====================================================
   VŨ TRỤ VĂN HỌC — AI CHAT CSS (REDESIGN)
   Dark Cinematic · Gold Tone · Modern Chat UI
   ===================================================== */

/* ===== SECTION ===== */
#section-ai-chat {
  min-height: 100vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: #06050f;
}

/* ===== LAYOUT ===== */
.aichat-layout {
  display: flex;
  height: calc(100vh - 60px);
  margin-top: 60px;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.aichat-sidebar {
  width: 230px;
  flex-shrink: 0;
  background: rgba(10, 8, 22, 0.98);
  border-right: 1px solid rgba(201, 169, 110, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.aichat-sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.1rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.aichat-sidebar-icon {
  color: #c9a96e;
  font-size: 0.9rem;
}

.aichat-sidebar-header h3 {
  font-size: 0.8rem;
  color: #a89070;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
}

.aichat-session-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.aichat-session-item {
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.76rem;
  color: #8a7a65;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  transition: all 0.18s ease;
}

.aichat-session-item:hover {
  background: rgba(201, 169, 110, 0.08);
  color: #c9a96e;
}

.aichat-session-item.active {
  background: rgba(201, 169, 110, 0.13);
  border-color: rgba(201, 169, 110, 0.35);
  color: #d4b278;
}

.aichat-session-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aichat-session-delete {
  background: none;
  border: none;
  color: #5a4e40;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.1rem 0.2rem;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s;
}

.aichat-session-delete:hover {
  color: #e8775a;
}

.aichat-new-session-btn {
  margin: 0.5rem;
  padding: 0.55rem;
  border: 1px dashed rgba(201, 169, 110, 0.25);
  border-radius: 8px;
  background: none;
  color: #8a7a65;
  font-size: 0.78rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.aichat-new-session-btn:hover {
  border-color: rgba(201, 169, 110, 0.5);
  color: #c9a96e;
  background: rgba(201, 169, 110, 0.06);
}

/* ===== MAIN ===== */
.aichat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(6, 5, 15, 0.98);
  overflow: hidden;
}

/* ===== CONFIG BAR ===== */
.aichat-config {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  flex-wrap: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(10, 8, 22, 0.9);
  flex-shrink: 0;
}

.aichat-config-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.aichat-label {
  font-size: 0.68rem;
  color: #7a6a55;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== INPUTS & SELECTS ===== */
.aichat-select,
#aichat-work-search,
#aichat-topic-search {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  color: #e8dcc8;
  padding: 0.42rem 0.65rem;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  font-family: inherit;
}

.aichat-select:focus,
#aichat-work-search:focus,
#aichat-topic-search:focus {
  border-color: rgba(201, 169, 110, 0.4);
}

/* ===== BUTTONS ===== */
.aichat-config-apply {
  padding: 0.45rem 1rem;
  background: #c9a96e;
  border-radius: 7px;
  color: #0a0814;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
  transition: opacity 0.18s;
}

.aichat-config-apply:hover {
  opacity: 0.87;
}

/* ===== TOOLBAR (status / model) ===== */
.aichat-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(11, 9, 22, 0.97);
  font-size: 0.76rem;
  color: #8a7a65;
  flex-shrink: 0;
}

/* ===== SUGGESTIONS ===== */
.aichat-suggestion-wrap {
  padding: 0.75rem 1.2rem 0.4rem;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.aichat-suggestion-wrap > div:first-child {
  font-size: 0.7rem;
  color: #7a6a55;
  margin-bottom: 0.45rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#aichat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.aichat-suggestion-btn {
  background: rgba(201, 169, 110, 0.07);
  border: 1px solid rgba(201, 169, 110, 0.2);
  color: #c8baa4;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  line-height: 1.35;
  font-family: inherit;
  transition: all 0.18s;
}

.aichat-suggestion-btn:hover {
  background: rgba(201, 169, 110, 0.15);
  border-color: rgba(201, 169, 110, 0.4);
  color: #e8dcc8;
}

/* ===== MESSAGES AREA ===== */
.aichat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.aichat-messages::-webkit-scrollbar {
  width: 5px;
}

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

.aichat-messages::-webkit-scrollbar-thumb {
  background: rgba(201, 169, 110, 0.2);
  border-radius: 99px;
}

.aichat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(201, 169, 110, 0.35);
}

/* ===== WELCOME ===== */
.aichat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 3rem 2rem;
  color: #6a5a48;
  text-align: center;
  flex: 1;
}

.aichat-welcome-icon {
  font-size: 2.5rem;
  color: rgba(201, 169, 110, 0.25);
}

.aichat-welcome p {
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 340px;
}

/* ===== SESSION CHIP ===== */
.aichat-session-chip {
  align-self: center;
  background: rgba(201, 169, 110, 0.1);
  border: 1px solid rgba(201, 169, 110, 0.22);
  color: #a89070;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.74rem;
  letter-spacing: 0.03em;
}

/* ===== BUBBLE WRAP ===== */
.aichat-bubble-wrap {
  display: flex;
  max-width: 78%;
}

.aichat-bubble-user {
  align-self: flex-end;
  justify-content: flex-end;
  margin-left: auto;
}

.aichat-bubble-assistant {
  align-self: flex-start;
  justify-content: flex-start;
}

/* ===== BUBBLE ===== */
.aichat-bubble {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.65;
  word-break: break-word;
  max-width: 100%;
}

.aichat-bubble-user .aichat-bubble {
  background: linear-gradient(135deg, #c9a96e, #b08a4e);
  color: #1a1208;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.aichat-bubble-assistant .aichat-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e0d4c0;
  border-bottom-left-radius: 4px;
}

/* ===== BUBBLE ANIMATION ===== */
@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.aichat-bubble-in {
  animation: bubbleIn 0.22s ease forwards;
}

/* ===== LOADING DOTS ===== */
.aichat-loading {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 0.75rem 1rem;
}

.aichat-loading span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c9a96e;
  opacity: 0.5;
  animation: loadingDot 1.2s infinite ease-in-out;
}

.aichat-loading span:nth-child(2) { animation-delay: 0.2s; }
.aichat-loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingDot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* ===== INPUT AREA ===== */
.aichat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(10, 8, 22, 0.97);
  flex-shrink: 0;
}

.aichat-textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.7rem 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  color: #f0e8d8;
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.55;
  min-height: 48px;
  max-height: 160px;
  outline: none;
  transition: border-color 0.2s;
}

.aichat-textarea:focus {
  border-color: rgba(201, 169, 110, 0.45);
}

.aichat-textarea:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.aichat-textarea::placeholder {
  color: #5a4e40;
  font-size: 0.82rem;
}

.aichat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #c9a96e, #a07840);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.18s ease;
  align-self: flex-end;
}

.aichat-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #d8b97e, #b08850);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201, 169, 110, 0.3);
}

.aichat-send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== FLOATING CHAT BUTTON ===== */
#floating-chat-btn {
  position: fixed;
  bottom: 1.8rem;
  right: 1.8rem;
  z-index: 9000;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a96e, #8a5c28);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 20px rgba(201, 169, 110, 0.35),
    0 0 0 0 rgba(201, 169, 110, 0.4);
  animation: floatPulse 2.8s ease-in-out infinite;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

#floating-chat-btn svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  flex-shrink: 0;
}

#floating-chat-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow:
    0 8px 32px rgba(201, 169, 110, 0.5),
    0 0 0 6px rgba(201, 169, 110, 0.1);
  animation: none;
}

@keyframes floatPulse {
  0%   { box-shadow: 0 4px 20px rgba(201,169,110,0.35), 0 0 0 0 rgba(201,169,110,0.35); }
  50%  { box-shadow: 0 4px 20px rgba(201,169,110,0.35), 0 0 0 10px rgba(201,169,110,0); }
  100% { box-shadow: 0 4px 20px rgba(201,169,110,0.35), 0 0 0 0 rgba(201,169,110,0); }
}

/* Tooltip on hover */
#floating-chat-btn::before {
  content: "Trò chuyện AI";
  position: absolute;
  right: 68px;
  background: rgba(12, 10, 24, 0.95);
  border: 1px solid rgba(201, 169, 110, 0.3);
  color: #d4b278;
  font-size: 0.75rem;
  white-space: nowrap;
  padding: 0.35rem 0.75rem;
  border-radius: 7px;
  font-family: 'Be Vietnam Pro', sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#floating-chat-btn:hover::before {
  opacity: 1;
}

/* ===== ACTION BUTTONS IN BUBBLE ===== */
.aichat-bubble-action {
  background: rgba(201, 169, 110, 0.1);
  border: 1px solid rgba(201, 169, 110, 0.22);
  color: #c8baa4;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.74rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.aichat-bubble-action:hover {
  background: rgba(201, 169, 110, 0.18);
  color: #e8dcc8;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  .aichat-layout {
    flex-direction: column;
    height: calc(100vh - 60px);
  }

  /* Sidebar → horizontal scroll strip */
  .aichat-sidebar {
    width: 100%;
    flex-direction: column;
    height: auto;
    border-right: none;
    border-bottom: 1px solid rgba(201, 169, 110, 0.1);
    flex-shrink: 0;
  }

  .aichat-sidebar-header {
    padding: 0.65rem 0.8rem;
  }

  .aichat-session-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.4rem 0.6rem;
    max-height: 52px;
  }

  .aichat-session-item {
    min-width: 110px;
    flex-shrink: 0;
  }

  .aichat-new-session-btn {
    display: none; /* hide on mobile sidebar row; add inline in list instead */
  }

  /* Config: wrap to 2-column grid */
  .aichat-config {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding: 0.7rem;
  }

  .aichat-config-row {
    width: 100%;
  }

  .aichat-select,
  #aichat-work-search,
  #aichat-topic-search {
    font-size: 0.85rem;
  }

  .aichat-config-apply {
    width: 100%;
    text-align: center;
    padding: 0.55rem;
    font-size: 0.85rem;
  }

  /* Bubbles full width */
  .aichat-bubble-wrap {
    max-width: 95%;
  }

  .aichat-messages {
    padding: 0.9rem 0.8rem;
    gap: 0.8rem;
  }

  /* Input area stacked */
  .aichat-input-area {
    padding: 0.6rem 0.7rem;
    gap: 0.45rem;
  }

  .aichat-textarea {
    font-size: 0.9rem;
  }

  /* Floating button smaller, away from input */
  #floating-chat-btn {
    bottom: 1.2rem;
    right: 1.2rem;
    width: 50px;
    height: 50px;
  }

  #floating-chat-btn::before {
    display: none;
  }
}

@media (max-width: 480px) {
  .aichat-bubble-wrap {
    max-width: 100%;
  }

  .aichat-bubble {
    font-size: 0.85rem;
  }
}
/* FIX dropdown chọn tác phẩm + chủ đề */
select {
  background: #111118 !important;
  color: #e8e4d8 !important;
  border: 1px solid rgba(255,255,255,0.15);
}

/* option bên trong */
select option {
  background: #111118;
  color: #e8e4d8;
}

/* option đang hover */
select option:hover {
  background: #1c1c28;
  color: #fff;
}

/* option được chọn */
select option:checked {
  background: #c89b3c;
  color: #0a0a0f;
}