@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #111128;
  --bg-card: rgba(20, 20, 50, 0.7);
  --bg-card-hover: rgba(30, 30, 70, 0.8);
  --bg-glass: rgba(139, 92, 246, 0.08);
  --accent-primary: #8b5cf6;
  --accent-secondary: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #8b5cf6, #06b6d4);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(139, 92, 246, 0.15);
  --success: #22c55e;
  --danger: #ef4444;
  --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.15);
}

/* 1. Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

@media (min-width: 640px) {
  html, body {
    font-size: 16px;
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* 2. App Shell */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 1rem;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}
.back-btn:hover {
  background: var(--accent-primary);
  box-shadow: var(--shadow-glow);
  transform: translateX(-2px);
}

/* 3. Search */
.search-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
}
.search-wrap:focus-within {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}
.search-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  padding-left: 0.5rem;
}
.search-input::placeholder {
  color: var(--text-muted);
}

/* 4. Breadcrumbs */
.breadcrumbs {
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.breadcrumb-item {
  background: var(--bg-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Header Layout */
.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.header-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}
.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Breadcrumbs */
.crumb {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.crumb-active {
  color: var(--accent-primary);
  font-weight: 600;
}
.crumb-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Main Content Area */
.main {
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}
.view {
  width: 100%;
}

/* 5. Batch Grid */
.batch-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 640px) { .batch-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .batch-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .batch-grid { grid-template-columns: repeat(4, 1fr); } }

.batch-card {
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.batch-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
  transform: translateY(-4px);
}
.batch-card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
}
.batch-card-info {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}
.batch-card-img {
  position: relative;
  overflow: hidden;
}
.batch-lang {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.7);
  color: var(--accent-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
}
.batch-name {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.batch-byname {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
}
.batch-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
}
.batch-fee {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--success);
}
.batch-tag {
  align-self: flex-start;
  padding: 0.25rem 0.6rem;
  background: var(--bg-glass);
  color: var(--accent-secondary);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 6. Subject List */
.subject-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 640px) { .subject-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .subject-grid { grid-template-columns: repeat(3, 1fr); } }

.subject-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  transition: all 0.3s ease;
  cursor: pointer;
}
.subject-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-secondary);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.15);
}
.subject-left {
  flex-shrink: 0;
}
.subject-img {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.subject-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--bg-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.teacher-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--accent-primary);
  object-fit: cover;
}
.teacher-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
}
.teacher-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.subject-info {
  flex: 1;
  min-width: 0;
}
.subject-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subject-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.tag-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.lecture-count {
  display: inline-block;
  background: var(--accent-primary);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* 7. Content Tabs */
.tabs {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.5rem 0 1rem;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s ease;
}
.tab:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.tab.active {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

/* 8. Content List */
.content-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.content-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: 12px;
  transition: all 0.3s ease;
  cursor: pointer;
}
.content-item:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
  background: var(--bg-card-hover);
}
.content-thumb-wrap {
  position: relative;
  flex-shrink: 0;
}
.content-thumb {
  width: 80px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-secondary);
}
.play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
  color: white;
  font-size: 1.2rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.content-item:hover .play-badge {
  opacity: 1;
}
.pdf-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: var(--danger);
  color: white;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
.content-info {
  flex: 1;
  min-width: 0;
}
.content-name {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.content-action {
  flex-shrink: 0;
  color: var(--accent-primary);
  opacity: 0.6;
  transition: opacity 0.3s;
}
.content-item:hover .content-action {
  opacity: 1;
}
.content-type-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
  background: var(--bg-glass);
  color: var(--accent-secondary);
}
.content-actions {
  display: flex;
  gap: 0.5rem;
}

