/* ==========================================================================
   HaiZuka Academy - AI Chat Page Styling (/chat)
   ========================================================================== */

:root {
  --haizuka-chat-primary: #7367f0;
  --haizuka-chat-primary-hover: #5e50ee;
  --haizuka-chat-bg-light: #f8f7fa;
  --haizuka-chat-card-bg: #ffffff;
  --haizuka-chat-border-color: rgba(75, 70, 92, 0.12);
  --haizuka-chat-text-main: #5d596c;
  --haizuka-chat-text-dark: #33303c;
  --haizuka-chat-shadow: 0 0.25rem 1.25rem rgba(165, 163, 174, 0.15);
  --haizuka-chat-bot-bubble-bg: #f1f0f7;
  --haizuka-chat-user-bubble-bg: #7367f0;
  --haizuka-chat-user-bubble-text: #ffffff;
}

[data-theme="dark"], html.dark-style {
  --haizuka-chat-bg-light: #25293c;
  --haizuka-chat-card-bg: #2f3349;
  --haizuka-chat-border-color: rgba(225, 222, 245, 0.12);
  --haizuka-chat-text-main: #b6bee3;
  --haizuka-chat-text-dark: #cfd3ec;
  --haizuka-chat-shadow: 0 0.25rem 1.25rem rgba(15, 20, 34, 0.35);
  --haizuka-chat-bot-bubble-bg: #363b54;
  --haizuka-chat-user-bubble-bg: #7367f0;
  --haizuka-chat-user-bubble-text: #ffffff;
}

/* Page Layout Container */
.haizuka-page-chat-container {
  min-height: calc(100vh - 12rem);
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
}

.haizuka-chat-wrapper-card {
  background: var(--haizuka-chat-card-bg);
  border-radius: 1rem;
  box-shadow: var(--haizuka-chat-shadow);
  border: 1px solid var(--haizuka-chat-border-color);
  overflow: hidden;
  display: flex;
  height: calc(100vh - 12rem);
  min-height: 600px;
}

/* Left Sidebar */
.haizuka-chat-sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--haizuka-chat-bg-light);
  border-right: 1px solid var(--haizuka-chat-border-color);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  overflow-y: auto;
  gap: 1.25rem;
}

.haizuka-sidebar-profile {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--haizuka-chat-border-color);
}

.haizuka-sidebar-avatar-wrapper {
  position: relative;
  width: 48px;
  height: 48px;
}

.haizuka-sidebar-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: contain;
  background: transparent;
  border: 2px solid var(--haizuka-chat-primary);
  box-shadow: 0 4px 12px rgba(115, 103, 240, 0.25);
}

.haizuka-sidebar-online-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background-color: #28c76f;
  border: 2px solid var(--haizuka-chat-card-bg);
  border-radius: 50%;
}

.haizuka-sidebar-profile-info h5 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--haizuka-chat-text-dark);
}

.haizuka-sidebar-profile-info p {
  margin: 2px 0 0 0;
  font-size: 0.8rem;
  color: var(--haizuka-chat-text-main);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Sidebar Section Titles & Lists */
.haizuka-sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #a5a3ae;
  margin-bottom: 0.5rem;
}

.haizuka-suggested-prompts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.haizuka-page-prompt-chip {
  background: var(--haizuka-chat-card-bg);
  color: var(--haizuka-chat-text-dark);
  border: 1px solid var(--haizuka-chat-border-color);
  padding: 0.65rem 0.85rem;
  border-radius: 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.haizuka-page-prompt-chip:hover {
  background: var(--haizuka-chat-primary);
  color: #ffffff;
  border-color: var(--haizuka-chat-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(115, 103, 240, 0.3);
}

.haizuka-page-prompt-chip i {
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Sidebar Action Buttons */
.haizuka-sidebar-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--haizuka-chat-border-color);
}

.haizuka-sidebar-btn {
  width: 100%;
  padding: 0.65rem 1rem;
  border-radius: 0.6rem;
  border: 1px solid var(--haizuka-chat-border-color);
  background: var(--haizuka-chat-card-bg);
  color: var(--haizuka-chat-text-dark);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.haizuka-sidebar-btn:hover {
  background: rgba(115, 103, 240, 0.1);
  color: var(--haizuka-chat-primary);
  border-color: var(--haizuka-chat-primary);
}

.haizuka-sidebar-btn-danger:hover {
  background: rgba(234, 84, 85, 0.1);
  color: #ea5455;
  border-color: #ea5455;
}

/* Main Chat Section */
.haizuka-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--haizuka-chat-card-bg);
  position: relative;
  overflow: hidden;
}

/* Chat Main Header */
.haizuka-page-chat-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--haizuka-chat-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--haizuka-chat-card-bg);
  z-index: 10;
}

.haizuka-page-header-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.haizuka-page-header-title h4 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--haizuka-chat-text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.haizuka-page-header-title span {
  font-size: 0.8rem;
  color: var(--haizuka-chat-text-main);
}

