/* =========================================
   AnyEXT — Core Design System
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Noto+Serif+JP:wght@400;700&display=swap');

/* ── CSS Variables ── */
:root {
  --bg-0:        #080c10;
  --bg-1:        #0d1117;
  --bg-2:        #161b22;
  --bg-3:        #21262d;
  --bg-4:        #30363d;

  --text-primary:   #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  --accent:         #00d9c0;
  --accent-dim:     rgba(0, 217, 192, 0.12);
  --accent-glow:    0 0 20px rgba(0, 217, 192, 0.35);
  --accent-hover:   #00f0d4;

  --blue:           #58a6ff;
  --gold:           #ffd700;
  --danger:         #f85149;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  --shadow-card:  0 4px 24px rgba(0, 0, 0, 0.6);
  --shadow-heavy: 0 8px 40px rgba(0, 0, 0, 0.8);

  --topbar-h: 64px;
  --font-body: 'Outfit', sans-serif;
  --font-jp:   'Noto Serif JP', serif;

  --transition: 0.22s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background-color: var(--bg-0);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

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

button { cursor: pointer; font-family: inherit; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(8, 12, 16, 0.85);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  z-index: 1050;
}

/* ── Logo ── */
.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo-svg { height: 48px; width: auto; }
.logo-svg .main-text { fill: var(--text-primary); font-family: var(--font-body); }
.logo-svg .ext-text  { fill: var(--accent); }
.logo-svg .subtext   { fill: var(--text-muted); font-family: var(--font-jp); }
.logo-svg text { transition: fill var(--transition); }

/* ── Nav ── */
.main-nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.nav-item {
  position: relative;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.nav-item:hover { color: var(--text-primary); background: var(--bg-3); }

.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Search ── */
.search-form {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

#searchInput {
  background: var(--bg-2);
  color: var(--text-primary);
  border: 1px solid var(--bg-4);
  border-radius: 999px;
  padding: 7px 16px 7px 38px;
  font-size: 0.875rem;
  font-family: var(--font-body);
  width: 220px;
  transition: border-color var(--transition), box-shadow var(--transition), width var(--transition);
  outline: none;
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
  width: 280px;
}

#searchInput::placeholder { color: var(--text-muted); }

.search-icon-wrap {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
}

.btn-search, #search-toggle-btn {
  background: var(--bg-3);
  border: 1px solid var(--bg-4);
  color: var(--text-secondary);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all var(--transition);
}

.btn-search:hover, #search-toggle-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-0);
}

/* Mobile active search */
.search-form.mobile-search-active {
  position: absolute;
  left: 16px; right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-2);
  border: 1px solid var(--bg-4);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  z-index: 1100;
}

.search-form.mobile-search-active input {
  display: block !important;
  flex-grow: 1;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  border-bottom: 2px solid var(--accent);
  outline: none;
  animation: slideInSearch 0.3s forwards;
}

#search-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.search-form.mobile-search-active #search-toggle-btn { display: none; }
.search-form.mobile-search-active #search-close-btn { display: inline-flex; align-items: center; }

@keyframes slideInSearch {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Suggestions ── */
.suggestions-list {
  list-style: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--bg-2);
  border: 1px solid var(--bg-4);
  border-radius: var(--radius-md);
  z-index: 1200;
  overflow: hidden;
  box-shadow: var(--shadow-heavy);
}

.suggestions-list li {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 12px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--bg-3);
  transition: background var(--transition);
}

.suggestions-list li:last-child { border-bottom: none; }
.suggestions-list li:hover { background: var(--bg-3); }

.suggestions-list li img {
  width: 38px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* ── Hamburger button ── */
#hamburgerBtn {
  display: none;
  background: var(--bg-3);
  border: 1px solid var(--bg-4);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
}

#hamburgerBtn:hover { color: var(--text-primary); background: var(--bg-4); }

@media (max-width: 650px) {
  #hamburgerBtn { display: flex; }
  nav.main-nav   { display: none !important; }
}

/* ── Mobile dropdown ── */
#mobileDropdownMenu {
  position: absolute;
  top: calc(var(--topbar-h) + 8px);
  right: 16px;
  background: var(--bg-2);
  border: 1px solid var(--bg-4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-heavy);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  min-width: 180px;
  z-index: 1060;
}

#mobileDropdownMenu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

#mobileDropdownMenu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

#mobileDropdownMenu a:hover { background: var(--bg-3); color: var(--text-primary); }
#mobileDropdownMenu a.active { color: var(--accent); background: var(--accent-dim); }

/* ── Download badge ── */
#downloadBadge {
  position: absolute;
  top: 75px;
  left: 20px;
  background: var(--accent);
  color: var(--bg-0) !important;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 20px rgba(0, 217, 192, 0.4);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}

#downloadBadge:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 217, 192, 0.55);
  color: var(--bg-0) !important;
}

/* ── Layout container ── */
.layout-container {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: calc(var(--topbar-h) + 24px) 24px 80px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow-y: auto;
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 0 8px;
}

.sidebar-menu {
  list-style: none;
}

