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

/* --- CSS Variables for Light and Dark Themes --- */
:root {
  --bg-color: #ffffff;
  --text-color: #333333;
  --header-bg: #2c3e50;
  --header-text: #ffffff;
  --primary-color: #3498db;
  --primary-color-dark: #2980b9;
  --secondary-bg: #f9f9f9;
  --border-color: #ddd;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --card-bg: #f9f9f9;
  --input-bg: #ffffff;
  --input-border: #ddd;
  --card-white: hsl(0, 0%, 100%);
  --card-black: hsl(240, 15%, 9%);
  --card-paragraph: hsl(0, 0%, 83%);
  --card-line: hsl(240, 9%, 17%);
  --card-primary: hsl(266, 92%, 58%);
}

/* --- Dark Mode Variables --- */
[data-theme="dark"] {
  --bg-color: #161a20;
  --text-color: #ffffff;
  --text-color-muted: #a0a0a0;
  --border-color: #2a2f38;
  --card-bg: #1e222a;
  --header-bg: #1e222a;
  --header-text: #ffffff;
  --primary-color: #4e7bf7;
  --primary-color-dark: #8451f3;
  --link-color: #4e7bf7;
  --link-hover-color: #8451f3;
  --button-text: #ffffff;
}

/* --- Dark Mode Toggle Button --- */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 4px 10px var(--shadow-color);
  color: var(--text-color);
  font-size: 1.2rem;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

.theme-toggle:active {
  transform: scale(0.95);
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: none;
}

[data-theme="light"] .theme-toggle .moon-icon,
:root .theme-toggle .moon-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: block;
}

[data-theme="light"] .theme-toggle .sun-icon,
:root .theme-toggle .sun-icon {
  display: block;
}

@media (max-width: 768px) {
  .theme-toggle {
    top: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
  }
}

body {
  font-family: Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

/* Header styles */
header {
  background-color: var(--header-bg);
  padding: 20px 0;
  color: var(--header-text);
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo a {
  color: var(--header-text);
  font-size: 24px;
  font-weight: bold;
  text-decoration: none;
}

nav ul {
  display: flex;
  list-style: none;
}

nav ul li {
  margin-left: 20px;
}

nav ul li a {
  color: var(--header-text);
  text-decoration: none;
  transition: color 0.3s;
}

nav ul li a:hover,
nav ul li a.active {
  color: var(--primary-color);
}

/* Main content styles */
main {
  padding: 40px 0;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 20px;
  color: var(--text-color);
}

h2 {
  font-size: 1.8rem;
  margin-bottom: 15px;
  color: var(--text-color);
}

p {
  margin-bottom: 20px;
  color: var(--text-color);
}

.btn {
  display: inline-block;
  background-color: var(--primary-color);
  color: white;
  padding: 10px 20px;
  text-decoration: none;
  border-radius: 5px;
  transition: background-color 0.3s;
  border: none;
  cursor: pointer;
}

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

/* Hero section */
.hero {
  text-align: center;
  padding: 60px 0;
  background-color: var(--secondary-bg);
  margin-bottom: 40px;
}

.hero h1 {
  font-size: 3rem;
}

.hero p {
  font-size: 1.2rem;
  max-width: 600px;
  margin: 0 auto 30px;
}

/* Features section */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  margin-bottom: 40px;
}

.feature {
  background-color: var(--card-bg);
  padding: 30px;
  border-radius: 5px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: background-color 0.3s ease;
}

/* About page */
.about-content {
  margin: 40px 0;
}

/* Contact page */
.contact-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
  margin: 40px 0;
}

.contact-item {
  background-color: var(--card-bg);
  padding: 20px;
  border-radius: 5px;
  border: 1px solid var(--border-color);
}

.contact-form {
  max-width: 600px;
  margin: 40px 0;
}

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

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: var(--text-color);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--input-border);
  border-radius: 5px;
  background-color: var(--input-bg);
  color: var(--text-color);
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Footer styles */
footer {
  background-color: var(--header-bg);
  color: var(--header-text);
  padding: 20px 0;
  text-align: center;
}

/* Services page */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 30px;
  margin: 40px 0;
}

