/* =========================
   Google Fonts Import
   ========================= */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@500;600&family=Poppins:wght@700&display=swap');
/* =========================
   Theme Variables
   ========================= */
:root {
  --bg: #0b1220;
  --panel: #0f1629;
  --border: #1e2a45;
  --text: #e6e9ef;
  --muted: #a9b1c3;
  --primary: #6ee7ff;
  --accent: #fbbf24;
  --success: #a3e635;
  --danger: #ef4444;
  --paused: #f472b6;
  --planning: #fbbf24;
  --font-button: 'Inter', sans-serif;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* =========================
   Reset / Base
   ========================= */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Poppins", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
.container { width: 100%; max-width: 640px; margin: 0 auto; padding: 12px; }

/* Utility (used by JS sometimes) */
.hidden { display: none !important; }

/* =========================
   Header (Sticky App Bar)
   ========================= */
.header {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px;
  background: rgba(15,22,41,.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.logo {
  font-family: "Poppins", sans-serif;
  font-size: 18px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  color: var(--primary); letter-spacing: 0.5px;
}
.header-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  display: grid; place-items: center;
  font-size: 16px;
  transition: transform .15s ease, filter .15s ease;
}
.icon-btn:active { transform: scale(.95); filter: brightness(1.2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  overflow: hidden; border: 1px solid var(--border);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* =========================
   Profile Menu (Dropdown)
   ========================= */
.profile-menu {
  position: absolute;
  right: 12px;
  top: 66px;
  width: calc(100vw - 24px);
  max-width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  animation: fadeIn .25s ease;
  overflow: hidden;
}
.profile-menu.active { display: flex; }

/* Profile Menu Header: avatar left, name/email right */
.profile-menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px dashed var(--border);
}
.profile-menu-header .avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.profile-menu-header .avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-menu-header .profile-text {
  display: flex; flex-direction: column; justify-content: center;
}
.profile-menu-header #username {
  font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap;
}
.profile-menu-header #userEmail {
  font-size: 12px; color: var(--muted); white-space: nowrap;
}

/* Buttons inside dropdown */
.profile-menu a {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  margin: 8px 12px;
  text-decoration: none;
  transition: transform .12s ease, filter .12s ease, background .12s ease, color .12s ease;
}
.profile-menu a:active { transform: scale(.97); filter: brightness(1.1); }
.profile-menu a i { font-size: 15px; }

/* Login (primary) */
#loginAniList {
  background: var(--primary);
  color: #0b1220;
  border: 1px solid var(--primary);
  box-shadow: 0 4px 12px rgba(110,231,255,.25);
}
#loginAniList i { color: #0b1220; }
#loginAniList:active { filter: brightness(0.95); }

/* Logout (danger) */
#logoutAniList {
  background: rgba(239,68,68,.1);
  color: var(--danger);
  border: 1px solid var(--danger);
}
#logoutAniList i { color: var(--danger); }
#logoutAniList:active { background: var(--danger); color: #fff; }

/* =========================
   Section Headers
   ========================= */
.section-header { margin: 12px 0 8px; }
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  padding-left: 4px;
}

/* =========================
   Stats Bar
   ========================= */
.stats {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 10px;
  margin: 12px 0;
}
.stat-card {
  display: flex; gap: 10px; align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.stat-card:active {
  transform: scale(.98);
  box-shadow: 0 4px 16px rgba(110,231,255,.15);
  filter: brightness(1.05);
}
.stat-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: #111a31;
  border: 1px solid var(--border);
  font-size: 16px;
}
.stat-title { font-size: 11px; color: var(--muted); }
.stat-value { font-weight: 700; font-size: 15px; }

/* =========================
   Filters
   ========================= */
.filter-bar {
  position: sticky; top: 56px; z-index: 20;
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 8px 0;
  background: var(--bg);
}
.filter-btn {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font-family: var(--font-button);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  min-width: 40px;
  text-align: center;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: transform .12s ease, filter .12s ease, border-color .12s ease;
}
.filter-btn:active { transform: scale(.96); filter: brightness(1.08); }
.filter-btn.active { border-color: var(--primary); background: rgba(110,231,255,0.08); color: var(--primary); box-shadow: 0 0 10px rgba(110,231,255,0.25); }

