/* Typing indicator */
.typing-indicator {
  display: inline-block;
  background: #f0f0f0;
  padding: .5rem 1rem;
  border-radius: 1rem;
  font-size: .85rem;
  color: #666;
}
.typing-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  margin: 0 2px;
  animation: typing-dot 1.5s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typing-dot {
  0%, 100% { transform: translateY(0); opacity: .4; }
  50% { transform: translateY(-5px); opacity: 1; }
}

/* Audio controls */
audio { width: 100%; margin-top: .5rem; }

/* Copy button */
.polly-copy-btn {
  background: none;
  border: none;
  padding: 0;
  margin-left: 5px;
  cursor: pointer;
  font-size: .8em;
  color: #007bff;
}
.polly-copy-btn:hover {
  color: #0056b3;
}

/* Chat body styling */
#chat-body {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 1rem;
  height: 360px;
  overflow-y: auto;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* Textbook image viewer */
.object-fit-contain {
  object-fit: contain;
}

/* Tiny TTS buttons */
.btn-tts {
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
  line-height: 1;
}

/* Space and alignment */
.tts-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* Push status to the far right */
.tts-status {
  margin-left: auto;
  font-size: 0.75rem;
  color: #6c757d;
}

/* Progress Check button styling */
.btn-success.d-inline-flex {
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}
.btn-success.d-inline-flex:hover {
  background-color: #198c4a;
  border-color: #198c4a;
}

/* Make every TTS word-span transparent until spoken */
#tts-content span {
  display: inline-block;
  background-color: transparent;
  transition: background-color .1s ease;
}

/* Highlight the current word */
#tts-content span.highlight {
  background-color: #ffeb3b !important;
  padding: 0 2px;
  border-radius: 2px;
}

/* Textbook page styling */
.page {
  margin-bottom: 2rem;
  border: 1px solid #eee;
  padding: 1rem;
  border-radius: 0.5rem;
  background: white;
}
.page img {
  max-width: 100%;
  height: auto;
  margin-bottom: 1rem;
  border: 1px solid #ddd;
}

/* Shared badge look */
.badge-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}
.badge-btn svg,
.badge-btn i {
  width: 32px;
  height: 32px;
  opacity: .85;
  transition: opacity .15s;
}
.badge-btn:hover svg,
.badge-btn:hover i {
  opacity: 1;
}

/* VIDEO HANDLING */
#video-block {
  margin-bottom: 1.5rem;
}

/* Rich content styling */
#rich-block {
  margin-bottom: 1rem;
  min-height: 220px; /* Added to maintain layout */
}

/* ======= UPDATED PAGINATION STYLES ======= */
.tts-nav-btns{
  display:flex;
  align-items:center;
  gap:.5rem .5rem;
  flex-wrap:wrap !important;
  overflow:visible !important;
  padding:.25rem 0;
}

@media (max-width: 992px){
  .tts-nav-btns{
    flex-basis:100%;
    order:10;
  }
}

.page-num-wrapper{
  display:inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}
.page-num-btn{
  width:36px; height:36px;
  border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  font-size:.9rem; font-weight:600; line-height:1;
  padding:0; margin:0;
}
#tts-prev-page, #tts-next-page{
  width:36px; height:36px;
  border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  font-size:.95rem; padding:0;
}

@media (max-width: 576px){
  .page-num-btn,
  #tts-prev-page, #tts-next-page{
    width:32px; height:32px; font-size:.8rem;
  }
}

.play-overlay{
  position:static;
  background:none;
  border:none;
  padding:0;
  margin:0;
  line-height:1;
  cursor:pointer;
}

.play-overlay i {
  font-size: 1.05rem;
  color: red !important;
  opacity: 1;
  transition: transform .15s, opacity .15s;
  vertical-align: middle;
}

.play-overlay:hover i {
  opacity: 0.85;
  transform: scale(1.06);
}

.page-num-btn.btn-primary{ box-shadow:0 2px 5px rgba(0,0,0,.1); }

/* Content formatting */
#tts-content {
  white-space: pre-wrap;
  font-family: inherit;
}

.textbook-page-content {
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.6;
}

/* Page TTS Toolbar */
#page-tts-toolbar {
  flex: 0 0 100%;
  margin-top: 0.5rem;
}