.service-card {
  background-color: var(--card-bg);
  border-radius: 5px;
  padding: 30px;
  text-align: center;
  transition: transform 0.3s, box-shadow 0.3s;
  border: 1px solid var(--border-color);
}

.service-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px var(--shadow-color);
}

.service-icon {
  margin-bottom: 20px;
}

.service-icon img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.cta-section {
  background-color: var(--card-bg);
  padding: 40px;
  text-align: center;
  border-radius: 5px;
  margin: 40px 0;
  border: 1px solid var(--border-color);
}

.cta-section h2 {
  margin-bottom: 10px;
}

.cta-section .btn {
  margin-top: 20px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  header .container {
    flex-direction: column;
  }

  nav ul {
    margin-top: 15px;
  }

  .hero h1 {
    font-size: 2.5rem;
  }
}

/* Flipbook Integration Styles */
.content-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0;
}

.tab-button {
  background: none;
  border: none;
  padding: 12px 20px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-color);
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
}

.tab-button:hover {
  color: var(--primary-color);
  background-color: var(--secondary-bg);
}

.tab-button.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background-color: rgba(77, 158, 255, 0.1);
}

.tab-button i {
  margin-right: 8px;
}

.flipbook-container {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 6px var(--shadow-color);
  height: 100vh;
  max-height: 800px;
  border: 1px solid var(--border-color);
}

.flipbook-header {
  margin-bottom: 20px;
  text-align: center;
}

.flipbook-header h2 {
  color: var(--text-color);
  margin-bottom: 10px;
}

.flipbook-header p {
  color: var(--text-color);
  opacity: 0.8;
  margin-bottom: 0;
}

.flipbook-viewer {
  width: 100%;
  height: calc(100vh - 200px);
  max-height: 700px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.flipbook-viewer iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.flipbook-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 400px;
  background: var(--secondary-bg);
  border-radius: 8px;
  color: var(--text-color);
}

.flipbook-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.flipbook-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
}

.flipbook-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s ease;
}

.flipbook-btn:hover {
  background: var(--primary-color-dark);
}

.flipbook-btn.secondary {
  background: #6c757d;
}

.flipbook-btn.secondary:hover {
  background: #545b62;
}

/* Mobile responsive styles for flipbook */
@media (max-width: 768px) {
  .content-tabs {
    gap: 5px;
  }
  
  .tab-button {
    padding: 10px 15px;
    font-size: 14px;
  }
  
  .flipbook-container {
    padding: 15px;
    height: auto;
    max-height: none;
  }
  
  .flipbook-viewer {
    height: 400px;
    max-height: none;
  }
  
  .flipbook-header h2 {
    font-size: 1.5rem;
  }
  
  .flipbook-controls {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .flipbook-btn {
    padding: 6px 12px;
    font-size: 13px;
  }
}

/* Additional dark mode text overrides for static pages */
[data-theme="dark"] .feature h3 {
  color: var(--text-color);
}

[data-theme="dark"] .feature p {
  color: var(--text-color);
}

[data-theme="dark"] .contact-item h3 {
  color: var(--text-color);
}

[data-theme="dark"] .contact-item p {
  color: var(--text-color);
}

[data-theme="dark"] .service-card h3 {
  color: var(--text-color);
}

[data-theme="dark"] .service-card p {
  color: var(--text-color);
}

[data-theme="dark"] .cta-section h2 {
  color: var(--text-color);
}

[data-theme="dark"] .cta-section p {
  color: var(--text-color);
}

/* Button Styles */
.btn {
  color: var(--button-text);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-dark) 100%);
  color: var(--button-text);
}

.btn-primary:hover {
  opacity: 0.95;
}

/* Card Styles */
.card {
  background-color: var(--card-bg);
  border-color: var(--border-color);
}

.card-title {
  color: var(--text-color);
}

.card-text {
  color: var(--text-color-muted);
}

/* Navigation */
.nav-link {
  color: var(--text-color);
}

.nav-link:hover {
  color: var(--primary-color);
}

/* Search Box */
.search-box {
  background-color: var(--card-bg);
  border-color: var(--border-color);
  color: var(--text-color);
}

