/* GateAnime Theme Mode v2 (Light/Dark)
   - Activated by adding `ga-dark` class to <html>.
   - Stores user choice in localStorage: gateanime_color_scheme => "dark"|"light"
   - Uses CSS variables for clean, modern overrides.
*/

:root{
  --ga-bg: #ffffff;
  --ga-surface: #f6f7f9;
  --ga-surface-2: #ffffff;
  --ga-text: #111827;
  --ga-muted: #6b7280;
  --ga-border: rgba(17,24,39,.12);
  --ga-shadow: 0 10px 30px rgba(0,0,0,.08);

  --ga-toggle-bg: rgba(255,255,255,.92);
  --ga-toggle-fg: #111827;
  --ga-toggle-br: rgba(17,24,39,.16);
}

html.ga-dark{
  --ga-bg: #0b0f14;
  --ga-surface: #0f1621;
  --ga-surface-2: #121b28;
  --ga-text: #e6edf3;
  --ga-muted: #9aa4b2;
  --ga-border: rgba(255,255,255,.12);
  --ga-shadow: 0 10px 30px rgba(0,0,0,.45);

  --ga-toggle-bg: rgba(18,27,40,.92);
  --ga-toggle-fg: #e6edf3;
  --ga-toggle-br: rgba(255,255,255,.16);

  color-scheme: dark;
}

/* Smooth but subtle transitions (avoid animating huge lists too aggressively). */
html, body{
  transition: background-color .18s ease, color .18s ease;
}

/* Base page */
html.ga-dark body{
  background: var(--ga-bg) !important;
  color: var(--ga-text) !important;
}
html.ga-dark hr{ border-color: var(--ga-border); }

/* Inputs */
html.ga-dark input,
html.ga-dark select,
html.ga-dark textarea{
  background-color: var(--ga-surface-2) !important;
  color: var(--ga-text) !important;
  border-color: var(--ga-border) !important;
}
html.ga-dark ::placeholder{ color: rgba(154,164,178,.75); }

/* Header / Nav / Footer surfaces
   IMPORTANT: do NOT target generic <header>/<footer> tags here.
   Single pages (movies/seasons/episodes) use <header>/<footer> inside the hero banner;
   styling them would create unwanted dark rectangles behind meta/info.
*/
html.ga-dark .Header,
html.ga-dark nav.Menu,
html.ga-dark .Menu{
  background-color: var(--ga-bg) !important;
  color: var(--ga-text) !important;
  border-color: var(--ga-border) !important;
}

/* Keep header inner bar (links) identical to header background */
html.ga-dark .Header .Top,
html.ga-dark .Header .Top * ,
html.ga-dark .Header nav,
html.ga-dark .Header nav * ,
html.ga-dark .Header .Menu,
html.ga-dark .Header .Menu *{
  background-color: transparent !important;
  background: transparent !important;
}

/* Common content surfaces */
html.ga-dark .Content,
html.ga-dark .Result,
html.ga-dark .SearchMovies,
html.ga-dark .TPlayer,
html.ga-dark .TPlayerTb{
  background-color: transparent !important;
  color: var(--ga-text) !important;
  border-color: var(--ga-border) !important;
}

/* Widgets/cards: keep them clean (no harsh black blocks) */
html.ga-dark .TPost,
html.ga-dark .TpMvCn,
html.ga-dark .TpBrCn,
html.ga-dark .widget,
html.ga-dark .Widget,
html.ga-dark .sidebar,
html.ga-dark .Side,
html.ga-dark .MovieList li{
  background-color: transparent !important;
  color: var(--ga-text) !important;
  border-color: var(--ga-border) !important;
  box-shadow: none !important;
}

/* Titles */
html.ga-dark .Title,
html.ga-dark .Title *{
  color: var(--ga-text) !important;
}
html.ga-dark .Title:before,
html.ga-dark .Title:after,
html.ga-dark .Title span:before,
html.ga-dark .Title span:after{
  background-color: rgba(255,255,255,.18) !important;
  border-color: rgba(255,255,255,.18) !important;
}

/* Single page meta badges: keep ORIGINAL theme styling (no dark overrides) */
/* Synopsis/description blocks */
html.ga-dark .TPost.Single .Description,
html.ga-dark .TPost.Single .Overview,
html.ga-dark .TPost.Single .Summary,
html.ga-dark .TPost.Single .Story{
  background-color: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  color: var(--ga-muted) !important;
}

/* Episodes table (season page): ensure titles are readable in dark mode */
html.ga-dark .MvTbTtl,
html.ga-dark .MvTbTtl a{
  color: var(--ga-text) !important;
}
html.ga-dark .MvTbTtl span,
html.ga-dark .MvTbTtl .Date{
  color: var(--ga-muted) !important;
}

/* =========================
   Modern toggle button
   ========================= */
