/* XReel Theme — Main Styles (Reset + Layout + Components) */

/* CSS Variables */
:root {
  /* Colors — overridden by customizer */
  --xreel-primary: #e50914;
  --xreel-primary-dark: #b80710;
  --xreel-primary-glow: rgba(229, 9, 20, 0.4);
  --xreel-primary-light: rgba(229, 9, 20, 0.15);
  --xreel-bg: #0a0a14;
  --xreel-bg-card: #14142a;
  --xreel-bg-elevated: #1c1c38;
  --xreel-bg-hover: #24244a;
  --xreel-text: #ffffff;
  --xreel-text-secondary: #9ca3af;
  --xreel-text-muted: #6b7280;
  --xreel-border: #2a2a4a;
  --xreel-success: #10b981;
  --xreel-warning: #f59e0b;
  --xreel-danger: #ef4444;
  --xreel-radius: 12px;
  --xreel-radius-sm: 8px;
  --xreel-radius-lg: 16px;
  --xreel-radius-xl: 24px;
  --xreel-shadow: 0 8px 32px rgba(0,0,0,0.5);
  --xreel-shadow-glow: 0 0 40px var(--xreel-primary-glow);
  --xreel-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --xreel-header-height: 64px;
  --xreel-bottom-nav-height: 60px;
  --xreel-max-width: 1280px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--xreel-bg);
  background-image:
    radial-gradient(ellipse at top, var(--xreel-primary-light) 0%, transparent 50%),
    radial-gradient(ellipse at bottom, var(--xreel-bg-card) 0%, var(--xreel-bg) 60%);
  background-attachment: fixed;
  color: var(--xreel-text);
  font-family: 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--xreel-text);
  text-decoration: none;
  transition: color var(--xreel-transition);
}

a:hover { color: var(--xreel-primary); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

::selection {
  background: var(--xreel-primary);
  color: white;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--xreel-bg); }
::-webkit-scrollbar-thumb { background: var(--xreel-bg-elevated); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--xreel-primary); }

/* Site structure */
.site {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-content {
  flex: 1;
  padding-top: var(--xreel-header-height);
  padding-bottom: calc(var(--xreel-bottom-nav-height) + 16px);
}

.site-main {
  max-width: var(--xreel-max-width);
  margin: 0 auto;
  padding: 16px;
  width: 100%;
}

@media (min-width: 768px) {
  .site-main { padding: 24px; }
}

/* ============= Header ============= */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 10, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--xreel-border);
}

.header-container {
  max-width: var(--xreel-max-width);
  margin: 0 auto;
  height: var(--xreel-header-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
}

.header-logo { flex-shrink: 0; }

.logo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 22px;
  color: var(--xreel-text);
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--xreel-primary), var(--xreel-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 20px var(--xreel-primary-glow);
}

.logo-text { letter-spacing: -0.5px; }
.logo-accent { color: var(--xreel-primary); }

/* Navigation */
.main-navigation {
  flex: 1;
  display: flex;
  justify-content: center;
}

.primary-menu {
  display: flex;
  list-style: none;
  gap: 4px;
}

.primary-menu li a {
  display: block;
  padding: 8px 16px;
  border-radius: var(--xreel-radius-sm);
  color: var(--xreel-text-secondary);
  font-weight: 600;
  font-size: 14px;
  transition: var(--xreel-transition);
}

.primary-menu li a:hover,
.primary-menu li.current-menu-item > a {
  background: var(--xreel-primary-light);
  color: var(--xreel-primary);
}

/* Search */
.header-search {
  flex-shrink: 0;
}

.search-form {
  display: flex;
  align-items: center;
  background: var(--xreel-bg-card);
  border: 1px solid var(--xreel-border);
  border-radius: 999px;
  padding: 4px 4px 4px 16px;
  transition: var(--xreel-transition);
}

.search-form:focus-within {
  border-color: var(--xreel-primary);
  box-shadow: 0 0 0 3px var(--xreel-primary-light);
}

.search-field {
  background: none;
  border: none;
  color: var(--xreel-text);
  padding: 6px 8px;
  width: 220px;
  outline: none;
}

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

.search-submit {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--xreel-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--xreel-transition);
}

.search-submit:hover { background: var(--xreel-primary-dark); }

/* Mobile menu toggle */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
}

.mobile-menu-toggle span {
  width: 24px;
  height: 2px;
  background: var(--xreel-text);
  border-radius: 2px;
  transition: var(--xreel-transition);
}

.mobile-menu-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.mobile-menu-toggle.active span:nth-child(2) { opacity: 0; }
.mobile-menu-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.mobile-menu {
  display: none;
  background: var(--xreel-bg-card);
  border-bottom: 1px solid var(--xreel-border);
  padding: 16px;
}

.mobile-menu.active { display: block; }