.search-box::placeholder {
  color: var(--text-color-muted);
}

/* Category Tags */
.category-tag {
  background-color: var(--primary-color);
  color: var(--button-text);
}

/* Modern Content Card */
.content-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  width: 100%;
  background-color: hsla(240, 15%, 9%, 1);
  background-image: 
    radial-gradient(at 88% 40%, hsla(240, 15%, 9%, 1) 0px, transparent 85%),
    radial-gradient(at 49% 30%, hsla(240, 15%, 9%, 1) 0px, transparent 85%),
    radial-gradient(at 14% 26%, hsla(240, 15%, 9%, 1) 0px, transparent 85%),
    radial-gradient(at 0% 64%, hsla(263, 93%, 56%, 1) 0px, transparent 85%),
    radial-gradient(at 41% 94%, hsla(284, 100%, 84%, 1) 0px, transparent 85%),
    radial-gradient(at 100% 99%, hsla(306, 100%, 57%, 1) 0px, transparent 85%);
  border-radius: 1rem;
  box-shadow: 0px -16px 24px 0px rgba(255, 255, 255, 0.25) inset;
  transition: transform 0.3s ease;
}

.content-card .card__border {
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  z-index: -10;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  background-image: linear-gradient(0deg, hsl(0, 0%, 100%) -50%, hsl(0, 0%, 40%) 100%);
  border-radius: 1rem;
}

.content-card .card__border::before {
  content: "";
  pointer-events: none;
  position: fixed;
  z-index: 200;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200%;
  height: 10rem;
  background-image: linear-gradient(
    0deg,
    hsla(0, 0%, 100%, 0) 0%,
    hsl(277, 95%, 60%) 40%,
    hsl(277, 95%, 60%) 60%,
    hsla(0, 0%, 40%, 0) 100%
  );
  animation: rotate 8s linear infinite;
}

.content-card:hover {
  transform: translateY(-5px);
}

.content-thumbnail {
  width: 100%;
  height: 200px;
  border-radius: 0.75rem;
  overflow: hidden;
}

.content-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.content-info {
  padding: 0.5rem;
}

.content-title {
  font-size: 1.1rem;
  color: var(--card-white);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.content-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.content-category {
  background: var(--card-primary);
  color: var(--card-white);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  box-shadow: inset 0 -2px 25px -4px var(--card-white);
}

.content-date {
  font-size: 0.75rem;
  color: var(--card-paragraph);
}

.content-description {
  font-size: 0.875rem;
  color: var(--card-paragraph);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.content-button {
  cursor: pointer;
  padding: 0.5rem;
  width: 100%;
  background-image: linear-gradient(0deg, rgba(94, 58, 238, 1) 0%, rgba(197, 107, 240, 1) 100%);
  font-size: 0.875rem;
  color: var(--card-white);
  border: 0;
  border-radius: 9999px;
  box-shadow: inset 0 -2px 25px -4px var(--card-white);
  transition: transform 0.2s ease;
  text-decoration: none;
  text-align: center;
  display: inline-block;
}

.content-button:hover {
  transform: scale(1.02);
  color: var(--card-white);
  text-decoration: none;
}

.content-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--card-line);
  margin-top: auto;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--card-paragraph);
}

.stat-item i {
  color: var(--card-primary);
}

@keyframes rotate {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Grid Layout */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  padding: 2rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .content-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  
  .content-card {
    width: 100%;
  }
}

/* Related Videos Styling */
.modern-chapter-item {
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.modern-chapter-item:hover {
    transform: translateX(5px);
}

.modern-chapter-link {
    display: flex;
    text-decoration: none;
    color: inherit;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 8px;
}

.modern-chapter-thumbnail {
    width: 120px;
    height: 68px;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 12px;
    flex-shrink: 0;
}

.modern-chapter-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modern-thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.1);
}

.modern-thumbnail-placeholder i {
    font-size: 24px;
    opacity: 0.5;
}

.modern-chapter-info {
    flex: 1;
    min-width: 0;
}

