/* EdgarGym Design System & Modern CSS */

:root {
  color-scheme: dark light;
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.5);
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --accent: #ec4899;
  --accent-glow: rgba(236, 72, 153, 0.35);
  --cyan: #06b6d4;
  
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-sub: #6b7280;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Light Theme Overrides */
html[data-theme="light"] {
  color-scheme: light;
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-glass: rgba(0, 0, 0, 0.05);
  --border-glass: rgba(0, 0, 0, 0.1);
  --border-active: rgba(99, 102, 241, 0.5);

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(79, 70, 229, 0.25);
  --accent: #db2777;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-sub: #64748b;
}

html[data-theme="light"] body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 85% 60%, rgba(236, 72, 153, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
}

html[data-theme="light"] .navbar,
html[data-theme="light"] .admin-sidebar {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .modal-container,
html[data-theme="light"] .pwa-banner,
html[data-theme="light"] .auth-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .category-icon-wrapper {
  background: rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .search-input,
html[data-theme="light"] .form-control {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
}

html[data-theme="light"] .search-input:focus,
html[data-theme="light"] .form-control:focus {
  background: #ffffff;
}

/* Theme Toggle Switch Button */
.theme-toggle-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition);
  outline: none;
}

.theme-toggle-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
  transform: scale(1.08) rotate(15deg);
}

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

html[data-theme="light"] .theme-icon-moon {
  display: inline-block;
}

html:not([data-theme="light"]) .theme-icon-sun {
  display: inline-block;
}

html:not([data-theme="light"]) .theme-icon-moon {
  display: none;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 45%),
    radial-gradient(circle at 85% 60%, rgba(236, 72, 153, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(6, 182, 212, 0.1) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Typography */
h1, h2, h3, h4, .font-heading {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

.gradient-text {
  background: linear-gradient(135deg, #a5b4fc 0%, #6366f1 50%, #ec4899 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Header & Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  background: rgba(11, 15, 25, 0.75);
  border-bottom: 1px solid var(--border-glass);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.brand-logo-img {
  height: 90px;
  max-height: 90px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 15px rgba(0, 0, 0, 0.6));
  transition: var(--transition);
}

.brand-logo-img:hover {
  transform: scale(1.05);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  box-shadow: 0 0 15px var(--primary-glow);
  color: white;
}

.search-bar-container {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.75rem;
  border-radius: var(--radius-full);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--primary);
  background: rgba(17, 24, 39, 0.9);
  box-shadow: 0 0 15px var(--primary-glow);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #be185d);
  color: white;
  box-shadow: 0 4px 14px var(--accent-glow);
}

/* Layout Main */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 3rem 1rem 4rem;
  max-width: 800px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-full);
  color: #a5b4fc;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.hero-title {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1.25rem;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* Categories Grid */
.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 4rem;
}

.category-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), transparent);
  opacity: 0;
  transition: var(--transition);
}

.category-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-active);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 20px var(--primary-glow);
}

.category-card:hover::before {
  opacity: 1;
}

.category-icon-wrapper {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  display: grid;
  place-items: center;
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 1;
  transition: var(--transition);
}

.category-card:hover .category-icon-wrapper {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
  transform: scale(1.08);
}

.category-icon {
  width: 55px;
  height: 55px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.category-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  position: relative;
  z-index: 1;
}

.category-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

/* Exercises Catalog */
.exercises-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.75rem;
}

.exercise-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.exercise-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.media-thumbnail-container {
  position: relative;
  width: 100%;
  height: 200px;
  background: #000;
  overflow: hidden;
}

.media-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.exercise-card:hover .media-thumbnail {
  transform: scale(1.05);
}

.play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.85);
  backdrop-filter: blur(4px);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
  transition: var(--transition);
}

.exercise-card:hover .play-badge {
  transform: translate(-50%, -50%) scale(1.15);
  background: var(--primary);
}

.category-tag {
  position: absolute;
  top: 1rem;
  left: 1rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-glass);
  font-size: 0.75rem;
  font-weight: 600;
  color: #a5b4fc;
}

.exercise-content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.exercise-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.exercise-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.exercise-desc-short {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  position: relative;
  transform: scale(0.95);
  transition: var(--transition);
}

.modal-backdrop.active .modal-container {
  transform: scale(1);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-close {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 1.5rem;
}

/* Exercise Detail Styling */
.video-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.video-wrapper iframe, .video-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.media-carousel {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  scrollbar-width: thin;
}

.carousel-item {
  min-width: 160px;
  height: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: var(--transition);
}

.carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-item:hover {
  border-color: var(--primary);
  transform: scale(1.03);
}

/* Step list */
.tech-guide {
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid var(--border-glass);
}

.tech-guide h4 {
  color: #a5b4fc;
  margin-bottom: 1rem;
}

.tech-steps {
  list-style: none;
  counter-reset: step-counter;
}

.tech-steps li {
  counter-increment: step-counter;
  position: relative;
  padding-left: 2.5rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.tech-steps li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}

/* CMS Admin Form */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
  background: rgba(17, 24, 39, 0.9);
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--primary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 2000;
  transform: translateY(100px);
  opacity: 0;
  transition: var(--transition);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Footer */
footer {
  border-top: 1px solid var(--border-glass);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-sub);
  margin-top: 5rem;
  font-size: 0.9rem;
}

/* PWA Install Banner */
.pwa-banner {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(150px);
  width: calc(100% - 3rem);
  max-width: 580px;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7), 0 0 25px var(--primary-glow);
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pwa-banner-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.pwa-banner-content strong {
  font-size: 1rem;
  color: var(--text-main);
  display: block;
}

.pwa-banner-content p {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.btn-close-banner {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-close-banner:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 640px) {
  .pwa-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    bottom: 1rem;
  }
  .pwa-banner-content {
    flex-direction: column;
    text-align: center;
  }
  .pwa-banner-actions {
    justify-content: center;
    width: 100%;
  }
}