.sidebar-menu .anime-link {
  display: block;
  padding: 7px 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-menu .anime-link:hover {
  background: var(--bg-3);
  color: var(--text-primary);
}

/* ── Main content ── */
.main-content {
  flex: 1;
  min-width: 0;
}

/* ── Section title ── */
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 1.25rem;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Anime grid ── */
.anime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

/* ── Anime card ── */
.anime-card {
  position: relative;
  background: var(--bg-2);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.05);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: block;
  height: 100%;
}

.anime-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-card), 0 0 0 1px var(--accent);
  border-color: var(--accent);
}

.anime-card img.anime-image {
  width: 100%;
  height: 280px;
  object-fit: cover;
  display: block;
  transition: filter var(--transition);
}

.anime-card:hover img.anime-image { filter: brightness(0.7); }

.anime-title {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 28px 12px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, transparent 100%);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.anime-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.anime-card.show-options .anime-overlay { opacity: 1; pointer-events: auto; }
.anime-card.show-options img.anime-image { filter: blur(4px) brightness(0.4); }

.anime-overlay button {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  backdrop-filter: blur(6px);
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
}

.anime-overlay button:hover { background: var(--accent); border-color: var(--accent); color: var(--bg-0); transform: scale(1.04); }

@keyframes removeCard {
  to { opacity: 0; transform: scale(0.85) translateY(16px); }
}

.anime-card.removing { animation: removeCard 0.35s ease forwards; }

/* ── Pagination ── */
#pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 28px 0;
}

.pagination-btn {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--bg-4);
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.pagination-btn:hover { border-color: var(--accent); color: var(--accent); }
.pagination-btn.active { background: var(--accent); border-color: var(--accent); color: var(--bg-0); }
.pagination-btn.nav { border-color: var(--bg-4); color: var(--text-muted); }
.pagination-btn.nav:hover { background: var(--bg-3); color: var(--text-primary); }

/* ── Bottom bar ── */
.bottom-bar {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  height: 56px;
  background: rgba(13, 17, 23, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.bottom-bar.visible { transform: translateY(0); }

.bottom-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), transform var(--transition);
}

.bottom-btn:hover { color: var(--accent); transform: scale(1.15); }

/* ── Offline overlay ── */
#offlineOverlay {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  text-align: center;
  padding: 2rem;
  gap: 16px;
}

#offlineOverlay h2 { font-size: 1.5rem; font-weight: 700; }
#offlineOverlay p  { color: var(--text-secondary); font-size: 0.95rem; }
#offlineOverlay.hidden { display: none; }

/* ── Overlays / Modals policy ── */
.policy-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(12px);
}

.policy-modal {
  width: 92vw;
  max-width: 820px;
  height: 88vh;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-heavy);
}

.policy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.policy-iframe { flex: 1; border: none; width: 100%; }

.policy-footer {
  padding: 14px 20px;
  background: var(--bg-2);
  border-top: 1px solid rgba(255,255,255,0.07);
}

/* Ads overlay */
#adsOverlay.policy-overlay {
  background: rgba(0,0,0,0.8);
  z-index: 9999;
}

#adsOverlay .policy-modal {
  max-width: 460px;
  height: auto;
  padding: 2rem;
  text-align: center;
  border-radius: var(--radius-xl);
}

/* ── Menu overlay ── */
#menuOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  backdrop-filter: blur(12px);
}

#menuOverlay.show { opacity: 1; transform: scale(1); pointer-events: auto; }

#menuOverlay .policy-modal {
  max-width: 420px;
  width: 92vw;
  height: auto;
  border-radius: var(--radius-xl);
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 16px;
  padding: 20px;
  justify-items: center;
}

.menu-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--accent);
  font-size: 1.4rem;
  border: 1px solid var(--bg-4);
  cursor: pointer;
  transition: all var(--transition);
}

.menu-circle:hover { background: var(--accent-dim); border-color: var(--accent); transform: scale(1.06); }

.menu-text {
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
  text-align: center;
}

/* ── Continue watching modal ── */
#continueWatchingModal { backdrop-filter: blur(8px); }

.modal-title-S {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}
ol,
ul {
  padding-left:5.5px !important;
}
/* ── Fix búsqueda móvil ── */
.search-form {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-form.mobile-search-active {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--bg-4);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1200;
  transform: none;
}

.search-form.mobile-search-active input {
  display: block !important;
  flex: 1;
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--bg-4);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-body);
  outline: none;
  animation: none;
}

.search-form.mobile-search-active input:focus {
  border-color: var(--accent);
}

.search-form.mobile-search-active input::placeholder {
  color: var(--text-muted);
}

.search-form.mobile-search-active #search-toggle-btn {
  display: none;
}

.search-form.mobile-search-active #search-close-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  border: 1px solid var(--bg-4);
  color: var(--text-secondary);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 0.9rem;
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--transition);
}

.search-form.mobile-search-active #search-close-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-0);
}
/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .layout-container { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 576px) {
  .layout-container { gap: 0; }
  .anime-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .anime-card img.anime-image { height: 230px; }
  .topbar { padding: 0 12px; gap: 12px; }
  #downloadBadge { font-size: 0.75rem; padding: 7px 12px; }
}

@media (max-width: 400px) {
  .anime-grid { grid-template-columns: repeat(2, 1fr); }
}
