/* ============================================
   Reset & Base
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --secondary: #059669;
  --secondary-dark: #047857;
  --secondary-light: #10b981;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --text: #111827;
  --text-light: #6b7280;
  --bg: #f9fafb;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.page.hidden {
  display: none;
}

/* ============================================
   Header
   ============================================ */

.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.book-selector {
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s;
  min-width: 150px;
}

.book-selector:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================
   Home Page
   ============================================ */

.home-hero {
  text-align: center;
  margin: 40px 0 60px;
}

.home-hero h2 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.home-hero p {
  font-size: 1.2rem;
  color: var(--text-light);
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.book-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  cursor: pointer;
  border: 2px solid transparent;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.book-card-cover {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
}

.book-card-body {
  padding: 20px;
  text-align: center;
}

.book-card-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.book-card-cta {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 24px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s;
}

.book-card-cta:hover {
  background: var(--primary-dark);
}

/* ============================================
   Book Page - Overview (بازطراحی شده)
   ============================================ */

.book-overview {
  background: transparent;
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 48px;
}

/* Header فشرده */
.book-header-compact {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.book-title-main {
  font-size: 3rem;
  font-weight: 900;
  color: var(--text);
  margin: 0;
  flex: 1;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.back-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.back-home-btn:hover {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateX(-2px);
}

/* Content Layout: Cover + PDFs */
.overview-content {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 768px) {
  .overview-content {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .cover-container-compact {
    width: 120px;
    height: 168px;
    margin: 0 auto;
  }
  
  .pdf-cards-secondary {
    grid-template-columns: 1fr;
  }
}

.cover-container-compact {
  flex-shrink: 0;
  width: 140px;
  height: 196px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  position: relative;
}

.cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.cover-image.loaded {
  display: block;
}

.cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: white;
}

.cover-image.loaded ~ .cover-placeholder {
  display: none;
}

/* PDF Cards Layout */
.main-pdfs-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Primary Card - Student's Book (بزرگ و برجسته) */
.pdf-card-primary {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 50%, #1e3a8a 100%);
  color: white;
  padding: 32px;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(30, 64, 175, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.pdf-card-primary::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
  pointer-events: none;
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

.pdf-card-primary:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(30, 64, 175, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
  border-color: rgba(255, 255, 255, 0.25);
}

.pdf-card-primary::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.pdf-card-icon-large {
  font-size: 4.5rem;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  display: block;
  transform: scale(1);
  transition: transform 0.3s ease;
}

.pdf-card-primary:hover .pdf-card-icon-large {
  transform: scale(1.05);
}

.pdf-card-title-large {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 12px;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), 0 2px 4px rgba(0, 0, 0, 0.8);
  color: #ffffff;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-family: 'Vazirmatn', sans-serif;
}

.pdf-card-subtitle {
  font-size: 1.15rem;
  margin-bottom: 28px;
  color: #e0e7ff;
  font-weight: 600;
  text-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.6),
    0 1px 3px rgba(0, 0, 0, 0.8);
  opacity: 1;
  line-height: 1.4;
  font-family: 'Vazirmatn', sans-serif;
}

.pdf-card-primary .pdf-card-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-large {
  padding: 14px 28px;
  font-size: 1.05rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  min-width: 160px;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Vazirmatn', sans-serif;
}

.pdf-card-primary .btn-primary {
  background: white;
  color: var(--primary);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
  border: none;
  position: relative;
  overflow: hidden;
}

.pdf-card-primary .btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.1), transparent);
  transition: left 0.5s;
  z-index: 0;
}

.pdf-card-primary .btn-primary:hover::before {
  left: 100%;
}

.pdf-card-primary .btn-primary:hover {
  background: #f0f4ff;
  color: var(--primary-dark);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
}

.pdf-card-primary .btn-primary span {
  position: relative;
  z-index: 1;
}

.pdf-card-primary .btn-primary:active {
  transform: translateY(-1px) scale(1);
}

.pdf-card-primary .btn-success {
  background: white;
  color: var(--secondary);
  border: 2px solid white;
  backdrop-filter: blur(10px);
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  position: relative;
  overflow: hidden;
}

.pdf-card-primary .btn-success::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(5, 150, 105, 0.15), transparent);
  transition: left 0.5s;
  z-index: 0;
}

