/* ====== THEME VARIABLES ====== */
:root {
  --sidebar-width: 260px;

  --bg-body: #f5f5f7;
  --text-main: #111827;
  --text-subtle: #6b7280;

  --sidebar-bg: #ffffff;
  --border-color: #e5e7eb;
  --soft-bg: #f3f4f6;
  --soft-bg-hover: #e5e7eb;

  --ai-bg: #e5e7eb;
  --ai-text: #111827;
  --user-bg: #2563eb;

  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --input-border: #e5e5e5;
  --shadow-float: 0 0 15px rgba(0, 0, 0, 0.1);
}

/* Dark mode variables */
body.dark {
  --bg-body: #020617;
  --text-main: #f3f4f6;
  --text-subtle: #9ca3af;

  --sidebar-bg: #0f172a;
  --border-color: #1e293b;
  --soft-bg: #1e293b;
  --soft-bg-hover: #334155;

  --ai-bg: #43608f;
  --ai-text: #e5e7eb;
  --user-bg: #2563eb;

  --card-bg: #1e293b;
  --input-bg: #2f2f2f;
  --input-border: #424242;
  --shadow-float: 0 0 15px rgba(0, 0, 0, 0.5);
}

/* ====== GLOBAL ====== */
body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
  background: var(--bg-body);
  color: var(--text-main);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- FIX: Input Fields in Dark Mode --- */
input,
select,
textarea {
  background-color: var(--input-bg) !important;
  color: var(--text-main) !important;
  border-color: var(--input-border) !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-subtle);
}

/* --- FIX: Links in Dark Mode --- */
a {
  color: white;
}
body.dark a {
  color: #60a5fa;
}
body.dark a:hover {
  color: #93c5fd;
}

/* --- FIX: Markdown / Prose Content --- */
.prose,
.markdown-body {
  color: var(--text-main) !important;
}

.prose strong,
.markdown-body strong,
.prose h1,
.markdown-body h1,
.prose h2,
.markdown-body h2,
.prose h3,
.markdown-body h3,
.prose h4,
.markdown-body h4 {
  color: var(--text-main) !important;
}

.prose code,
.markdown-body code {
  background-color: var(--soft-bg);
  color: var(--text-main);
}

.prose pre,
.markdown-body pre {
  background-color: #111827; /* Always dark for code blocks */
  color: #e5e7eb;
}

/* Layout Classes */
.bg-chatgpt-body {
  background: var(--bg-body);
}
.text-chatgpt-text {
  color: var(--text-main);
}
.text-chatgpt-subtle {
  color: var(--text-subtle);
}
.bg-chatgpt-sidebar {
  background: var(--sidebar-bg);
}
.bg-chatgpt-soft {
  background: var(--soft-bg);
}
.bg-chatgpt-soft-hover {
  background: var(--soft-bg-hover);
}
.border-chatgpt-border {
  border-color: var(--border-color);
}

/* Layout Root */
.layout-root {
  min-height: 100vh;
}
.hide {
  display: none !important;
}

/* Fixed sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(15, 23, 42, 0.04);
  z-index: 30;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* When collapsed */
.sidebar.collapsed {
  width: 75px;
}
body.sidebar-collapsed .main-content {
  margin-left: 64px;
}

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-body);
  transition: margin-left 0.2s ease, background-color 0.3s ease;
}

/* Mobile sidebar open */
.sidebar.mobile-open {
  transform: translateX(0);
}

/* ====== NAV ITEMS ====== */
.nav-item {
  display: flex;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-main);
  text-decoration: none;
  margin-bottom: 2px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-item:hover {
  background: var(--soft-bg-hover);
}

/* Sidebar lists & sections */
.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.3rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
}
.sidebar-section-title {
  font-weight: 600;
}

.section-toggle-btn {
  padding: 2px;
  border-radius: 4px;
  color: var(--text-main);
}
.section-toggle-btn i {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}
.section-toggle-btn i.rotated {
  transform: rotate(-90deg);
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding-left: 0.2rem;
}
.sidebar-list li {
  margin-bottom: 2px;
}
.sidebar-list:not(.open) {
  display: none;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 0.35rem 0.4rem;
  border-radius: 0.45rem;
  font-size: 0.78rem;
  color: var(--text-main);
  text-decoration: none;
}
.sidebar-link:hover {
  background: var(--soft-bg-hover);
}

