/* ========= Global Theme (Elegant) ========= */
:root{
  --radius: 12px;
  --shadow-sm: 0 4px 12px rgba(0,0,0,.10);
  --shadow: 0 10px 30px rgba(0,0,0,.18);
  --footer-h: 56px; /* di-sync via JS */
  --footer-pad: calc(var(--footer-h) + env(safe-area-inset-bottom, 0px));
  --on-accent: #0b0f12; /* default fallback untuk teks di atas aksen */
}

/* DARK */
html[data-theme="dark"]{
  --bg:#0e1014;
  --text:#e7e9ee;
  --muted:#99a3b0;
  --card:#151922;
  --border:#2a2f36;
  --accent:#00eacb;
  --accent-contrast:#032a25;
  --on-accent:#0b0f12;
  --chip: rgba(255,255,255,.06);
}

/* LIGHT */
html[data-theme="light"]{
  --bg:#f7f9fb;
  --text:#0f172a;
  --muted:#64748b;
  --card:#ffffff;
  --border:#e5e7eb;
  --accent:#00eacb;           /* sama dengan dark */
  --accent-contrast:#065f57;
  --on-accent:#0b0f12;
  --chip: rgba(0,0,0,.06);
}

/* Base */
html, body { background: var(--bg); color: var(--text); }
#app { background: var(--bg); color: var(--text); min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .9; }

/* Cards & containers */
.card, .manga-card, .chapter-card, .detail-card, .tab, .panel, .box, .horizontal-scroll .item {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* Buttons */
button, .btn, .primary-btn {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}
.primary-btn, button.primary-btn {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
}

/* Chips / tags */
.badge, .chip {
  background: var(--chip);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}

/* Inputs */
input[type="search"], input[type="text"], select {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  height: 40px;
  padding: 0 12px;
}

/* Sections & titles */
h1,h2,h3 { color: var(--text); }
.section-title { font-weight: 700; margin: 8px 0; line-height: 1.3; }
.section-title.sm { font-size: 1rem; }
@media (min-width: 768px){ .section-title.sm { font-size: 1.125rem; } }

/* ===== Footer / Bottom Nav ===== */
.footer {
  height: var(--footer-h);
  position: fixed;
  bottom: 0; left: 0; right: 0;
  width: 100%;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 12px 12px;
  z-index: 9999;
  padding-bottom: env(safe-area-inset-bottom);
}
.footer a,
.footer a:visited,
.footer button{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 10px;
  font-weight: 700;
  text-decoration: none;
  border: 0;
  background: none;
  color: var(--accent);
}

/* legacy support */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  width: 100%; height: var(--footer-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  z-index: 9999;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-link { color: var(--accent); font-size: 14px; }

/* === Visibility safeguards (non reading-mode) === */
body:not(.reading-mode) .footer {
  height: var(--footer-h); display: flex !important; padding-bottom: env(safe-area-inset-bottom);
}
body:not(.reading-mode) .bottom-nav {
  height: var(--footer-h); display: flex !important; padding-bottom: env(safe-area-inset-bottom);
}
body:not(.reading-mode) #mini-footer { display: flex !important; }
body:not(.reading-mode) footer:not(.footer) { display: block !important; }

/* === FINAL GUARD: cegah konten ketutup footer === */
body:not(.reading-mode){ padding-bottom: 0 !important; }
body:not(.reading-mode) #app{ padding-bottom: var(--footer-pad) !important; }

html.scrolls-app body:not(.reading-mode) #app::after{
  content: "";
  display: block;
  height: var(--footer-pad);
}

/* Sedikit napas di atas footer */
.detail-manga,
#tab-content,
.manga-list,
.related-vertical-list,
.chapter-list {
  padding-bottom: 12px;
}

/* Reading mode */
body.reading-mode .app-header,
body.reading-mode .bottom-nav,
body.reading-mode .footer,
body.reading-mode #mini-footer,
body.reading-mode footer { display: none !important; }
body.reading-mode { padding-bottom: 0 !important; }

/* ====== Home: Riwayat Baca ====== */
.home-history-list .history-row:hover { filter: brightness(0.98); }
.home-history-list .history-row:active { transform: scale(0.995); transition: transform .08s ease; }
@media (min-width: 768px) {
  .home-history-list .history-row img { width: 64px; height: 92px; }
  .home-history-list .history-row .title { font-size: 1.05rem; }
}

/* ===== OVERRIDES BERBASIS AKSEN ===== */
.sort-btn,
.tab-btn.active,
.tab-btn[aria-selected="true"],
.read-btn{
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* Spacer universal anti-ketutup footer */
.footer-spacer{
  height: var(--footer-pad);
  pointer-events: none;
}

/* Tab/content breathing on mobile */
@media (max-width: 768px){
  #tab-content { padding-bottom: var(--footer-pad); }
  .related-vertical-list { margin-bottom: var(--footer-pad); }
  .chapter-list { margin-bottom: var(--footer-pad); }
}

/* Motion preference */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