.ga-theme-toggle{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--ga-toggle-br);
  background: var(--ga-toggle-bg);
  color: var(--ga-toggle-fg);
  cursor: pointer;
  margin-inline-start: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  transition: transform .12s ease, box-shadow .12s ease, background-color .18s ease, color .18s ease, border-color .18s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.ga-theme-toggle:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0,0,0,.12);
}
.ga-theme-toggle:active{
  transform: translateY(0);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}
.ga-theme-toggle:focus{
  outline: none;
}
.ga-theme-toggle:focus-visible{
  outline: 2px solid rgba(124,196,255,.6);
  outline-offset: 2px;
}

.ga-theme-toggle__icon{
  line-height: 1;
  font-size: 18px;
}
.ga-theme-toggle__icon--sun{ display: none; }
html.ga-dark .ga-theme-toggle__icon--moon{ display: none; }
html.ga-dark .ga-theme-toggle__icon--sun{ display: inline-block; }


/* =========================
   GateAnime Theme Mode v2.1 - Visual polish fixes
   - Remove dark blocks behind section titles, single meta, and footer widgets
   ========================= */

/* Homepage section headers: keep them floating on the page (no boxed background) */
html.ga-dark section > .Top,
html.ga-dark .Home section > .Top,
html.ga-dark .Top.Wdgt,
html.ga-dark .Top.Titles{
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
}

/* Some themes wrap the title bar in containers; keep them transparent */
html.ga-dark section > .Top *,
html.ga-dark .Home section > .Top *{
  background: transparent !important;
  box-shadow: none !important;
}

/* Single pages: keep original theme styling for meta/ratings/year/runtime (no forced transparency) */
/* Footer: make it fully dark and remove inner black rectangles */
html.ga-dark body > footer,
html.ga-dark footer.Footer,
html.ga-dark .Footer,
html.ga-dark body > footer .Container,
html.ga-dark footer.Footer .Container,
html.ga-dark .Footer .Container{
  background-color: #000000 !important;
  background: #000000 !important;
  color: var(--ga-text) !important;
  border-color: rgba(255,255,255,.10) !important;
}

html.ga-dark body > footer * ,
html.ga-dark footer.Footer * ,
html.ga-dark .Footer *{
  background: transparent !important;
  box-shadow: none !important;
}

/* Footer widgets/tags/categories list items */
html.ga-dark .Footer .widget,
html.ga-dark footer .widget,
html.ga-dark .Footer .Widget,
html.ga-dark footer .Widget,
html.ga-dark .Footer .Tag,
html.ga-dark .Footer .tag,
html.ga-dark .Footer .cat-item a,
html.ga-dark footer .cat-item a{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}


/* Footer categories/tags: ensure they don't get a different pill background */
html.ga-dark body > footer .cat-item a,
html.ga-dark footer.Footer .cat-item a,
html.ga-dark .Footer .cat-item a,
html.ga-dark body > footer .Tag,
html.ga-dark footer.Footer .Tag,
html.ga-dark .Footer .Tag,
html.ga-dark body > footer .tag,
html.ga-dark footer.Footer .tag,
html.ga-dark .Footer .tag{
  background-color: #000000 !important;
  background: #000000 !important;
  border-color: rgba(255,255,255,.12) !important;
}
/* If the theme uses a bottom bar */
html.ga-dark .FooterBtm,
html.ga-dark .FooterBottom,
html.ga-dark .copyright,
html.ga-dark .CopyRight{
  background: #000000 !important;
  border-color: rgba(255,255,255,.10) !important;
}


/* =========================================================
   Header actions (Search icon + Theme toggle)
   ========================================================= */
.ga-hdr-actions{
  display: flex;
  align-items: center;
  gap: 10px;
}
.ga-hdr-action{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--ga-toggle-br);
  background: var(--ga-toggle-bg);
  color: var(--ga-toggle-fg);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  transition: transform .12s ease, box-shadow .12s ease, background-color .18s ease, color .18s ease, border-color .18s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.ga-hdr-action:hover{ transform: translateY(-1px); box-shadow: 0 10px 22px rgba(0,0,0,.12); }
