/* ============================================================
   EduBot Beta — Custom styles
   (Tailwind CDN handles utilities; this file adds custom CSS)
   ============================================================ */

/* Material Symbols */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  user-select: none;
}
.material-symbols-outlined.filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #dadce0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bdc1c6; }

/* ---- Prose (for markdown) ---- */
.prose { font-size: 14px; line-height: 1.7; color: #202124; }
.prose h1,.prose h2,.prose h3 { font-weight: 600; margin: 1em 0 .4em; }
.prose h1 { font-size: 1.4em; }
.prose h2 { font-size: 1.2em; }
.prose h3 { font-size: 1.05em; }
.prose p  { margin: .5em 0; }
.prose ul,.prose ol { padding-left: 1.4em; margin: .4em 0; }
.prose li { margin: .2em 0; }
.prose code { background: #f1f3f4; padding: 1px 5px; border-radius: 4px; font-size: .88em; font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.prose pre  { background: #f1f3f4; padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: .6em 0; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 3px solid #1a73e8; margin: .6em 0; padding: .3em .8em; color: #5f6368; background: #e8f0fe; border-radius: 0 4px 4px 0; }
.prose strong { font-weight: 600; }
.prose table { width: 100%; border-collapse: collapse; margin: .6em 0; font-size: .95em; }
.prose th,.prose td { border: 1px solid #e8eaed; padding: 6px 10px; text-align: left; }
.prose th { background: #f8f9fa; font-weight: 600; }

/* ---- Chat bubbles ---- */
.msg-user {
  background: #1a73e8;
  color: white;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  max-width: 78%;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.6;
  align-self: flex-end;
}
.msg-assistant {
  background: #f8f9fa;
  color: #202124;
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
  max-width: 85%;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.6;
}
.msg-system {
  background: #fff3e0;
  color: #e65100;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  text-align: center;
  align-self: center;
}

/* ---- AI change notice ---- */
.change-notice-card {
  width: min(92%, 680px);
  background: linear-gradient(180deg, #fffdf4 0%, #fff9e6 100%);
  border: 1px solid #f1d58a;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
}
.change-notice-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #7a4e00;
}
.change-notice-summary {
  margin-top: 4px;
  font-size: 12px;
  color: #8a6a2f;
}
.change-item {
  background: rgba(255,255,255,.75);
  border: 1px solid #f2e2b0;
  border-radius: 10px;
  padding: 8px 10px;
}
.change-item-title {
  font-size: 12px;
  font-weight: 600;
  color: #6b4a15;
}
.change-item-values {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.change-before,
.change-after {
  display: inline-block;
  max-width: 44%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 8px;
  border-radius: 999px;
}
.change-before {
  background: #f1f3f4;
  color: #5f6368;
}
.change-after {
  background: #e8f0fe;
  color: #1a73e8;
}
.change-arrow {
  color: #9aa0a6;
  font-weight: 700;
}

/* ---- Typing indicator ---- */
.typing-dot {
  width: 8px; height: 8px;
  background: #bdc1c6;
  border-radius: 50%;
  display: inline-block;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typing-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%          { transform: translateY(-6px); }
}

/* ---- Card hover selection ---- */
.bot-card { position: relative; cursor: pointer; transition: box-shadow .15s, transform .1s; }
.bot-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.12); }
.bot-card .check-overlay {
  position: absolute; top: 8px; left: 8px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: white;
  border: 2px solid #bdc1c6;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
  z-index: 2;
}
.bot-card:hover .check-overlay,
.bot-card.selected .check-overlay { opacity: 1; }
.bot-card.selected .check-overlay { background: #1a73e8; border-color: #1a73e8; color: white; }

/* ---- Sidebar resize handle ---- */
.sidebar-resize-handle {
  width: 4px; cursor: ew-resize;
  background: transparent;
  transition: background .15s;
  flex-shrink: 0;
  position: relative;
}
.sidebar-resize-handle::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 1px; width: 2px;
}
.sidebar-resize-handle:hover::after,
.sidebar-resize-handle.dragging::after { background: #1a73e8; }

/* ---- Toast ---- */
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #323232;
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  pointer-events: auto;
  animation: toast-in .2s ease;
  min-width: 240px; max-width: 400px;
}
.toast.toast-success { background: #1e8e3e; }
.toast.toast-error   { background: #c5221f; }
.toast.toast-warning { background: #e37400; }
@keyframes toast-in { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  animation: fade-in .15s ease;
}
.modal-box {
  background: white;
  border-radius: 16px;
  padding: 28px 28px 20px;
  width: 100%; max-width: 480px;
  box-shadow: 0 8px 40px rgba(0,0,0,.15);
  animation: modal-in .2s ease;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box.modal-lg { max-width: 680px; }
.modal-box.modal-xl { max-width: 860px; }
@keyframes fade-in { from { opacity:0; } to { opacity:1; } }
@keyframes modal-in { from { opacity:0; transform: scale(.96) translateY(-8px); } to { opacity:1; transform: scale(1) translateY(0); } }

/* ---- Form elements ---- */
.field-label { display: block; font-size: 13px; font-weight: 500; color: #5f6368; margin-bottom: 4px; }
.field-input {
  width: 100%; padding: 9px 12px;
  border: 1px solid #e8eaed; border-radius: 8px;
  font-size: 14px; font-family: inherit; color: #202124;
  background: white; outline: none; transition: border .15s;
}
.field-input:focus { border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
.field-input:disabled { background: #f8f9fa; color: #9aa0a6; }
textarea.field-input { resize: vertical; min-height: 80px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
  border: none; cursor: pointer; transition: background .15s, opacity .15s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #1a73e8; color: white; }
.btn-primary:hover:not(:disabled) { background: #1557b0; }
.btn-secondary { background: #f8f9fa; color: #202124; border: 1px solid #e8eaed; }
.btn-secondary:hover:not(:disabled) { background: #f1f3f4; }
.btn-danger { background: #c5221f; color: white; }
.btn-danger:hover:not(:disabled) { background: #a50e0e; }
.btn-ghost { background: transparent; color: #1a73e8; }
.btn-ghost:hover:not(:disabled) { background: #e8f0fe; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn.ai-choice-btn {
  white-space: normal;
  height: auto;
  text-align: left;
  justify-content: flex-start;
  align-items: flex-start;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
  padding-top: 8px;
  padding-bottom: 8px;
}
.btn-icon { padding: 6px; border-radius: 50%; background: transparent; border: none; cursor: pointer; transition: background .15s; display: flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: #f1f3f4; }

/* ---- Tabs ---- */
.tab-bar { display: flex; border-bottom: 1px solid #e8eaed; gap: 0; }
.tab-item { padding: 10px 18px; font-size: 14px; font-weight: 500; cursor: pointer;
  color: #5f6368; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
  margin-bottom: -1px; }
.tab-item:hover { color: #202124; }
.tab-item.active { color: #1a73e8; border-bottom-color: #1a73e8; }

/* ---- Voice mode ---- */
.mic-btn-idle    { background: #f8f9fa; color: #5f6368; }
.mic-btn-recording { background: #c5221f; color: white; animation: pulse-record 1s infinite; }
.mic-btn-processing { background: #e8f0fe; color: #1a73e8; }
@keyframes pulse-record { 0%,100% { box-shadow: 0 0 0 0 rgba(197,34,31,.4); } 50% { box-shadow: 0 0 0 8px rgba(197,34,31,0); } }

/* ---- Debug panel ---- */
.debug-panel { background: #1e2327; color: #d0d7de; border-radius: 8px; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.debug-panel summary { cursor: pointer; padding: 8px 12px; color: #58a6ff; font-weight: 600; user-select: none; }
.debug-panel pre { padding: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

/* ---- Misc ---- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.chip-blue   { background: #e8f0fe; color: #1a73e8; }
.chip-green  { background: #e6f4ea; color: #1e8e3e; }
.chip-orange { background: #fef7e0; color: #e37400; }
.chip-red    { background: #fce8e8; color: #c5221f; }
.chip-gray   { background: #f1f3f4; color: #5f6368; }

.divider { border: none; border-top: 1px solid #e8eaed; margin: 16px 0; }

.tooltip-wrap { position: relative; display: inline-flex; align-items: center; }
.tooltip-content {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #323232; color: white; font-size: 12px; padding: 6px 10px;
  border-radius: 6px; white-space: nowrap; max-width: 260px; white-space: normal;
  pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 100;
}
.tooltip-wrap:hover .tooltip-content { opacity: 1; }

/* ---- Loading spinner ---- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid #e8eaed;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Hide scrollbar when not needed */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
