* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Tajawal", sans-serif;
}

html,
body {
  height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

header,
.breadcrumb {
  border-bottom: 1px solid #e5e7eb;
}

footer img {
  display: block;
}

.breadcrumb {
  padding: 20px 24px;
  font-weight: 500;
  font-size: 14px;
  line-height: 24px;
  color: #c0c0c0;
}

.breadcrumb span {
  color: #008556;
}

.content-wrapper {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 200px);
}

.content-wrapper.quiz-active {
  display: grid;
  grid-template-columns: 300px 1fr 1.4fr;
  gap: 24px;
}

.content-wrapper.quiz-active .sidebar {
  grid-column: 1 / 2;
}

.content-wrapper.quiz-active .main-content {
  grid-column: 2 / 3;
}

#quizSection {
  grid-column: 3 / 4;
}

/* Summary Sidebar Active State */
.content-wrapper.summary-active {
  display: grid;
  grid-template-columns: 300px 1fr 400px;
  gap: 24px;
}

.content-wrapper.summary-active .sidebar {
  grid-column: 1 / 2;
}

.content-wrapper.summary-active .main-content {
  grid-column: 2 / 3;
}

.content-wrapper.summary-active #summarySidebar {
  grid-column: 3 / 4;
}

@media (max-width: 992px) {
  .content-wrapper.quiz-active {
    grid-template-columns: 1fr;
  }

  .content-wrapper.quiz-active #quizSection,
  .content-wrapper.quiz-active .main-content,
  .content-wrapper.quiz-active .sidebar {
    grid-column: 1 / -1 !important;
  }

  .content-wrapper.summary-active {
    grid-template-columns: 1fr;
  }

  .content-wrapper.summary-active #summarySidebar,
  .content-wrapper.summary-active .main-content,
  .content-wrapper.summary-active .sidebar {
    grid-column: 1 / -1 !important;
  }
}

.sidebar {
  border-left: 1px solid #ededed;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-header {
  border-bottom: 1px solid #ededed;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 24px;
}

.sidebar-icon {
  font-size: 24px;
}

.sidebar-title {
  font-weight: 700;
  font-size: 16px;
  color: #000000;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.file-item:hover {
  background: #f9fafb;
  border-color: #008556;
}

.file-icon {
  width: 24px;
  height: 24px;
}

.file-name {
  font-weight: 500;
  font-size: 14px;
  color: #1a1a1a;
}

.main-content {
  padding: 30px;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
}

.form-container {
  display: flex;
  justify-content: end;
}

.chat-input-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fbfbfb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 16px;
  width: 100%;
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: "Tajawal", sans-serif;
  color: #3f5c52;
  background: transparent;
}

.chat-input::placeholder {
  color: #9ca3af;
}

.chat-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  margin-top: 24px;
}

.chat-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  max-width: 70%;
  font-size: 14px;
  line-height: 1.7;
  padding: 12px;
  border-radius: 8px;
  width: fit-content;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-message.user {
  align-self: flex-start;
  background: #f8f8f8;
  border: 1px solid #ebebeb;
  font-size: 14px;
  font-weight: 500;
  width: 40%;
}

.chat-message.bot {
  align-self: flex-end;
  width: 50%;
  font-size: 14px;
  font-weight: 500;
}

.send-btn {
  width: 40px;
  height: 40px;
  background: #3f5c52;
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.send-btn img {
  width: 20px;
  height: 20px;
}

.send-btn:hover {
  background: #333;
}

.form-title,
.info-text {
  font-size: 14px;
  color: #333333;
  font-weight: 500;
  width: 500px;
}

.info-section {
  padding-bottom: 20px;
}

.warning-text {
  font-size: 13px;
  color: #92400e;
  line-height: 1.6;
}

.quiz-box {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #D5E8E1;
  background: #F3FAF8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 50%;
  align-self: end;
}

.quiz-title, .summary-title {
  font-size: 14px;
  font-weight: 700;
  color: #333333;
}

.quiz-start-btn, .summary-open-btn {
  padding: 6px 16px;
  border-radius: 6px;
  border: none;
  background: #008556;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.quiz-start-btn:hover, .summary-open-btn:hover {
  background: #006c45;
}

@media (max-width: 1200px) {
  .main-content {
    max-width: 100%;
    padding: 24px;
  }

  .quiz-box {
    width: 60%;
  }
}

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1.2fr);
  gap: 24px;
}

.quiz-left {
  background: #ffffff;
  border-right: 1px solid #ededed;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quiz-right {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.quiz-main-title {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.quiz-download-btn,
.quiz-close-btn {
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.quiz-close-btn {
  font-weight: 700;
}

.quiz-questions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-question-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 24px;
  background: #ffffff;
}

.quiz-question-title {
  font-size: 14px;
  font-weight: 500;
  color: #161616;
  margin-bottom: 4px;
}

.quiz-question-text {
  font-size: 14px;
  font-weight: 500;
  color: #161616;
  margin-bottom: 8px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}

.quiz-option input[type="radio"] {
  accent-color: #008556;
}

.quiz-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-start;
}

.quiz-submit-btn {
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  background: #008556;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.quiz-submit-btn:hover {
  background: #006c45;
}

.quiz-info-title {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}

