/* Universal Box Sizing for perfect alignments */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --accent: #8b5cf6; 
  --accent-hover: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.4);
  --bg-deep: #050505;
  --glass-bg: rgba(20, 20, 22, 0.4);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(24px);
  --text-main: #ffffff;
  --text-dim: #a1a1aa;
}

body {
  margin: 0; font-family: sans-serif;
  color: var(--text-main); background-color: var(--bg-deep);
  overflow-x: hidden; position: relative; min-height: 100vh;
}

/* --- DYNAMIC BACKGROUND --- */
.bg-layer {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(to bottom, rgba(5,5,5,0.5) 0%, rgba(5,5,5,0.9) 80%, var(--bg-deep) 100%), var(--bg-image, none);
  background-size: cover; background-position: center;
  filter: blur(40px) brightness(0.5); transform: scale(1.2); transition: background-image 0.5s ease-in-out;
}

/* --- PRELOADER --- */
#preloader {
  position: fixed; inset: 0; background: #000; z-index: 9999999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity 0.8s ease-out, visibility 0.8s;
}
.loader-logo-only {
  width: 90px; height: auto; object-fit: contain; margin-bottom: 25px;
  animation: breathingLogo 2s ease-in-out infinite;
}
@keyframes breathingLogo {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.2)); }
  50% { transform: scale(1.1); filter: drop-shadow(0 0 25px rgba(139, 92, 246, 0.8)); }
}
.loader-text { font-weight: 800; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 12px; color: #fff; }
.progress-container { width: 220px; height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 10px; overflow: hidden; }

.progress-bar { 
  width: 0%; 
  height: 100%; 
  background: linear-gradient(90deg, var(--accent) 0%, #a78bfa 50%, var(--accent) 100%);
  background-size: 200% 100%;
  animation: loadingMove 1.5s linear infinite;
  box-shadow: 0 0 10px var(--accent); 
  transition: width 0.4s ease; 
}
@keyframes loadingMove { 0% { background-position: 200% 0; } 100% { background-position: 0 0; } }

.status-steps { margin-top: 12px; font-size: 11px; color: #888; font-weight: 500; letter-spacing: 0.5px; transition: color 0.3s; }
.preloader-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

/* --- TOAST --- */
.toast-notification {
  position: fixed; top: -80px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 15, 15, 0.95); backdrop-filter: blur(12px); border: 1px solid var(--glass-border);
  color: #fff; padding: 12px 24px; border-radius: 30px; font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 1000000; display: flex; align-items: center; gap: 8px; transition: top 0.4s;
}
.toast-notification.show { top: 80px; }

/* --- HEADER --- */
.header {
  height: 70px; 
  background: linear-gradient(180deg, rgba(5,5,5,0.98) 0%, rgba(5,5,5,0.70) 100%);
  backdrop-filter: blur(24px); 
  -webkit-backdrop-filter: blur(24px);
  display: flex; align-items: center; justify-content: space-between; 
  padding: 0 4%; position: sticky; top: 0; z-index: 10000;
  
  border-radius: 0 0 24px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 1px solid rgba(255, 255, 255, 0.03); 
  border-right: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  
  transition: all 0.4s ease; 
}

.header.scrolled {
  background: linear-gradient(180deg, rgba(0,0,0,0.90) 0%, rgba(0,0,0,0.60) 100%);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-bottom: 1px solid rgba(139, 92, 246, 0.6);
  border-left: 1px solid rgba(139, 92, 246, 0.1);
  border-right: 1px solid rgba(139, 92, 246, 0.1);
  box-shadow: 0 15px 40px rgba(0,0,0,0.8), 0 5px 20px rgba(139, 92, 246, 0.15); 
}

.logo { 
  height: 38px; cursor: pointer; position: absolute; left: 50%; transform: translateX(-50%); 
  filter: drop-shadow(0 2px 6px rgba(0,0,0,1)) drop-shadow(0 0 2px rgba(0,0,0,0.8)); 
}

.home-btn { 
  padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); 
  border: 1px solid rgba(255, 255, 255, 0.1); color: #fff; cursor: pointer; transition: 0.2s; backdrop-filter: blur(10px); 
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.home-btn:hover { 
  background: rgba(255,255,255,0.1); border-color: var(--accent); 
  box-shadow: 0 0 15px var(--accent-glow); transform: scale(1.05); 
}

/* --- THEATER LAYOUT --- */
.theater-container {
  display: grid; 
  grid-template-columns: 360px 1fr; 
  gap: 24px;
  max-width: 1450px; 
  margin: 8px auto 24px auto; 
  padding: 0 4vw;
  align-items: stretch; 
}
@media (min-width: 1600px) { .theater-container { padding: 0 5vw; } }

.sidebar-wrapper { order: 1; position: relative; height: 100%; min-height: 300px; }
.ep-sidebar {
  position: absolute; inset: 0; 
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border);
  border-radius: 20px; display: flex; flex-direction: column; overflow: hidden; margin: 0;
}
.player-main { order: 2; width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 16px; justify-content: flex-start; margin: 0; padding: 0; }

@media (max-width: 1100px) { 
  .theater-container { grid-template-columns: 1fr; padding: 0 20px; } 
  .player-main { order: 1; } 
  .sidebar-wrapper { order: 2; height: auto; min-height: 0; }
  .ep-sidebar { position: relative; inset: auto; height: auto; max-height: none; }
  .ep-scroll { max-height: 420px; } 
}

/* --- PLAYER --- */
.player-wrapper {
  position: relative; aspect-ratio: 16/9; background: #000; border-radius: 16px;
  overflow: hidden; border: 1px solid var(--glass-border); box-shadow: 0 20px 40px rgba(0,0,0,0.6); margin: 0; display: block;
}
.player-wrapper iframe { width: 100%; height: 100%; border: none; display: block; }
.player-overlay {
  position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background-size: cover; background-position: center; cursor: pointer; transition: background-image 0.5s ease-in-out;
}
.play-btn {
  width: 75px; height: 75px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
  box-shadow: 0 0 30px var(--accent-glow); transition: 0.2s;
}
.play-btn:hover { transform: scale(1.1); background: var(--accent-hover); }
.play-btn span { color: #fff; font-size: 45px; margin: 0; }

.loader { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: #000; z-index: 5; }
.loader span { width: 50px; height: 50px; border: 4px solid #222; border-top: 4px solid var(--accent); border-radius: 50%; animation: playerSpin 1s linear infinite; }
@keyframes playerSpin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- CONTROLS GRID --- */
.controls-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; position: relative; margin: 0; }
.btn-ui {
  height: 50px; 
  padding: 0 16px; border-radius: 14px; background: var(--glass-bg); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); color: #fff; cursor: pointer; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 13px; transition: 0.2s;
}
.btn-ui:hover { background: rgba(255,255,255,0.1); }
.btn-ui:active { transform: scale(0.96); }
@media (max-width: 360px) { .controls-grid { grid-template-columns: 1fr; } }

.server-wrap { position: relative; width: 100%; }
.btn-server { background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.2); color: #4ade80; position: relative; justify-content: space-between; }
#currentServer { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; }

.server-menu {
  position: absolute; bottom: calc(100% + 10px); left: 0; width: 100%; background: rgba(15,15,15,0.95);
  backdrop-filter: blur(15px); border: 1px solid var(--glass-border); border-radius: 14px; overflow: hidden;
  display: none; flex-direction: column; box-shadow: 0 10px 30px rgba(0,0,0,0.8); z-index: 100;
}
.server-menu.active { display: flex; }
.server-item { padding: 14px; color: #ccc; cursor: pointer; display: flex; justify-content: space-between; font-size: 14px; }
.server-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.server-item.active { color: #4ade80; font-weight: 600; }
.server-dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; }

.btn-red { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); color: #f87171;}
.btn-red.active-red { background: #ef4444; border-color: #ef4444; color: #fff; }
.btn-purple { background: rgba(139, 92, 246, 0.1); border-color: rgba(139, 92, 246, 0.2); color: #a78bfa;}
.btn-blue { background: rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.2); color: #60a5fa;}

/* --- SECTION WRAPPERS --- */
.section-wrap { max-width: 1450px; margin: 40px auto 0; padding: 0 4vw; }
@media (min-width: 1600px) { .section-wrap { padding: 0 5vw; } }
@media (max-width: 768px) { .section-wrap { padding: 0 20px; } }

/* --- FULL WIDTH ANIME CARD --- */
.anime-glass-card {
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border);
  padding: 30px; border-radius: 16px; display: flex; gap: 30px; align-items: center; 
  transition: 0.3s; width: 100%; box-sizing: border-box; min-height: 260px;
}
.anime-glass-card img { width: 160px; height: 230px; object-fit: cover; border-radius: 14px; box-shadow: 0 10px 20px rgba(0,0,0,0.5); }
.anime-text { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.anime-text h1 { margin: 0 0 14px 0; font-size: 30px; font-weight: 800; transition: 0.3s; }

/* Scrollable Description */
.desc-clamp {
  font-size: 15px; line-height: 1.6; margin: 0; color: #ccc;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; transition: 0.3s;
}
.desc-clamp.expanded { 
  display: block; -webkit-line-clamp: unset; overflow-y: auto; max-height: 130px; padding-right: 8px; 
}
.desc-clamp.expanded::-webkit-scrollbar { width: 4px; }
.desc-clamp.expanded::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); border-radius: 10px; }
.desc-clamp.expanded::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 10px; }
.desc-clamp.expanded::-webkit-scrollbar-thumb:hover { background: var(--accent-hover); }

.read-more-btn { color: var(--accent); cursor: pointer; font-size: 14px; font-weight: 600; margin-top: 10px; display: inline-block; transition: 0.2s; }
.read-more-btn:hover { color: var(--accent-hover); }

@media (max-width: 600px) { 
  .anime-glass-card { flex-direction: column; text-align: center; padding: 24px; gap: 20px; min-height: auto;} 
  .anime-glass-card img { width: 140px; height: 200px; }
  .anime-text h1 { font-size: 24px; }
}

/* --- EPISODE SIDEBAR --- */
.ep-header-wrap { padding: 20px 20px 10px 20px; }
.ep-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.ep-top-row h2 { margin: 0; font-size: 20px; font-weight: 700; }
.ep-tools { display: flex; gap: 8px; align-items: center; }
.ep-search {
  background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 8px;
  color: #fff; padding: 6px 12px; width: 80px; font-size: 13px; outline: none; font-family: inherit; transition: 0.2s;
}
.ep-search:focus { width: 120px; border-color: var(--accent); background: rgba(0,0,0,0.5); }
.ep-view-btn { background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 8px; color: #ccc; padding: 4px 8px; cursor: pointer; display: flex; align-items: center; }

/* Pagination Controls */
.ep-range-selector {
  background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border); border-radius: 10px;
  padding: 10px; text-align: center; font-size: 14px; font-weight: 600; color: #aaa; margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: center;
}

#prevPageBtn, #nextPageBtn { 
  cursor: pointer; 
  padding: 4px 8px; 
  transition: 0.2s; 
  border-radius: 6px; 
  background: var(--accent); 
  color: #fff; 
  box-shadow: 0 4px 10px var(--accent-glow);
}

#prevPageBtn:hover, #nextPageBtn:hover { 
  background: var(--accent-hover); 
  transform: scale(1.05); 
}

