/* book-reader.css */
body {
  display: flex;
  flex-direction: row;
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #fcfcfc;
  padding: 0;
  max-width: 100%;
}

#br-main-content {
  flex: 6;
  padding: 40px 60px;
  background-color: #ffffff;
  overflow-y: auto;
  scroll-behavior: smooth;
  line-height: 1.6;
}

#br-right-panel {
  flex: 4;
  background-color: #f4f5f7;
  border-left: 1px solid #e1e4e8;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  z-index: 999;
}

/* Flex layout inside Right Panel */
#br-eng-section {
  flex: 6;
  padding: 20px;
  overflow-y: auto;
  border-bottom: 1px solid #e1e4e8;
}

#br-comments-section {
  flex: 4;
  padding: 15px 12px; /* Decreased horizontal padding from 20px for more workspace */
  background-color: #ffffff;
  border-top: 1px solid #e1e4e8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.br-comments-header {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #111827;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #0366d6;
  padding-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#br-comments-list-wrapper {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 4px;
}

#br-comments-list {
  display: flex;
  flex-direction: column;
}

.br-comments-placeholder, .br-comments-empty {
  font-style: italic;
  color: #64748b;
  text-align: center;
  padding: 30px 10px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.br-comment-bubble {
  position: relative;
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid #e2e8f0;
  max-width: 100%;
  word-wrap: break-word;
  word-break: break-word;
}

.br-comment-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #64748b;
  margin-bottom: 4px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 3px;
}

.br-comment-user {
  font-weight: 700;
  color: #334155;
}

.br-comment-time {
  color: #94a3b8;
}

.br-comment-text {
  font-size: 0.88rem;
  color: #1e293b;
  line-height: 1.45;
  padding-right: 12px;
}

.br-comment-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.15s, transform 0.1s;
}

.br-comment-bubble:hover .br-comment-delete-btn {
  color: #94a3b8;
}

.br-comment-delete-btn:hover {
  color: #ef4444 !important;
  transform: scale(1.15);
}

#br-comments-input-area {
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  background-color: #ffffff;
  width: 100%;
}

#br-comment-username {
  width: 50px;
  height: 38px;
  padding: 0 4px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
  flex-shrink: 0;
  text-align: center;
  box-sizing: border-box;
}

#br-comment-text {
  flex-grow: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

#br-comment-username:focus, #br-comment-text:focus {
  border-color: #0366d6;
  box-shadow: 0 0 0 2px rgba(3, 102, 214, 0.15);
}

#br-comment-submit-btn {
  background: #0366d6;
  color: white;
  border: none;
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  transition: background 0.15s;
  font-family: inherit;
  flex-shrink: 0;
  white-space: nowrap;
  box-sizing: border-box;
}

#br-comment-submit-btn:hover {
  background: #0256b4;
}

#br-comment-submit-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

/* Hover, pinned, and commented states for main content paragraph blocks */
.br-comments-hover {
  background-color: #ecfccb !important;
  border-radius: 4px;
  transition: background-color 0.15s;
}

.br-comments-pinned {
  background-color: #fef08a !important;
  border-radius: 4px;
  transition: background-color 0.15s;
}

.br-has-comments {
  background-color: #f7fee7 !important;
  border-radius: 4px;
}

/* Mega Menu Table of Contents Modal */
#br-toc-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
  display: block;
}

#br-toc-modal.br-modal-show {
  opacity: 1;
  pointer-events: auto;
}

.br-toc-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}

.br-toc-modal-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -45%);
  width: 90%;
  max-width: 1000px;
  max-height: 85vh;
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  transition: transform 0.2s ease-in-out;
}

#br-toc-modal.br-modal-show .br-toc-modal-container {
  transform: translate(-50%, -50%);
}

.br-toc-modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8fafc;
}