.haizuka-sidebar-toggle-btn {
  display: none;
  background: none;
  border: 1px solid var(--haizuka-chat-border-color);
  border-radius: 0.5rem;
  padding: 0.4rem 0.6rem;
  color: var(--haizuka-chat-text-dark);
  cursor: pointer;
}

/* Chat Messages Feed Area */
.haizuka-page-chat-messages {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.haizuka-page-chat-messages::-webkit-scrollbar {
  width: 6px;
}
.haizuka-page-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(115, 103, 240, 0.25);
  border-radius: 10px;
}

/* Message Rows & Bubbles */
.haizuka-page-chat-messages .haizuka-msg-row {
  display: flex;
  gap: 0.85rem;
  max-width: 85%;
}

.haizuka-page-chat-messages .haizuka-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.haizuka-page-chat-messages .haizuka-msg-bot {
  align-self: flex-start;
}

.haizuka-page-chat-messages .haizuka-msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid var(--haizuka-chat-primary);
}

.haizuka-page-chat-messages .haizuka-msg-content {
  background: var(--haizuka-chat-bot-bubble-bg);
  color: var(--haizuka-chat-text-dark);
  padding: 0.85rem 1.15rem;
  border-radius: 1rem;
  border-top-left-radius: 0.2rem;
  font-size: 0.92rem;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.haizuka-page-chat-messages .haizuka-msg-user .haizuka-msg-content {
  background: var(--haizuka-chat-user-bubble-bg);
  color: var(--haizuka-chat-user-bubble-text);
  border-radius: 1rem;
  border-top-right-radius: 0.2rem;
  border-top-left-radius: 1rem;
}

.haizuka-page-chat-messages .haizuka-msg-content p:last-child {
  margin-bottom: 0;
}

/* Code Block & Markdown Styles */
.haizuka-page-chat-messages pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 1rem;
  border-radius: 0.6rem;
  position: relative;
  overflow-x: auto;
  margin: 0.8rem 0;
}

.haizuka-page-chat-messages code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
}

.haizuka-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #181825;
  padding: 0.35rem 0.85rem;
  margin: -1rem -1rem 0.8rem -1rem;
  border-top-left-radius: 0.6rem;
  border-top-right-radius: 0.6rem;
  font-size: 0.75rem;
  color: #a6adc8;
}

.haizuka-copy-code-btn {
  background: transparent;
  border: none;
  color: #89b4fa;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.haizuka-copy-code-btn:hover {
  color: #cba6f7;
}

/* Chat Footer & Input Wrapper */
.haizuka-page-chat-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--haizuka-chat-border-color);
  background: var(--haizuka-chat-card-bg);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.haizuka-page-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--haizuka-chat-bg-light);
  border: 1.5px solid var(--haizuka-chat-border-color);
  border-radius: 0.85rem;
  padding: 0.4rem 0.6rem 0.4rem 0.8rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.haizuka-page-input-wrapper:focus-within {
  border-color: var(--haizuka-chat-primary);
  box-shadow: 0 0 0 3px rgba(115, 103, 240, 0.15);
}

.haizuka-page-input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  max-height: 120px;
  font-size: 0.92rem;
  color: var(--haizuka-chat-text-dark);
  font-family: inherit;
  padding: 0.4rem 0.5rem;
}

.haizuka-page-input-wrapper textarea::placeholder {
  color: #a5a3ae;
}

.haizuka-page-attach-btn,
.haizuka-page-send-btn {
  background: transparent;
  border: none;
  color: var(--haizuka-chat-primary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.haizuka-page-attach-btn:hover {
  background: rgba(115, 103, 240, 0.1);
}

.haizuka-page-send-btn {
  background: var(--haizuka-chat-primary);
  color: #ffffff;
}

.haizuka-page-send-btn:hover {
  background: var(--haizuka-chat-primary-hover);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(115, 103, 240, 0.35);
}

.haizuka-page-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.haizuka-page-footer-note {
  font-size: 0.75rem;
  color: #a5a3ae;
  text-align: center;
}

/* Image Preview Bar */
.haizuka-img-preview-container {
  display: flex;
  gap: 0.6rem;
  padding: 0.4rem 0;
  overflow-x: auto;
}

.haizuka-img-preview-item {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--haizuka-chat-primary);
}

.haizuka-img-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.haizuka-img-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive Media Queries */
@media (max-width: 991.98px) {
  .haizuka-chat-sidebar {
    position: absolute;
    left: -320px;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: left 0.3s ease;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  }

  .haizuka-chat-sidebar.show {
    left: 0;
  }

  .haizuka-sidebar-toggle-btn {
    display: flex;
    align-items: center;
  }
}

@media (max-width: 575.98px) {
  .haizuka-chat-wrapper-card {
    height: calc(100vh - 8rem);
    border-radius: 0.5rem;
  }

  .haizuka-page-chat-messages {
    padding: 1rem;
  }

  .haizuka-page-chat-messages .haizuka-msg-row {
    max-width: 95%;
  }

  .haizuka-page-chat-footer {
    padding: 0.75rem 1rem;
  }
}