.page-btn-disabled { 
  opacity: 0.3 !important; 
  pointer-events: none !important; 
  cursor: default !important; 
  background: rgba(255,255,255,0.05) !important; 
  color: #888 !important; 
  box-shadow: none !important; 
  transform: none !important;
}

.ep-scroll { flex: 1; overflow-y: auto; padding: 0 16px 20px 16px; min-height: 0; scroll-behavior: smooth; }
.ep-scroll::-webkit-scrollbar { width: 6px; }
.ep-scroll::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 10px; margin: 10px 0; }
.ep-scroll::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 10px; }
.ep-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent-hover); }

/* List View */
.ep-list { display: flex; flex-direction: column; gap: 4px; }
.ep-list .ep-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px;
  text-decoration: none; color: #ccc; font-size: 14px; font-weight: 500; transition: 0.2s; cursor: pointer;
}
.ep-list .ep-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.ep-list .ep-item.active { background: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 4px 15px var(--accent-glow); }
.ep-list .ep-num { width: 20px; font-weight: 800; }

/* Grid View Box */
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 10px; }
.ep-grid .ep-item {
  aspect-ratio: 1; background: rgba(0,0,0,0.3); border-radius: 12px; display: flex; align-items: center;
  justify-content: center; font-weight: 700; text-decoration: none; color: #ccc; transition: 0.2s; cursor: pointer;
}
.ep-grid .ep-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.ep-grid .ep-item.active { background: var(--accent); color: #fff; box-shadow: 0 4px 15px var(--accent-glow); }

/* --- NETFLIX STYLE GLASSY GRIDS --- */
.section-head { 
  display: flex; justify-content: space-between; align-items: flex-end; 
  margin-bottom: 24px; padding-bottom: 12px;
  border-bottom: 1px solid var(--glass-border); position: relative;
}
.section-head::after {
  content: ''; position: absolute; bottom: -1px; left: 0; 
  width: 100px; height: 3px; background: var(--accent); border-radius: 3px;
  box-shadow: 0 0 10px var(--accent-glow);
}
.section-head h3 { margin: 0; font-size: 22px; font-weight: 800; }
.text-btn { font-size: 13px; color: var(--text-dim); cursor: pointer; background: var(--glass-bg); backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border); padding: 8px 16px; border-radius: 10px; text-decoration: none; transition: 0.2s; }
.text-btn:hover { color: #fff; border-color: rgba(255,255,255,0.3); }

.netflix-row {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 16px;
  padding-bottom: 20px; scroll-behavior: smooth;
}
.netflix-row::-webkit-scrollbar { height: 6px; }
.netflix-row::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

.netflix-card {
  flex: 0 0 clamp(140px, 40vw, 200px); scroll-snap-align: start;
  position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 2/3;
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border);
  cursor: pointer; text-decoration: none; color: #fff; transition: 0.3s;
}
.netflix-card:hover { transform: translateY(-6px); border-color: rgba(255,255,255,0.3); box-shadow: 0 15px 30px rgba(0,0,0,0.6); }
.netflix-card img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.9; }
.card-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, transparent 60%); display: flex; flex-direction: column; justify-content: flex-end; padding: 12px; }