/* =========================
   Search Modal
   ========================= */
.search-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.7);
  display: none; justify-content: center; align-items: flex-start;
}
.search-modal.active { display: flex; }
.search-modal-content {
  margin-top: 20px; width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0 0 16px 16px;
  padding: 8px;
  display: flex; gap: 8px;
  animation: fadeIn .2s ease;
}
#searchInput {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1429;
  color: var(--text);
  outline: none;
}
#searchInput:focus { border-color: var(--primary); }

/* =========================
   Anime Cards Grid
   ========================= */
.search-results {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 10px;
}
.anime-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  overflow: hidden;
  min-height: 300px;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.anime-card:active {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 6px 20px rgba(110,231,255,.15);
  filter: brightness(1.03);
}
.anime-image {
  width: 100%;
  height: 200px;
  background: #0b1429;
  overflow: hidden;
}
.anime-image img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.anime-content {
  padding: 10px;
  display: flex; flex-direction: column;
  flex: 1;
}
.anime-title {
  font-size: 14px; font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 20px;
  margin-bottom: 4px;
}
.anime-meta {
  font-size: 12px; color: var(--muted);
  display: flex; justify-content: space-between;
  margin-bottom: 4px;
  min-height: 16px;
}

/* =========================
   Badge Styles (Cool Pills)
   ========================= */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 9px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
  text-align: center;
  width: fit-content;
  align-self: flex-start;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.badge:active { transform: scale(.98); filter: brightness(1.05); }
.badge-current {
  color: #6ee7ff;
  border-color: #6ee7ff;
  background: rgba(110,231,255,0.08);
  box-shadow: 0 0 8px rgba(110,231,255,0.25);
}
.badge-completed {
  color: #a3e635;
  border-color: #a3e635;
  background: rgba(163,230,53,0.08);
  box-shadow: 0 0 8px rgba(163,230,53,0.25);
}
.badge-planning {
  color: #fbbf24;
  border-color: #fbbf24;
  background: rgba(251,191,36,0.08);
  box-shadow: 0 0 8px rgba(251,191,36,0.25);
}
.badge-paused {
  color: #f472b6;
  border-color: #f472b6;
  background: rgba(244,114,182,0.08);
  box-shadow: 0 0 8px rgba(244,114,182,0.25);
}
.badge-dropped {
  color: #ef4444;
  border-color: #ef4444;
  background: rgba(239,68,68,0.08);
  box-shadow: 0 0 8px rgba(239,68,68,0.25);
}

.anime-actions {
  display: flex; gap: 6px;
  margin-top: auto;
}
.anime-actions button {
  flex: 1;
  padding: 6px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #101933;
  color: var(--text);
  font-weight: 600;
  transition: transform .12s ease, filter .12s ease, background .12s ease, color .12s ease;
}
.anime-actions button:active {
  transform: scale(.98);
  background: var(--primary);
  color: #0b1220;
}

/* =========================
   Modal (Anime Detail)
   ========================= */
.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.6);
  display: none; justify-content: center; align-items: stretch;
}
.modal.active { display: flex; }
.modal-content {
  width: 100%; height: 100dvh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  display: flex; flex-direction: column;
}
.modal-header {
  padding: 12px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.postcard-grid {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px; display: flex; flex-direction: column; gap: 12px;
}
.cover img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* Anime info labels */
#modalGenres::before { content: "Genre: "; font-weight: 600; color: var(--muted); }
#modalFormat::before { content: "Type: "; font-weight: 600; color: var(--muted); }
#modalEpisodes::before { content: "Episodes: "; font-weight: 600; color: var(--muted); }
#modalGenres, #modalFormat, #modalEpisodes {
  margin: 4px 0; font-size: 14px; color: var(--text);
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group input, .form-group select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1429;
  color: var(--text);
}
.actions { display: flex; gap: 10px; margin-top: 10px; }
.save-btn, #animeModal .delete-btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  letter-spacing: .3px;
  transition: transform .12s ease, filter .12s ease, background .12s ease, color .12s ease, border-color .12s ease;
}
.save-btn {
  border: 1px solid var(--primary);
  background: rgba(110,231,255,.12);
  color: var(--primary);
}
.save-btn:active {
  transform: scale(.98);
  background: var(--primary);
  color: #0b1220;
}
#animeModal .delete-btn {
  border: 1px solid var(--danger);
  background: rgba(239,68,68,.1);
  color: var(--danger);
}
#animeModal .delete-btn:active {
  transform: scale(.98);
  background: var(--danger);
  color: #fff;
}
.description {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.4;
  background: #0c1426;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-top: 6px;
}