/* Hide labels when collapsed */
.sidebar.collapsed .sidebar-label-text {
  display: none;
}
.sidebar.collapsed .sidebar-footer {
  align-items: center;
}

/* ====== CARDS ====== */
.card {
  background: var(--card-bg);
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
  color: var(--text-main);
}

/* ====== CHAT BUBBLES ====== */
/* AI Message */
.ai-msg {
  background: var(--ai-bg);
  color: var(--ai-text);
  padding: 12px;
  border-radius: 12px;
  max-width: 85%;
}

/* User Message */
.user-msg {
  background: var(--user-bg);
  color: #ffffff;
  padding: 12px;
  border-radius: 12px;
  max-width: 85%;
}

.bg-blue-600 {
  background-color: #2563eb !important;
  color: white !important;
}

/* --- FIX: Green Bubble Visibility --- */
.bg-green-200 {
  background-color: #dcfce7 !important; /* Light green */
  color: #14532d !important; /* Dark green text */
}

body.dark .bg-green-200 {
  background-color: #1e293b !important; /* Dark Slate in dark mode */
  color: #e2e8f0 !important; /* Light text */
  border: 1px solid #334155;
}

/* Chat container */
body.dark #chatContainer {
  border-radius: 1rem;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
}

#chatContainer {
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: radial-gradient(circle at top left, #eef2ff 0, #ffffff 40%);
}

#chatHistory {
  max-height: 400px;
  height: 400px;
  padding: 12px;
  overflow-y: auto;
  background: transparent;
  border-radius: 0.75rem;
}
body.dark #chatHistory {
  border: 1px solid #334155;
}
#chatHistory > div {
  margin-bottom: 8px;
}

body.dark .mpcon {
  background-color: var(--card-bg);
}

body.dark #output {
  background-color: var(--card-bg);
  border-radius: 0.75rem;
}

body.dark #quizBox {
  background-color: var(--card-bg) !important;
}

#quizBox {
  margin-top: 20px !important;
}

body.dark #mindmapContainer {
  background-color: var(--card-bg);
  border: 1px solid #334155;
}

.prose pre code {
  color: white !important;
}

.compare-btn {
  color: black !important;
}

.column-box pre code {
  color: white !important;
}

/* ====== BUTTONS ====== */
.delete-btn i,
.delete-all-btn i,
.delete-detail-btn i {
  color: #ef4444;
  font-size: 18px;
}
.delete-btn,
.delete-all-btn,
.delete-detail-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
}
.delete-all-btn {
  background: #ff4d4d;
  color: white;
  border-radius: 8px;
  font-weight: bold;
}
.delete-detail-btn {
  background: #ef4444;
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 16px;
}
.regen-btn {
  background: #1d4ed8;
  color: white;
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
  margin-bottom: 15px;
  transition: background-color 0.2s;
}
.regen-btn:hover {
  background: #2563eb;
}

.model-dropdown {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  margin-bottom: 15px;
  margin-top: 5px;
  background-color: var(--input-bg);
  color: var(--text-main);
}
.model-dropdown-small {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  margin-right: 6px;
  background-color: var(--input-bg);
  color: var(--text-main);
}

/* Compare view */
.toggle-container {
  margin: 15px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.simple-container,
.diff-container {
  display: flex;
  gap: 20px;
  margin-top: 20px;
}
.column-box,
.diff-column {
  flex: 1;
  padding: 15px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  color: var(--text-main);
}
.removed {
  background: #fee2e2;
  color: black;
}
.added {
  background: #dcfce7;
  color: black;
}
.responce-container {
  margin: auto !important;
}

/* Mindmap controls */
.mind-btn {
  background: var(--soft-bg-hover);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.85;
  transition: 0.2s;
  border: 1px solid var(--border-color);
}
.mind-btn:hover {
  opacity: 1;
  background: var(--border-color);
}

#diagramWrapper.fullscreen {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--card-bg);
  z-index: 9999;
  padding: 20px;
  border-radius: 0;
}