.pdf-card-primary .btn-success:hover::before {
  left: 100%;
}

.pdf-card-primary .btn-success:hover {
  background: #f0fdf4;
  color: var(--secondary-dark);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  border-color: white;
}

.pdf-card-primary .btn-success span {
  position: relative;
  z-index: 1;
}

.pdf-card-primary .btn-success:active {
  transform: translateY(-1px) scale(1);
}

/* Secondary Cards Container */
.pdf-cards-secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

/* Secondary Cards - سایر PDFها */
.pdf-card-secondary {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 28px 24px;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
}

.pdf-card-secondary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transform: scaleX(0);
  transition: transform 0.4s ease;
}

.pdf-card-secondary:hover:not(.disabled)::before {
  transform: scaleX(1);
}

.pdf-card-secondary:hover:not(.disabled) {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15);
  transform: translateY(-4px);
  background: #fafbfc;
}

.pdf-card-secondary.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg);
  filter: grayscale(0.3);
}

.pdf-card-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  display: block;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.pdf-card-secondary:hover:not(.disabled) .pdf-card-icon {
  transform: scale(1.15) rotate(5deg);
}

.pdf-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  line-height: 1.3;
  font-family: 'Vazirmatn', sans-serif;
}

.pdf-card-secondary .pdf-card-subtitle {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 20px;
  line-height: 1.4;
  font-weight: 500;
  font-family: 'Vazirmatn', sans-serif;
}

.pdf-card-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.pdf-card-secondary .pdf-card-actions {
  margin-top: 8px;
}

.pdf-card-badge {
  display: inline-block;
  padding: 8px 16px;
  background: var(--text-light);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 12px;
}

.pdf-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: all 0.2s;
}

.pdf-card:hover:not(.disabled) {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.pdf-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pdf-card-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.pdf-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.pdf-card-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.pdf-card-badge {
  display: inline-block;
  padding: 6px 12px;
  background: var(--text-light);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-top: 8px;
}

/* ============================================
   Sections (بازطراحی شده با hierarchy)
   ============================================ */

.sections-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.section-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: visible;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.section-card:hover {
  box-shadow: var(--shadow-lg);
}

.section-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.section-header:hover {
  background: #f5f5f5;
}

.section-header.active {
  background: var(--bg);
  border-bottom-color: var(--primary);
  border-bottom-width: 2px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.2rem;
  font-weight: 600;
}

.section-icon {
  font-size: 1.5rem;
}

.section-meta {
  color: var(--text-light);
  font-size: 0.9rem;
}

.section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.section-content.open {
  max-height: none;
  overflow: visible;
  height: auto;
}

.section-body {
  padding: 24px;
  overflow: visible;
}

.section-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.search-box:focus {
  outline: none;
  border-color: var(--primary);
}

.sort-select {
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--card-bg);
  cursor: pointer;
}

.files-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  gap: 16px;
}

.file-item:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

/* Video Item - Layout خاص */
.file-item.video-item {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}

.video-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.video-wrapper {
  width: 100%;
  background: #000;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  overflow: visible;
  position: relative;
  min-height: 200px;
}

.video-wrapper .plyr-video,
.video-wrapper video {
  width: 100%;
  height: auto;
  display: block;
  max-height: 600px;
}

.video-wrapper .plyr {
  width: 100%;
  height: auto;
  max-height: 600px;
  overflow: visible;
}

.video-info {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.file-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.file-name {
  font-size: 0.95rem;
  color: var(--text);
  word-break: break-all;
  direction: ltr;
  text-align: left;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}


/* ============================================
   Buttons
   ============================================ */

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
}

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

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

.btn-success {
  background: var(--secondary);
  color: white;
  border: none;
}

.btn-success:hover {
  background: var(--secondary-dark);
  color: white;
}

.btn-success:active {
  background: var(--secondary-dark);
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-icon:hover {
  background: var(--border);
  transform: scale(1.05);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-icon:active {
  transform: scale(0.95);
}

/* ============================================
   Modal
   ============================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 1200px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  word-break: break-all;
  direction: ltr;
  text-align: left;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.modal-body {
  flex: 1;
  overflow: hidden;
  padding: 20px;
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: var(--radius-sm);
}

/* ============================================
   Audio Player (Sticky)
   ============================================ */

.audio-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-top: 2px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  z-index: 999;
  padding: 16px 20px;
  backdrop-filter: blur(10px);
}

.audio-player.hidden {
  display: none;
}

.audio-player-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  direction: rtl;
}