.mobile-menu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-menu-list li a {
  display: block;
  padding: 12px 16px;
  border-radius: var(--xreel-radius-sm);
  background: var(--xreel-bg-elevated);
  color: var(--xreel-text);
  font-weight: 600;
}

.mobile-menu-list li a:hover { background: var(--xreel-primary); color: white; }

/* ============= Footer ============= */
.site-footer {
  background: var(--xreel-bg-card);
  border-top: 1px solid var(--xreel-border);
  margin-top: 64px;
  padding: 32px 16px 16px;
}

.footer-container {
  max-width: var(--xreel-max-width);
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 24px;
}

.footer-widget-title,
.footer-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--xreel-text);
  margin-bottom: 12px;
}

.footer-logo-text {
  font-size: 22px;
}

.footer-logo-accent { color: var(--xreel-primary); }

.footer-desc {
  color: var(--xreel-text-secondary);
  font-size: 13px;
  line-height: 1.7;
}

.footer-widget ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-widget a {
  color: var(--xreel-text-secondary);
  font-size: 13px;
}

.footer-widget a:hover { color: var(--xreel-primary); }

.footer-bottom {
  border-top: 1px solid var(--xreel-border);
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--xreel-text-muted);
  font-size: 12px;
}

.footer-menu {
  list-style: none;
  display: flex;
  gap: 16px;
}

.footer-menu a { color: var(--xreel-text-secondary); }

/* ============= Bottom nav (mobile) ============= */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: rgba(10, 10, 20, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--xreel-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--xreel-bottom-nav-height);
  max-width: 480px;
  margin: 0 auto;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  color: var(--xreel-text-muted);
  font-size: 10px;
  font-weight: 600;
  transition: var(--xreel-transition);
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
  color: var(--xreel-primary);
}

.bottom-nav-item.active svg {
  fill: var(--xreel-primary-light);
}

/* ============= Common Components ============= */

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--xreel-bg-elevated);
  border-top-color: var(--xreel-primary);
  border-radius: 50%;
  animation: xreel-spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* Loading state */
.loading-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--xreel-text-secondary);
}

.loading-state p { font-size: 14px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--xreel-text-muted);
}

.empty-state svg {
  margin: 0 auto 16px;
  opacity: 0.4;
}

.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* Buttons */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--xreel-radius-sm);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: var(--xreel-transition);
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--xreel-primary-dark);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--xreel-primary-glow);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

.btn-secondary:hover {
  background: var(--xreel-bg-hover);
  border-color: var(--xreel-primary);
  color: var(--xreel-text);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  backdrop-filter: blur(8px);
}

.badge-dubbed { background: var(--xreel-primary); color: white; }
.badge-subtitled { background: rgba(0, 0, 0, 0.75); color: white; }
.badge-episodes { background: rgba(255, 255, 255, 0.1); color: var(--xreel-text-secondary); }
.badge-source { background: rgba(0, 0, 0, 0.6); color: var(--xreel-text-secondary); }
.badge-corner {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Breadcrumb */
.xreel-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--xreel-text-muted);
  margin-bottom: 16px;
  padding: 8px 0;
}

.xreel-breadcrumb a:hover { color: var(--xreel-primary); }
.xreel-breadcrumb .sep { opacity: 0.5; }
.xreel-breadcrumb .current { color: var(--xreel-text); font-weight: 600; }

/* Section title */
.section-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--xreel-text);
}

.section-title::before {
  content: '';
  width: 4px;
  height: 20px;
  background: var(--xreel-primary);
  border-radius: 2px;
}

/* Page header */
.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--xreel-text);
}

/* Plugin required notice */
.plugin-required {
  text-align: center;
  padding: 80px 24px;
  max-width: 600px;
  margin: 0 auto;
}

.plugin-required-icon {
  color: var(--xreel-warning);
  margin-bottom: 24px;
}

.plugin-required h1 {
  font-size: 28px;
  margin-bottom: 12px;
}

.plugin-required p {
  color: var(--xreel-text-secondary);
  margin-bottom: 24px;
}

/* Comments */
.comments-area {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--xreel-border);
}

.comments-title {
  font-size: 20px;
  margin-bottom: 24px;
}

.comment-list {
  list-style: none;
}

.comment {
  background: var(--xreel-bg-card);
  padding: 16px;
  border-radius: var(--xreel-radius);
  margin-bottom: 12px;
}

.comment-body { display: flex; gap: 12px; }
.comment-meta { font-size: 12px; color: var(--xreel-text-muted); margin-bottom: 8px; }
.comment-content { font-size: 14px; }

.comment-form {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.comment-form input,
.comment-form textarea {
  background: var(--xreel-bg-card);
  border: 1px solid var(--xreel-border);
  color: var(--xreel-text);
  padding: 10px 14px;
  border-radius: var(--xreel-radius-sm);
}

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

.comment-form .submit {
  background: var(--xreel-primary);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: var(--xreel-radius-sm);
  font-weight: 700;
  cursor: pointer;
  width: fit-content;
}
