/* =============================================================
   MindGurus AI Guide — Page Template Styles
   Design tokens match the Figma specification exactly.
   ============================================================= */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600&family=Public+Sans:wght@400;500;600&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  --mg-input:               #E4D7B8;
  --mg-accent-fg:           #2B241C;
  --mg-muted-fg:            #6B6459;
  --mg-destructive:         #B23B2E;
  --mg-destructive-fg:      #F8F3E9;
  --mg-primary-fg:          #FDFAF3;
  --mg-ring:                #B98A3D;
  --mg-safety-bg:           rgba(178,59,46,0.051);
  --mg-safety-border:       rgba(178,59,46,0.302);
  --mg-tag-pill-bg:         rgba(234,217,174,0.698);
  --mg-border-subtle:       rgba(228,215,184,0.600);
  --mg-shadow-card:         0px 8px 24px 0px rgba(43,36,28,0.059),
                            0px 1px 2px 0px rgba(43,36,28,0.039);
  --mg-user-bubble-bg:      #B98A3D;
  --mg-user-bubble-fg:      #FDFAF3;
}

/* ---------- Page Wrapper ---------- */
.mg-ai-guide-wrap, .mg-ai-guide-wrap * {
  box-sizing: border-box;
}

.mg-ai-guide-wrap {
  background: #F8F3E9;
  min-height: 100vh;
  padding: 48px 24px 80px;
  overflow-x: hidden;
}

.mg-ai-guide-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 341px 1fr;
  gap: 24px;
  align-items: start;
}

/* =============================================================
   LEFT CARD
   ============================================================= */
.mg-ai-left-card {
  width: 100%;
  background: var(--mg-primary-fg);
  border: 1px solid var(--mg-input);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--mg-shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 100px;
}

/* Tag pill at top */
.mg-ai-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 9999px;
  background: var(--mg-tag-pill-bg);
  font-family: 'Public Sans', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--mg-accent-fg);
  width: fit-content;
}

.mg-ai-tag-pill svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Main heading */
.mg-ai-left-heading {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: 30px;
  line-height: 36px;
  letter-spacing: -0.45px;
  color: var(--mg-accent-fg);
  margin: 0;
}

/* Disclaimer text */
.mg-ai-disclaimer {
  font-family: 'Public Sans', sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: var(--mg-muted-fg);
  margin: 0;
}

/* Safety box */
.mg-ai-safety-box {
  background: var(--mg-safety-bg);
  border: 1px solid var(--mg-safety-border);
  border-radius: 20px;
  padding: 28px 16px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mg-ai-safety-label {
  font-family: 'Public Sans', sans-serif;
  font-weight: 400;
  font-size: 10px;
  line-height: 15px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--mg-destructive);
  margin: 0;
}

.mg-ai-safety-text {
  font-family: 'Public Sans', sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: var(--mg-accent-fg);
  margin: 0;
}

.mg-ai-safety-link {
  font-family: 'Public Sans', sans-serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 20px;
  color: var(--mg-destructive);
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.2s ease;
}

.mg-ai-safety-link:hover {
  opacity: 0.8;
}

/* Thread list (sidebar within the full-page template) */
.mg-ai-thread-list-wrap {
  margin-top: 8px;
  border-top: 1px solid var(--mg-border-subtle);
  padding-top: 12px;
}

.mg-ai-thread-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.mg-ai-thread-list-title {
  font-family: 'Public Sans', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--mg-muted-fg);
}

.mg-ai-new-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--mg-ring);
  color: var(--mg-primary-fg);
  border: none;
  border-radius: 9999px;
  font-family: 'Public Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.mg-ai-new-chat-btn:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.mg-ai-thread-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.mg-ai-thread-list li {
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'Public Sans', sans-serif;
  font-size: 12px;
  color: var(--mg-accent-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease;
}

.mg-ai-thread-list li:hover {
  background: var(--mg-destructive-fg, #F8F3E9);
}

.mg-ai-thread-list li.active {
  background: rgba(185,138,61,0.12);
  font-weight: 500;
}

/* =============================================================
   RIGHT CHAT PANEL
   ============================================================= */
.mg-ai-right-panel {
  background: var(--mg-primary-fg);
  border: 1px solid var(--mg-input);
  border-radius: 24px;
  box-shadow: var(--mg-shadow-card);
  display: flex;
  flex-direction: column;
  min-height: 560px;
  overflow: hidden;
}

/* Message feed */
.mg-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.mg-ai-messages::-webkit-scrollbar {
  width: 4px;
}
.mg-ai-messages::-webkit-scrollbar-thumb {
  background: var(--mg-input);
  border-radius: 2px;
}

/* ---- Message bubbles ---- */
.mg-ai-bubble-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  animation: mg-bubble-in 0.25s ease both;
}