/* =========================
   Loading + Empty States
   ========================= */
.loading {
  grid-column: 1 / -1;
  display: flex; gap: 10px;
  align-items: center; justify-content: center;
  padding: 16px;
  color: var(--muted);
}
.loading .spinner {
  width: 22px; height: 22px;
  border: 3px solid #222c44;
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { 0%{transform:rotate(0deg);} 100%{transform:rotate(360deg);} }
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #0c1426;
  color: var(--muted);
}

/* =========================
   Toast Notification
   ========================= */
.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: .25s;
  z-index: 300;
}
.toast.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(-6px); }

/* =========================
   Remove Confirmation Modal
   ========================= */
.remove-modal {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(0,0,0,0.6);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.remove-modal.active { display: flex; }
.remove-modal-content {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: fadeIn .25s ease;
  box-shadow: var(--shadow);
}
.remove-modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  color: var(--text);
  font-size: 16px;
  text-align: center;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.remove-modal-body {
  padding: 16px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.remove-modal-actions {
  display: flex;
  gap: 10px;
  padding: 12px 16px 16px;
}
.remove-modal-actions .remove-confirm-btn,
.remove-modal-actions .remove-cancel-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, background .12s ease, color .12s ease, border-color .12s ease;
}
.remove-modal-actions .remove-confirm-btn {
  border: 1px solid var(--danger);
  background: rgba(239,68,68,.1);
  color: var(--danger);
}
.remove-modal-actions .remove-confirm-btn:active {
  transform: scale(.98);
  background: var(--danger);
  color: #fff;
}
.remove-modal-actions .remove-cancel-btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
}
.remove-modal-actions .remove-cancel-btn:active {
  transform: scale(.98);
  filter: brightness(1.1);
}
/* Add Button */
.add-btn {
  font-family: "Poppins", sans-serif;
  color: #fff;
}
/* Edit Button */
.anime-card .edit-btn {
  font-family: "Poppins", sans-serif;
  color: #FFD700;
}
/* Delete Button (inside cards only) */
.anime-card .delete-btn {
  font-family: "Poppins", sans-serif;
  color: #e74c3c;
}
/* =========================
   Compact Professional Pagination
   ========================= */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px; /* fixed spacing between buttons */
  margin: 18px 0;
  user-select: none;
}
.pagination-btn,
.pagination-info {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 36px;  /* fixed width */
  height: 36px; /* fixed height */
  min-width: 36px;
  border-radius: 6px;
  font-family: "Inter", "Poppins", sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  color: #fff; /* white font */
  background: #2f3640; /* grey background */
  border: 1px solid #444; /* subtle border */
  box-sizing: border-box;
  transition: all 0.15s ease;
}
.pagination-btn {
  cursor: pointer;
  background: #2f3640;
  border: 1px solid #444;
}
.pagination-btn:hover {
  background: #444;
}
.pagination-btn:active {
  background: #555;
  transform: scale(0.95);
}
.pagination-btn:disabled {
  opacity: 0.3;
  cursor: default;
  background: #2f3640;
  border-color: #444;
}
.pagination-info {
  background: #3b3f50; /* slightly different grey for info */
  color: #fff;
  pointer-events: none;
  width: auto;
  min-width: 36px;
  padding: 0 8px;
  border-radius: 6px;
}
/* =========================
   Animations / Motion
   ========================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}