.quiz-info-text {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.7;
}

@media (max-width: 992px) {
  .quiz-layout {
    grid-template-columns: 1fr;
  }
}

.quiz-option.is-correct {
  background: #e8f6ed;
  border: 1px solid #5bb98c;
  border-radius: 6px;
}

.quiz-option.is-user-answer.is-incorrect {
  background: #fdeaea;
  border: 1px solid #e57373;
  border-radius: 6px;
}

.quiz-option.is-user-answer {
  border-radius: 6px;
}

.quiz-option input:disabled {
  cursor: not-allowed;
}

.quiz-feedback {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.7;
}

.quiz-feedback-correct {
  background: #e8f6ed;
  border: 1px solid #5bb98c;
  color: #145a32;
}

.quiz-feedback-incorrect {
  background: #fdeaea;
  border: 1px solid #e57373;
  color: #7b1f1f;
}

.quiz-feedback-status {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 15px;
}

.quiz-feedback-explanation {
  margin-top: 6px;
  font-size: 13px;
  color: #333;
  line-height: 1.8;
}

.quiz-option {
  padding: 8px 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  transition: 0.2s;
}

.quiz-option span {
  margin-top: -2px;
}

.quiz-score-box {
  width: 100%;
  padding: 24px 16px;
  border-radius: 8px;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.quiz-score-title {
  font-size: 16px;
  font-weight: 700;
  color: #333333;
}

.quiz-score-value {
  font-size: 16px;
  font-weight: 700;
  color: #00794e;
}

/* Summary Sidebar Styles */
.summary-sidebar {
  background: #ffffff;
  border-right: 1px solid #ededed;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 200px);
}

.summary-sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid #ededed;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.summary-close-btn {
  align-self: flex-start;
  background: transparent;
  border: none;
  font-size: 20px;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s;
}

.summary-close-btn:hover {
  color: #000;
}

.summary-sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  line-height: 1.5;
}

.summary-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.summary-download-btn:hover {
  background: #f9fafb;
  border-color: #008556;
  color: #008556;
}

.summary-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  max-height: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.summary-loading {
  text-align: center;
  color: #6b7280;
  font-size: 14px;
  padding: 40px 20px;
}

/* Summary Content Wrapper - Override inline styles */
.summary-content > div {
  background: transparent !important;
  padding: 0 !important;
}

.summary-content p {
  font-size: 14px;
  line-height: 1.8;
  color: #374151;
  margin-bottom: 16px;
  word-wrap: break-word;
}

.summary-content h1,
.summary-content h2,
.summary-content h3 {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  margin-top: 24px;
  margin-bottom: 12px;
  word-wrap: break-word;
}

.summary-content h2 {
  font-size: 18px;
  color: #007b83;
}

.summary-content h3 {
  font-size: 16px;
  color: #005960;
}

.summary-content h1:first-child,
.summary-content h2:first-child,
.summary-content h3:first-child {
  margin-top: 0;
}

.summary-content ul,
.summary-content ol {
  padding-right: 24px;
  margin-bottom: 16px;
  list-style-position: outside;
}

.summary-content ul {
  list-style-type: disc;
}

.summary-content li {
  font-size: 14px;
  line-height: 1.8;
  color: #374151;
  margin-bottom: 8px;
  word-wrap: break-word;
}

.summary-content strong,
.summary-content b {
  font-weight: 700;
  color: #111827;
}

.summary-content em,
.summary-content i {
  font-style: italic;
}

.summary-content code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.summary-content blockquote {
  border-right: 4px solid #008556;
  padding-right: 16px;
  margin: 16px 0;
  color: #4b5563;
  font-style: italic;
}

@media (max-width: 992px) {
  .content-wrapper {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .sidebar {
    border-left: none;
    border-bottom: 1px solid #ededed;
    flex-direction: column;
  }

  .file-list {
    padding: 16px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .file-item {
    flex: 1 1 calc(50% - 8px);
  }

  .main-content {
    padding: 20px;
  }

  .chat-messages {
    max-height: 55vh;
  }

  .chat-message.user,
  .chat-message.bot {
    width: auto;
    max-width: 100%;
  }

  .quiz-box {
    width: 70%;
  }

  .summary-sidebar {
    max-height: 70vh;
  }
}

@media (max-width: 768px) {
  .breadcrumb {
    padding: 12px 16px;
    font-size: 12px;
  }

  .main-content {
    padding: 16px;
  }

  .sidebar-header {
    padding: 8px 16px;
  }

  .file-list {
    padding: 12px;
  }

  .file-item {
    flex: 1 1 100%;
  }

  .chat-messages {
    max-height: 50vh;
  }

  .chat-input-row {
    align-items: stretch;
  }

  .send-btn {
    width: 38px;
    height: 38px;
  }

  .quiz-box {
    width: 100%;
    align-self: stretch;
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-sidebar-header {
    padding: 16px;
  }

  .summary-content {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  .breadcrumb {
    padding: 10px 12px;
  }

  .main-content {
    padding: 12px;
  }

  .chat-input-container {
    padding: 8px 10px;
  }

  .chat-message {
    max-width: 100%;
  }

  .form-title,
  .info-text {
    width: 100%;
  }
}