@keyframes mg-bubble-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* AI bubble — left aligned */
.mg-ai-bubble-wrap.ai {
  flex-direction: row;
}

/* User bubble — right aligned */
.mg-ai-bubble-wrap.user {
  flex-direction: row-reverse;
}

.mg-ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--mg-ring);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.mg-ai-bubble {
  max-width: 531px;
  padding: 12px 16px;
  border-radius: 20px;
  font-family: 'Public Sans', sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: var(--mg-accent-fg);
}

/* AI bubble — cream background */
.mg-ai-bubble-wrap.ai .mg-ai-bubble {
  background: var(--mg-destructive-fg);
  border-radius: 4px 20px 20px 20px;
}

.mg-ai-bubble h1, .mg-ai-bubble h2, .mg-ai-bubble h3 {
  margin: 0 0 8px 0;
  font-size: 1.1em;
  font-weight: 600;
}

.mg-ai-bubble strong {
  font-weight: 600;
}

.mg-ai-button-link {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 16px;
  background: var(--mg-ring, #B98A3D);
  color: #ffffff !important;
  text-decoration: none;
  border-radius: 9999px;
  font-family: 'Public Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.mg-ai-button-link:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

/* User bubble — gold background */
.mg-ai-bubble-wrap.user .mg-ai-bubble {
  background: var(--mg-user-bubble-bg);
  color: var(--mg-user-bubble-fg);
  border-radius: 20px 4px 20px 20px;
}

/* ---- Typing indicator ---- */
.mg-ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
  background: var(--mg-destructive-fg);
  border-radius: 4px 20px 20px 20px;
  width: fit-content;
}

.mg-ai-typing span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mg-muted-fg);
  animation: mg-typing-dot 1.3s infinite ease-in-out;
}

.mg-ai-typing span:nth-child(1) { animation-delay: 0s; }
.mg-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.mg-ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes mg-typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ---- Predefined tags section ---- */
.mg-ai-quick-wrap {
  border-top: 1px solid var(--mg-border-subtle);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mg-ai-quick-label {
  font-family: 'Public Sans', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--mg-muted-fg);
  margin: 0;
}

.mg-ai-quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mg-ai-quick-tag {
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid var(--mg-input);
  background: var(--mg-destructive-fg);
  font-family: 'Public Sans', sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
  color: var(--mg-accent-fg);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
  border: none;
}

.mg-ai-quick-tag:hover {
  background: rgba(185,138,61,0.12);
  border-color: var(--mg-ring);
  transform: translateY(-1px);
}

/* ---- Input bar ---- */
.mg-ai-input-wrap {
  border-top: 1px solid var(--mg-border-subtle);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mg-ai-input {
  flex: 1;
  height: 46px;
  padding: 14px 20px;
  border-radius: 9999px;
  border: none;
  background: #ffffff;
  font-family: 'Public Sans', sans-serif;
  font-size: 14px;
  color: #000000;
  outline: none;
  transition: box-shadow 0.2s ease;
}

.mg-ai-input::placeholder {
  color: var(--mg-muted-fg);
}

.mg-ai-input:focus {
  box-shadow: 0 0 0 3px rgba(185,138,61,0.15);
}

.mg-ai-send-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  height: 44px;
  border-radius: 9999px;
  background: var(--mg-ring);
  border: none;
  cursor: pointer;
  font-family: 'Public Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--mg-primary-fg);
  transition: opacity 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
}

.mg-ai-send-btn:hover:not(:disabled) {
  opacity: 0.88;
  transform: translateY(-1px);
}

.mg-ai-send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mg-ai-send-btn svg {
  flex-shrink: 0;
}

/* =============================================================
   RESPONSIVE
   ============================================================= */

/* Tablet — stack columns */
@media (max-width: 900px) {
  .mg-ai-guide-inner {
    grid-template-columns: 1fr;
    max-width: 700px;
  }

  .mg-ai-left-card {
    position: static;
  }

  .mg-ai-right-panel {
    min-height: 480px;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .mg-ai-guide-wrap {
    padding: 24px 12px 60px;
  }

  .mg-ai-left-heading {
    font-size: 24px;
    line-height: 30px;
  }

  .mg-ai-quick-tags {
    gap: 6px;
  }

  .mg-ai-quick-tag {
    font-size: 11px;
    padding: 5px 10px;
    white-space: normal;
  }

  .mg-ai-send-btn span {
    display: none;
  }

  .mg-ai-send-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }

  .mg-ai-bubble {
    max-width: calc(100vw - 80px);
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
  }
  
  .mg-ai-bubble pre,
  .mg-ai-bubble code,
  .mg-ai-bubble table {
    max-width: 100%;
    overflow-x: auto;
  }
}