/* 9 & 10. Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.video-modal {
  width: 100vw;
  height: 100vh;
  background: #000;
  overflow: hidden;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}
.pdf-modal {
  width: 100vw;
  height: 100vh;
  background: var(--bg-primary);
  overflow: hidden;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}
.modal-overlay.active .video-modal,
.modal-overlay.active .pdf-modal {
  transform: scale(1);
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s ease;
}
.modal-close:hover {
  background: var(--danger);
  border-color: var(--danger);
}
.video-iframe, .pdf-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* 11. Loading States */
.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-card) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite linear;
  border-radius: 8px;
}
.skeleton-card {
  height: 250px;
  width: 100%;
  border-radius: 16px;
}
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 26, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-glass);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* 12. Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}
.toast {
  background: var(--bg-card);
  border-left: 4px solid var(--accent-primary);
  color: var(--text-primary);
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5);
  animation: slideInRight 0.3s ease forwards;
  backdrop-filter: blur(10px);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

/* PDF Modal Header */
.pdf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.pdf-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}
.pdf-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.pdf-download-btn {
  color: var(--accent-secondary);
  display: flex;
  padding: 0.3rem;
  border-radius: 6px;
  transition: background 0.3s;
}
.pdf-download-btn:hover {
  background: var(--bg-glass);
}
.pdf-modal .modal-close {
  position: static;
  width: 28px;
  height: 28px;
}
.pdf-modal .pdf-iframe {
  height: calc(100% - 50px);
}
.video-title {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  z-index: 5;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toast show state */
.toast {
  opacity: 0;
  transform: translateX(50px);
  transition: all 0.3s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(0);
  animation: none;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--accent-primary); }

/* 13. Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  text-align: center;
  color: var(--text-muted);
  grid-column: 1 / -1;
}
.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}
.empty-msg {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* 14. Utility */
.hidden {
  display: none !important;
}
.fade-in {
  animation: fadeIn 0.3s ease forwards;
}
.slide-up {
  animation: slideUp 0.4s ease both;
}

/* Skeleton Loading Items */
.skeleton-item {
  pointer-events: none;
}
.skeleton-thumb {
  width: 80px;
  height: 56px;
}
.skeleton-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.skeleton-line {
  height: 14px;
  width: 80%;
}
.skeleton-line-short {
  height: 12px;
  width: 40%;
}

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* 13. Mobile & Webview Optimization */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: max(1rem, env(safe-area-inset-top));
  }
  .app {
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

@media (max-width: 640px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .header-left {
    justify-content: flex-start;
  }
  
  .app-title {
    font-size: 1.25rem;
  }
  
  .search-wrap {
    max-width: 100%;
  }
  
  .main {
    padding: 1rem;
  }
  
  .breadcrumbs {
    padding: 0.75rem 1rem;
  }
  
  .tabs {
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1.25rem;
  }
  
  .tab {
    scroll-snap-align: start;
    font-size: 0.9rem;
    padding: 0.4rem 1rem;
  }
  
  .content-thumb {
    width: 90px;
    height: 60px;
  }
  
  .modal-close {
    top: max(1rem, env(safe-area-inset-top));
  }
  
  .pdf-header {
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }
}

/* 14. Community Popup */
.community-popup {
    background: #17181c;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 24px;
    padding: 32px 24px 24px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.community-icon {
    width: 48px;
    height: 48px;
    color: #06b6d4;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 12px rgba(6, 182, 212, 0.4));
}

.community-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #ffffff;
}

.community-desc {
    font-size: 0.95rem;
    color: #94a3b8;
    text-align: center;
    line-height: 1.5;
    margin-bottom: 24px;
}

.comm-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 12px;
    text-decoration: none;
    color: white;
    transition: transform 0.2s, filter 0.2s;
}

.comm-btn:hover {
    transform: scale(1.02);
    filter: brightness(1.1);
}

.whatsapp-btn {
    background: linear-gradient(135deg, #25d366, #128c7e);
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.25);
}

.telegram-btn {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.25);
}

.comm-btn-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    flex-shrink: 0;
}

.comm-btn-icon svg {
    width: 24px;
    height: 24px;
}

.comm-btn-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.comm-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 2px;
}

.comm-sub {
    font-size: 0.75rem;
    opacity: 0.9;
    font-weight: 500;
}

.comm-arrow {
    font-size: 1.5rem;
    font-weight: 300;
    opacity: 0.7;
}

.community-footer {
    margin-top: 16px;
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.5px;
}
