/* Import Inter font with Gujarati support */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* CSS Custom Properties - Font System */
:root {
  /* Font Weights */
  --font-light: 300;
  --font-regular: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Font Styles */
  --font-normal: normal;
  --font-italic: italic;

  /* Font Families */
  --font-primary: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --font-mono: "Roboto Mono", monospace;
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-mono);
  line-height: 1.6;
  color: #2d3748;
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  min-height: 100vh;
  padding: 0.5rem;
  overflow: hidden;
}

/* Main container - centered and fixed width */
.book-container {
  max-width: 900px;
  width: 100%;
  height: 100vh;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Book header - Hidden */
.book-header {
  display: none;
}

/* Content area */
.book-content {
  flex: 1;
  padding: 1rem 1rem;
  background: white;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Page container */
.page {
  flex: 1;
  display: none;
  overflow: hidden;
}

.page.active {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}

/* Paragraph styling */
.page p {
  font-size: 1.15rem;
  font-weight: var(--font-semibold);
  line-height: 1.8;
  margin-bottom: 0.5rem;
  text-align: justify;
  padding: 1rem 1.2rem;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

.page p:hover {
  background: #f1f5f9;
}

/* Sanskrit verses styling */
.page p:has(br) {
  background: linear-gradient(135deg, #fef7f0 0%, #fdf2e9 100%);
  border-left-color: #f6ad55;
  font-style: var(--font-italic);
}

/* Navigation area */
.book-navigation {
  background: #f8fafc;
  padding: 1rem 2rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

/* Page info */
.page-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 1rem;
  color: #64748b;
}

.page-indicator {
  font-weight: var(--font-semibold);
  color: #475569;
}

.total-pages {
  background: #e2e8f0;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: var(--font-medium);
}

/* Navigation buttons */
.nav-buttons {
  display: flex;
  gap: 1rem;
}

.nav-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 0.8rem 1.6rem;
  border-radius: 25px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: var(--font-semibold);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn:hover {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.nav-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

/* Progress bar */
.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 0 2px 2px 0;
}

/* Keyboard hint */
.keyboard-hint {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: var(--font-medium);
  backdrop-filter: blur(10px);
  opacity: 0;
}

.keyboard-hint.show {
  opacity: 1;
}

.keyboard-hint kbd {
  background: #374151;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin: 0 0.25rem;
  font-family: var(--font-mono);
}

/* Responsive design */
@media (max-width: 768px) {
  body {
    padding: 0.25rem;
  }

  .book-container {
    margin: 0;
    border-radius: 8px;
    max-width: 100%;
  }


  .book-content {
    padding: 1rem;
  }

  .page p {
    font-size: 1.05rem;
    font-weight: var(--font-semibold);
    padding: 0.8rem;
    margin-bottom: 0.4rem;
  }

  .book-navigation {
    padding: 0.75rem 1rem;
    flex-direction: column;
    gap: 0.75rem;
  }

  .keyboard-hint {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .book-content {
    padding: 0.75rem;
  }

  .page p {
    font-size: 0.95rem;
    font-weight: var(--font-semibold);
    line-height: 1.7;
    padding: 0.7rem;
    margin-bottom: 0.3rem;
  }

  .nav-btn {
    padding: 0.7rem 1.3rem;
    font-size: 0.9rem;
    font-weight: var(--font-semibold);
  }
}

/* Focus styles for accessibility */
.nav-btn:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .book-navigation,
  .keyboard-hint {
    display: none;
  }

  .book-container {
    box-shadow: none;
    max-width: 100%;
  }

  .page {
    display: block !important;
    page-break-after: always;
  }
}

/* ==========================================
   READING TIMER FEATURE STYLES
   ========================================== */

/* Finish Reading Button */
.finish-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.finish-btn:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

/* Elapsed Time Indicator */
.elapsed-indicator {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.elapsed-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.elapsed-icon:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.elapsed-tooltip {
  position: absolute;
  right: 50px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateX(10px);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.elapsed-tooltip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: rgba(0, 0, 0, 0.9);
}

.elapsed-indicator:hover .elapsed-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.elapsed-label {
  color: #9ca3af;
  font-weight: var(--font-medium);
}

.elapsed-time {
  color: #10b981;
  font-weight: var(--font-bold);
  font-family: var(--font-mono);
}

/* Results Modal */
.results-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.results-modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
}

.results-modal.show .modal-content {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #9ca3af;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #4b5563;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: var(--font-bold);
  color: #1f2937;
  margin-bottom: 1.5rem;
  text-align: center;
}

/* Stats Container */
.stats-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-item {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 1rem;
  border-radius: 12px;
  text-align: center;
  border: 1px solid #e2e8f0;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: #64748b;
  margin-bottom: 0.3rem;
  font-weight: var(--font-medium);
}

.stat-value {
  display: block;
  font-size: 1.3rem;
  font-weight: var(--font-bold);
  color: #667eea;
  font-family: var(--font-mono);
}

/* Table Container */
.table-container {
  flex: 1;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-table thead {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 1;
}

.results-table th {
  padding: 0.8rem 1rem;
  text-align: left;
  color: white;
  font-weight: var(--font-semibold);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.results-table th:hover {
  background: rgba(255, 255, 255, 0.1);
}

.results-table th.sortable {
  cursor: pointer;
  position: relative;
}

.results-table th.sortable .sort-icon {
  margin-left: 0.5rem;
}

.results-table th.active {
  background: rgba(255, 255, 255, 0.15);
}

.sort-icon {
  font-size: 0.8rem;
  opacity: 0.7;
}

.results-table th.active .sort-icon {
  opacity: 1;
}

.results-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #4b5563;
}

.results-table tbody tr:hover {
  background: #f8fafc;
}

.results-table tbody tr:last-child td {
  border-bottom: none;
}

.results-table td:first-child {
  font-weight: var(--font-semibold);
  color: #374151;
}

.results-table td:last-child {
  font-family: var(--font-mono);
  color: #667eea;
}

/* Responsive adjustments for timer features */
@media (max-width: 768px) {
  .elapsed-indicator {
    bottom: 1rem;
    right: 1rem;
  }

  .elapsed-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .elapsed-tooltip {
    right: 45px;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
  }

  .modal-content {
    padding: 1.5rem;
    max-height: 85vh;
  }

  .modal-title {
    font-size: 1.25rem;
  }

  .stats-container {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  .elapsed-indicator {
    bottom: 0.75rem;
    right: 0.75rem;
  }

  .modal-content {
    padding: 1rem;
    border-radius: 12px;
  }

  .results-table th,
  .results-table td {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }
}

/* Hide elapsed indicator during print */
@media print {
  .elapsed-indicator,
  .results-modal {
    display: none;
  }
}