.ga-hdr-action:active{ transform: translateY(0); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.ga-hdr-search i{ font-size: 18px; line-height: 1; }

/* Remove old inline margin now that we use gap */
.ga-theme-toggle{ margin-inline-start: 0; }

/* Ensure perfect vertical alignment between <a> and <button> across mobile browsers */
.ga-hdr-actions > .ga-hdr-action,
.ga-hdr-actions > .ga-theme-toggle{
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1 !important;
  vertical-align: middle;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

/* =========================================================
   Footer "Back to top" visibility in dark mode
   ========================================================= */
html.ga-dark .Footer .ListSocial>li>a{
  color: rgba(255,255,255,.9) !important;
  opacity: .95;
}
html.ga-dark .Footer .ListSocial>li>a.Up{
  opacity: 1 !important;
}
html.ga-dark .Footer .ListSocial>li>a.Up:before,
html.ga-dark .Footer .ListSocial>li>a.Up i{
  color: rgba(255,255,255,.95) !important;
}

/* =========================================================
   Home: "عرض المزيد" button (white border in dark mode)
   ========================================================= */
html.ga-dark .GA-DiscoverMore{
  border: 1px solid rgba(255,255,255,.75) !important;
  background: rgba(255,255,255,.06) !important;
}
html.ga-dark .GA-DiscoverMore__text,
html.ga-dark .GA-DiscoverMore__icon{
  color: rgba(255,255,255,.92) !important;
}

/* =========================================================
   Discover template: Tabs + arrows visibility in dark mode
   ========================================================= */
html.ga-dark .GA-DiscoverTabs .Lnk{
  color: rgba(255,255,255,.9) !important;
  background: rgba(255,255,255,.08) !important;
  border: 1px solid rgba(255,255,255,.18) !important;
  border-radius: 14px;
}
html.ga-dark .GA-DiscoverTabs .Lnk.on{
  color: #0b1220 !important;
  background: rgba(255,255,255,.92) !important;
  border-color: rgba(255,255,255,.92) !important;
}
html.ga-dark .GA-DiscoverArrows button{
  color: rgba(255,255,255,.9) !important;
  background: rgba(255,255,255,.08) !important;
  border: 1px solid rgba(255,255,255,.18) !important;
  border-radius: 12px;
}
html.ga-dark .GA-DiscoverArrows button:hover{
  background: rgba(255,255,255,.14) !important;
}


/* =========================================================
   Header actions: align search + theme icons on same baseline
   ========================================================= */
.ga-hdr-action,
.ga-theme-toggle{
  vertical-align: middle;
  line-height: 1;
}
.ga-theme-toggle{
  padding: 0 !important;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--ga-toggle-br);
}

/* =========================================================
   Home sections: "View more" button (عرض المزيد) clearer in dark mode
   ========================================================= */
html.ga-dark .Button.STPb{
  border: 1px solid rgba(255,255,255,.85) !important;
  background: rgba(255,255,255,.06) !important;
  color: rgba(255,255,255,.92) !important;
}
html.ga-dark .Button.STPb:hover{
  background: rgba(255,255,255,.10) !important;
}


/* =========================================================
   Desktop header alignment: keep actions inline with nav
   ========================================================= */
@media screen and (min-width:62em){
  /* Ensure the right header block is a single flex row (nav + icons) */
  .Header .MnBr .Container .Rght.BgA{
    display:flex;
    align-items:center;
    gap:12px;
    flex-wrap:nowrap;
  }
  .Header .MnBr .Container .Rght.BgA > nav{
    flex: 1 1 auto;
    min-width: 0;
  }
  /* Keep our actions on the same line, next to the menu (RTL: near the logo) */
  .Header .MnBr .Container .Rght.BgA .ga-hdr-actions{
    flex: 0 0 auto;
    margin: 0;
  }
  /* Prevent the menu from forcing a new line */
  .Header .MnBr .Container .Rght.BgA nav.Menu{
    display:flex;
    align-items:center;
    flex-wrap:nowrap;
  }
  .Header .MnBr .Container .Rght.BgA nav.Menu > ul{
    display:flex;
    align-items:center;
    flex-wrap:nowrap;
    gap:0;
    margin:0;
  }
}


/* =========================================================
   Desktop header layout fix (menu right, icons left in same row)
   - Applies only on desktop widths
   ========================================================= */
@media screen and (min-width:62em){
  /* Force nav + icons to stay on a single row */
  .Header .MnBr .Container .Rght.BgA{
    display:flex !important;
    flex-direction: row-reverse !important; /* DOM: actions then nav => actions left, nav right */
    align-items:center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    flex-wrap: nowrap !important;
  }

  /* Neutralize legacy floats / widths that can cause stacking */
  .Header .MnBr .Container .Rght.BgA > .Search{
    float: none !important;
    width: auto !important;
    position: static !important;
    margin: 0 !important;
  }
  .Header .MnBr .Container .Rght.BgA > nav.Menu{
    float: none !important;
    width: auto !important;
    position: static !important;
    margin: 0 !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  /* Keep menu items on one line */
  .Header .MnBr .Container .Rght.BgA nav.Menu > ul{
    display:flex !important;
    align-items:center !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
  }

  /* Keep actions from wrapping / jumping */
  .Header .MnBr .Container .Rght.BgA .ga-hdr-actions{
    flex: 0 0 auto !important;
    white-space: nowrap !important;
  }
}


/* =========================================================
   Desktop-only helpers
   ========================================================= */
.ga-desktop-only{ display: none !important; }

@media (min-width: 992px){
  .ga-desktop-only{ display: inline-flex !important; }
}