.card-tag { 
  position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 800; padding: 4px 8px; border-radius: 6px;
  background: var(--accent) !important; color: #ffffff !important; border: none !important; backdrop-filter: none !important; 
  box-shadow: 0 4px 10px rgba(139, 92, 246, 0.4) !important;
}
.card-title { font-weight: 700; font-size: 14px; line-height: 1.3; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.shimmer { background: rgba(255,255,255,0.05); position: relative; overflow: hidden; }
.shimmer::after { content:""; position:absolute; top:0; left:-150%; width:150%; height:100%; background:linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent); animation:shimmer 1.5s infinite; }
@keyframes shimmer { 100% { left: 150%; } }

/* --- GLASSY FOOTER --- */
.footer-glass {
  margin-top: 60px; padding: 25px 20px; background: var(--glass-bg); backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--glass-border); text-align: center; color: var(--text-dim); font-size: 13px;
}

/* --- MODAL (Report) --- */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.8); backdrop-filter: blur(10px); z-index: 100000; }
.modal-box { width: 90%; max-width: 400px; background: var(--glass-bg); backdrop-filter: var(--glass-blur); padding: 24px; border-radius: 20px; border: 1px solid var(--glass-border); box-shadow: 0 20px 50px rgba(0,0,0,0.8); }
.modal input, .modal textarea { width: 100%; margin-bottom: 12px; padding: 14px; border: 1px solid var(--glass-border); border-radius: 12px; background: rgba(0,0,0,0.5); color: #fff; box-sizing: border-box; font-family: inherit; outline: none;}
.modal input:focus, .modal textarea:focus { border-color: var(--accent); }
.modal button { width: 100%; padding: 14px; border: none; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; font-size: 16px; cursor: pointer; transition: 0.2s; }
.modal button:hover { background: var(--accent-hover); }

/* --- ERROR PAGE --- */
.error-page-wrap { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; z-index: 10; }
.error-icon { width: 80px; height: 80px; background: rgba(239, 68, 68, 0.1); border: 1px solid #ef4444; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; font-size: 40px; color: #ef4444; font-weight: bold; }