.modern-chapter-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.modern-chapter-meta {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.modern-chapter-views {
    display: flex;
    align-items: center;
    margin-right: 12px;
}

.modern-chapter-views i {
    margin-right: 4px;
    font-size: 10px;
}

.modern-chapter-duration {
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    font-size: 11px;
}

/* Empty State Styling */
.modern-empty-state {
    text-align: center;
    padding: 30px 20px;
    color: rgba(255, 255, 255, 0.6);
}

.modern-empty-state i {
    font-size: 24px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.modern-empty-state p {
    font-size: 14px;
    line-height: 1.4;
}

/* Section Header Styling */
.modern-section-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modern-section-header i {
    margin-right: 10px;
    font-size: 18px;
}

.modern-section-header h3 {
    flex: 1;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.modern-section-count {
    background: #007bff;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* Modern Video Player Layout */
.modern-video-player-page {
  display: grid;
  grid-template-columns: 2fr 1fr; /* Video takes 2/3, sidebar takes 1/3 */
  gap: 2rem;
  padding: 2rem;
  max-width: 1800px;
  margin: 0 auto;
}

.modern-video-main {
  width: 100%;
}

.modern-video-player-container {
  width: 100%;
  background: var(--card-bg);
  border-radius: 1rem;
  overflow: hidden;
  margin-bottom: 2rem;
}

.modern-video-player {
  width: 100%;
  aspect-ratio: 16/9;
  position: relative;
}

.modern-video-player video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modern-video-iframe-container {
  width: 100%;
  aspect-ratio: 16/9;
  position: relative;
}

.modern-video-iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.modern-video-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.modern-video-sidebar .card {
  width: 100%;
  height: auto;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .modern-video-player-page {
    grid-template-columns: 1fr;
  }
  
  .modern-video-sidebar {
    margin-top: 2rem;
  }
}

/* Comments Section Styles */
.comment-form {
  width: 100%;
  margin-bottom: 1.5rem;
}

.comment-textarea {
  width: 100%;
  margin: 1rem 0;
  padding: 0.75rem;
  background: rgba(255,255,255,0.1);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  min-height: 100px;
  resize: vertical;
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.comments-list {
  max-height: 500px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.comment-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.comment-item:last-child {
  border-bottom: none;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.commenter-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-color);
}

.comment-date {
  font-size: 0.85rem;
  color: var(--text-color-muted);
}

.comment-text {
  color: var(--text-color);
  line-height: 1.5;
  word-break: break-word;
}

.login-prompt {
  text-align: center;
  padding: 1rem;
}

/* Chapter Links Styles */
.chapter-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text-color);
  padding: 0.5rem;
  border-radius: 0.25rem;
  transition: background-color 0.2s ease;
}

.chapter-link:hover {
  background-color: rgba(var(--primary-color-rgb), 0.1);
}

.timestamp {
  margin-left: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-color-muted);
}

/* Scrollbar Styles */
.comments-list::-webkit-scrollbar {
  width: 6px;
}

.comments-list::-webkit-scrollbar-track {
  background: var(--card-bg);
}

.comments-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.comments-list::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Category Select Styles */
.category-select-wrapper {
    position: relative;
    min-width: 200px;
}

.category-select {
    width: 100%;
    padding: 10px 15px;
    font-size: 16px;
    color: #333333;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.category-select option {
    color: #333333;
    background-color: #ffffff;
    padding: 10px;
    font-size: 16px;
}

.category-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(94, 58, 238, 0.3);
}

/* Add a custom arrow */
.category-select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #333333;
    pointer-events: none;
    font-size: 12px;
}

/* Hover and focus states */
.category-select:hover {
    border-color: rgba(0, 0, 0, 0.4);
}

/* Style for disabled options if any */
.category-select option:disabled {
    color: #999999;
    background-color: #f5f5f5;
}

/* Ensure text is visible in all browsers */
.category-select option:checked {
    background-color: #f0f0f0;
    color: #333333;
}

/* Style for the dropdown when open */
.category-select option:hover,
.category-select option:focus {
    background-color: #f0f0f0;
    color: #333333;
}

/* Additional styles for better visibility */
.category-select,
.category-select option {
    text-shadow: none;
}