.br-toc-modal-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.br-toc-modal-close {
  background: none;
  border: none;
  font-size: 2.2rem;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.br-toc-modal-close:hover {
  color: #0f172a;
}

.br-toc-modal-body {
  padding: 28px;
  overflow-y: auto;
  flex: 1;
}

.br-mega-toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 28px;
}

.br-mega-toc-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.br-mega-toc-group-header {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0366d6;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.br-mega-toc-group-pages {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.br-mega-toc-page-item {
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
  user-select: none;
  border: 1px solid transparent;
}

.br-mega-toc-parent-item {
  font-weight: 700;
  color: #1e293b;
  font-size: 1rem;
  margin-top: 4px;
}

.br-mega-toc-children-container {
  margin-left: 14px;
  border-left: 1px dashed #cbd5e1;
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.br-mega-toc-child-item {
  font-weight: 500;
  color: #475569;
  font-size: 0.92rem;
}

.br-mega-toc-page-item:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.br-mega-toc-page-item.br-mega-toc-active {
  background-color: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
  border: 1px solid #bfdbfe;
}

/* Key terms inline layout with colon separator */
.os-glossary-container dl {
  margin-bottom: 16px;
  line-height: 1.6;
}

.os-glossary-container dt {
  display: inline;
  font-weight: 700;
  color: #0f172a;
}

.os-glossary-container dt::after {
  content: " : ";
  font-weight: 500;
  color: #64748b;
}

.os-glossary-container dd {
  display: inline;
  margin: 0;
  color: #374151;
}

/* Floating Tooltip Styles */
#br-term-tooltip {
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  width: 280px;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: none;
  transition: opacity 0.2s ease;
  line-height: 1.5;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.br-tooltip-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: #60a5fa;
  text-transform: capitalize;
}

.br-tooltip-vi {
  font-weight: 600;
  margin-bottom: 8px;
  color: #f1f5f9;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}

.br-tooltip-desc {
  color: #cbd5e1;
  margin-bottom: 4px;
}

.br-tooltip-desc strong {
  color: #94a3b8;
}

/* UI Elements */
.br-title {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 15px;
  color: #333;
  border-bottom: 2px solid #0366d6;
  padding-bottom: 10px;
}

#br-eng-content {
  font-size: 1rem;
  color: #444;
  line-height: 1.6;
}

.vn.visible, .eng.hidden {
  transition: background-color 0.2s;
}

/* Swapping Logic */
body.lang-swap #br-main-content .eng.hidden {
  display: block !important;
  color: #000;
}
body.lang-swap #br-main-content .vn.visible {
  display: none !important;
}

/* Hover effects based on mode */
body:not(.lang-swap) #br-main-content .vn.visible:hover {
  background-color: #f0f8ff;
  border-radius: 3px;
}
body.lang-swap #br-main-content .eng.hidden:hover {
  background-color: #f0f8ff;
  border-radius: 3px;
}

/* Make sure right panel always shows its content regardless of classes */
#br-eng-content .eng.hidden,
#br-eng-content .vn.visible {
  display: block !important;
  color: #444;
  background-color: transparent !important;
}

/* Glossary Term Panel */
.br-term-card h3 {
  margin: 0 0 10px 0;
  font-size: 1.1rem;
  color: #d73a49;
  text-transform: capitalize;
}

.br-term-card .br-vi {
  font-weight: bold;
  color: #333;
  margin-bottom: 5px;
}

.br-term-card .br-desc-en, .br-term-card .br-desc-vi {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 8px;
}

/* Term highlights */
.br-highlight-term {
  color: #d73a49 !important;
  font-weight: bold;
  cursor: pointer;
  border-bottom: 1px dashed #d73a49;
  transition: background-color 0.2s;
}

.br-highlight-term:hover {
  background-color: #ffebed;
  border-radius: 2px;
}

/* Clean up original document styles if they interfere */
body:not(.lang-swap) > .eng.hidden, body:not(.lang-swap) #br-main-content .eng.hidden {
  display: none !important;
}