#mindmapContainer {
  border-radius: 0.75rem;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
}
#mindmapContainer:active {
  cursor: grabbing;
}
.mindmap-scale {
  transform-origin: center center;
  transition: transform 0.2s ease-out;
}

.backbtn {
  color: white !important;
}
.backbtn:hover {
  text-decoration: none !important;
}

.input-area-container {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width); /* Matches sidebar width */
  right: 0;
  padding: 1.5rem 2rem 0.3rem 2rem; /* Top Right Bottom Left */
  background: linear-gradient(to top, var(--bg-body) 20%, transparent);
  z-index: 20;
  transition: left 0.3s ease;
}
body.sidebar-collapsed .input-area-container {
  left: 0;
}

.input-box-wrapper {
  max-width: 48rem; /* max-w-3xl */
  margin: 0 auto;
  position: relative;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 1.5rem; /* Rounded pill shape */
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
}

.input-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.input-main-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

.chat-input {
  width: 100%;
  background: transparent !important;
  border: none !important;
  resize: none;
  height: 24px; /* Start height */
  max-height: 200px;
  padding: 0 0.5rem;
  font-size: 1rem;
  line-height: 1.5;
  outline: none !important;
  box-shadow: none !important;
}
.chat-input:focus {
  outline: none;
}

.send-btn-float {
  background: #111; /* Black send button like ChatGPT */
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-bottom: 2px;
}
body.dark .send-btn-float {
  background: #fff;
  color: #000;
}

.send-btn-float:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.model-select-float {
  background: transparent !important;
  border: none !important;
  font-size: 0.85rem;
  color: var(--text-subtle) !important;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.model-select-float:hover {
  color: var(--text-main) !important;
}

.dropdown-menu {
  background-color: var(--input-bg);
  color: var(--text-main);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

/* ====== MINIMALIST BUTTONS (Action Bar) ====== */
.action-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 1rem;
  margin-bottom: 3rem; /* Space for fixed footer */
}

.minimal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: transparent;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-subtle);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}
.minimal-btn:hover {
  background-color: var(--soft-bg-hover);
  color: var(--text-main);
  border-color: var(--text-subtle);
}
.minimal-btn i {
  font-size: 0.9rem;
}

.aiout {
  color: var(--text-main) !important;
  padding: 25px;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
}
body.dark .aiout {
  background-color: var(--card-bg) !important;
  color: var(--text-main) !important;
}

body.dark .expbtn {
  color: var(--text-subtle) !important;
}

.debtn {
  color: rgb(238, 71, 71) !important;
  border: 1px solid rgb(233, 58, 58) !important ;
}

.debtn:hover {
  background-color: rgb(255, 162, 162) !important;
  border-color: rgb(233, 58, 58) !important ;
  color: rgb(233, 58, 58) !important;
}

.sidebar-label-text {
  overflow: hidden;
  height: 20px;
}

.theambtn {
  height: 20px !important;
}

.histrow {
  overflow: hidden;
  height: 35px;
}

#chatMessages {
  height: 24rem !important;
}

body.dark .mentorahead {
  color: #9ca3af;
  font-size: large;
}

body.dark #popup-content {
  background-color: #1e293b;
  text-align: center;
  border-radius: 20px;
  padding: 10px;
}

body.dark #popup-content p {
  font-size: 12px;
  color: #9ca3af !important;
}

body.dark .mentora-footer {
  background-color: #1e293b !important;
}

.mentora-footer {
  width: 100%;
  border-radius: 10px;
  background-color: #f3f4f6 !important;
}

.modal-container {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-out;

  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  transform: translateY(100vh);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  margin-bottom: 5vh;
}

.modal-container.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-container.is-visible .modal-content {
  transform: translateY(0);
}

.mentorahead {
  color: #6b7280;
  font-size: large;
}

#popup-content {
  background-color: #f3f4f6;
  text-align: center;
  border-radius: 20px;
  padding: 10px;
}

#popup-content p {
  font-size: 12px;
  color: #6b7280 !important;
}
