/* --- GLOBAL VARIABLES & BASE RESET --- */
:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #6b7280;
  --border: #dfe5ef;
  --primary: #315efb;
  --primary2: #2148d8;
  --shadow: 0 12px 35px rgba(30, 45, 80, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- NAVIGATION & LAYOUT --- */
.topbar {
  height: 68px;
  background-color: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5%;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 800;
  font-size: 1.1875rem;
  /* 19px */
}

nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

nav a {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #4b5563;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.2s ease, color 0.2s ease;
}

nav a.active,
nav a:hover {
  background-color: #eef2ff;
  color: var(--primary);
}

.container {
  width: min(1100px, 92%);
  margin: 0 auto;
  padding: 35px 0 60px;
}

.hero {
  padding: 20px 0 28px;
}

.hero.small {
  padding-bottom: 20px;
}

.eyebrow {
  font-size: 0.75rem;
  /* 12px */
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--primary);
  margin-bottom: 7px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.875rem, 5vw, 3rem);
  line-height: 1.1;
  margin: 0 0 12px;
}

h2 {
  margin: 0;
  font-size: 1.375rem;
  /* 22px */
}

.hero p {
  max-width: 750px;
  color: var(--muted);
  font-size: 1rem;
}

/* --- CARDS & INPUTS --- */
.card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
  margin: 18px 0;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

.input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  font: inherit;
  background-color: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49, 94, 251, 0.15);
}

.compact {
  max-width: 330px;
}

/* --- EDITOR & MEDIA TOOLS --- */
.editor-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
  align-items: center;
}

.editor-heading span,
.muted {
  font-size: 0.8125rem;
  /* 13px */
  color: var(--muted);
}

#editor {
  height: 410px;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

#toolbar {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.ql-editor {
  font-size: 1rem;
}

.ql-editor img {
  max-width: 100%;
}

.media-tools {
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.media-tools p {
  margin: 4px 0 0;
}

.media-tools input {
  flex: 1;
  min-width: 210px;
}

/* --- BUTTONS & STATUS --- */
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

button {
  border: 0;
  border-radius: 11px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

button:active {
  transform: translateY(1px);
}

.primary {
  background-color: var(--primary);
  color: #ffffff;
}

.primary:hover {
  background-color: var(--primary2);
}

.secondary {
  background-color: #eef2f7;
  color: #263247;
}

.secondary:hover {
  background-color: #e4e9f2;
}

.status {
  margin-top: 12px;
  min-height: 20px;
  color: #2563eb;
}

.status.error {
  color: #dc2626;
}

.status.success {
  color: #15803d;
}

/* --- QUESTION LIST & SEARCH --- */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 14px;
}

.question-list {
  display: grid;
  gap: 8px;
}

.question-item {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.question-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-actions {
  display: flex;
  gap: 6px;
}

.question-actions button {
  padding: 7px 10px;
  font-size: 0.8125rem;
}

.search-box {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  align-items: stretch;
}

.search-box textarea {
  resize: vertical;
  min-height: 65px;
}

.search-box button {
  min-width: 120px;
}

.suggestions {
  position: relative;
  margin-top: 5px;
  z-index: 5;
}

.suggestion {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-top: 0;
  padding: 12px 14px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.suggestion:hover {
  background-color: #f8faff;
}

.hidden {
  display: none !important;
}

/* --- SEARCH RESULTS & RICH CONTENT --- */
.answer-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 6px 9px;
  border-radius: 999px;
  background-color: #e9edff;
  color: var(--primary);
}

.ai-answer {
  margin-top: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.result-card {
  border-top: 1px solid var(--border);
  padding: 17px 0;
}

.result-card:first-child {
  border-top: 0;
}

.result-q {
  font-weight: 800;
  font-size: 1.0625rem;
}

.score {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.answer-content {
  margin-top: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.answer-content img,
.answer-content video {
  max-width: 100%;
  height: auto;
}

.answer-content iframe {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

.answer-content audio {
  width: min(100%, 500px);
}

.answer-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
}

.answer-content th,
.answer-content td {
  border: 1px solid #cbd5e1;
  padding: 8px;
  text-align: left;
}

.answer-content a {
  color: #2457df;
}

.empty {
  padding: 25px;
  text-align: center;
  color: var(--muted);
}

#editor .ql-editor img,
.answer-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 10px 0;
}

.selected-answer {
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 20px;
}

.selected-answer .result-q {
  font-size: 1.25rem;
}

/* --- FEEDBACK NAV BUTTON --- */
.feedback-nav-btn {
  background-color: #2563eb;
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.8125rem;
  margin-right: 8px;
  transition: background-color 0.2s ease;
}

.feedback-nav-btn:hover {
  background-color: #1d4ed8;
}

/* --- FEEDBACK MODAL POPUP WINDOW --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  background-color: var(--card);
  width: min(580px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.modal-close {
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  background: none;
  border: none;
  padding: 0;
}

.modal-close:hover {
  color: var(--text);
}

.form-group {
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* --- RESPONSIVE BREAKPOINTS --- */
@media (max-width: 700px) {
  .topbar {
    padding: 10px 4%;
    height: auto;
    min-height: 62px;
    gap: 10px;
    flex-wrap: wrap;
  }

  nav {
    width: 100%;
    flex-wrap: wrap;
  }

  nav a,
  .feedback-nav-btn {
    flex: 1;
    text-align: center;
  }

  .container {
    width: 94%;
    padding-top: 22px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
  }

  .search-box {
    flex-direction: column;
  }

  .search-box button {
    width: 100%;
  }

  .editor-heading,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .compact {
    max-width: none;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }
}