.audio-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 200px;
}

.audio-icon {
  font-size: 1.5rem;
}

.audio-filename {
  font-size: 0.95rem;
  color: var(--text);
  direction: ltr;
  text-align: left;
  word-break: break-all;
}

.audio-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.audio-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  padding: 0;
}

.audio-btn svg {
  width: 18px;
  height: 18px;
}

.audio-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.audio-btn:active {
  transform: scale(0.95);
}

.audio-seek {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.audio-seek {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.audio-seek audio {
  width: 100%;
}

/* Plyr Customization */
.plyr {
  border-radius: var(--radius-sm);
}

.plyr__control--overlaid {
  background: var(--primary);
}

.plyr__control--overlaid:hover {
  background: var(--primary-dark);
}

.plyr__progress__played {
  color: var(--primary);
}

.plyr__volume {
  color: var(--primary);
}

/* Video wrapper with Plyr */
.video-wrapper .plyr {
  width: 100%;
  height: auto;
}

.video-wrapper .plyr__video-wrapper {
  position: relative;
  width: 100%;
  height: auto;
}

.video-wrapper .plyr__video-embed,
.video-wrapper .plyr__video-wrapper video {
  width: 100%;
  height: auto;
  max-height: 600px;
}

/* Audio items in file list */
.file-item.audio-item .plyr {
  max-width: 400px;
  margin: 8px 0;
  overflow: visible;
}

.file-item.audio-item {
  overflow: visible;
}

.audio-close {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.audio-close:hover {
  background: #dc2626;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.audio-close:active {
  transform: scale(0.95);
}

/* ============================================
   Loading & Skeleton
   ============================================ */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  gap: 16px;
}

.loading-overlay.hidden {
  display: none;
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.error-message {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
  }

  .book-selector {
    width: 100%;
  }

  .home-hero h2 {
    font-size: 2rem;
  }

  .books-grid {
    grid-template-columns: 1fr;
  }

  .book-header-compact {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .book-title-main {
    font-size: 2rem;
  }

  .overview-content {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .cover-container-compact {
    width: 140px;
    height: 196px;
    margin: 0 auto;
  }

  .pdf-card-primary {
    padding: 32px 24px;
  }

  .pdf-card-title-large {
    font-size: 2rem;
  }

  .pdf-card-subtitle {
    font-size: 1.1rem;
  }

  .pdf-card-icon-large {
    font-size: 4rem;
  }

  .btn-large {
    padding: 14px 24px;
    font-size: 1rem;
    width: 100%;
    min-width: auto;
    justify-content: center;
  }

  .pdf-card-primary .pdf-card-actions {
    flex-direction: column;
  }

  .pdf-cards-secondary {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .book-title-main {
    font-size: 2.2rem;
  }

  .overview-content {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .cover-container-compact {
    width: 150px;
    height: 210px;
    margin: 0 auto;
  }

  .pdf-card-primary {
    padding: 36px 28px;
  }

  .pdf-card-title-large {
    font-size: 2.2rem;
  }

  .pdf-card-subtitle {
    font-size: 1.2rem;
  }

  .pdf-card-icon-large {
    font-size: 4.5rem;
  }

  .pdf-card-badge-primary {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .btn-large {
    padding: 16px 28px;
    font-size: 1.05rem;
    width: 100%;
    min-width: auto;
    justify-content: center;
  }

  .pdf-card-primary .pdf-card-actions {
    flex-direction: column;
    gap: 12px;
  }

  .pdf-cards-secondary {
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 28px;
  }

  .pdf-card-secondary {
    padding: 28px 24px;
  }

  .file-item:not(.video-item) {
    flex-direction: column;
    align-items: flex-start;
  }

  .file-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .video-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .video-info .file-actions {
    width: 100%;
    margin-top: 12px;
  }

  .audio-player-content {
    flex-direction: column;
    align-items: stretch;
  }

  .audio-seek {
    max-width: 100%;
  }

  .modal-content {
    height: 100vh;
    border-radius: 0;
  }
}

