/* ==========================================================
   Senarai Tontonan - gaya minimalis
   ========================================================== */

:root,
[data-bs-theme="light"] {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --ink: #161a23;
  --muted: #6b7280;
  --line: #e1e4ea;
  --star: #f2a93b;
  --watched: #2f9e6b;
  --unwatched: #6b7280;
  --planned: #3b6fd4;
  --btn-ink-bg: #161a23;
  --btn-ink-fg: #ffffff;
  --shadow: 0 1px 2px rgba(22, 26, 35, .06), 0 6px 18px rgba(22, 26, 35, .06);
}

[data-bs-theme="dark"] {
  --bg: #101218;
  --surface: #181b23;
  --surface-2: #20242e;
  --ink: #eceef3;
  --muted: #9aa1b0;
  --line: #272b36;
  --star: #f5b54f;
  --watched: #45b886;
  --unwatched: #9aa1b0;
  --planned: #6e9bf0;
  --btn-ink-bg: #eceef3;
  --btn-ink-fg: #101218;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .25);
}

html, body { min-height: 100%; }

body {
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted);
}

/* ---------- Header ---------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ---------- Butang ---------- */
.btn { font-weight: 600; border-radius: .6rem; }

.btn-ink {
  background: var(--btn-ink-bg);
  color: var(--btn-ink-fg);
  border: 1px solid var(--btn-ink-bg);
}
.btn-ink:hover,
.btn-ink:focus-visible {
  background: var(--btn-ink-bg);
  color: var(--btn-ink-fg);
  opacity: .88;
}

.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }

.btn:focus-visible,
.tab:focus-visible,
.star-input button:focus-visible,
.form-control:focus,
.form-select:focus {
  outline: 2px solid var(--planned);
  outline-offset: 2px;
  box-shadow: none;
}

/* ---------- Borang ---------- */
.form-control,
.form-select,
.input-group-text {
  background-color: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  border-radius: .6rem;
}
.input-group > .form-control { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > .input-group-text { border-top-right-radius: 0; border-bottom-right-radius: 0; color: var(--muted); }
.form-label { font-weight: 600; font-size: .9rem; }

.modal-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
}

/* ---------- Tab status ---------- */
.status-tabs {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding-bottom: .25rem;
  scrollbar-width: none;
}
.status-tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .9rem;
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); background: var(--surface); }
.tab.active {
  background: var(--btn-ink-bg);
  color: var(--btn-ink-fg);
  border-color: var(--btn-ink-bg);
}
.tab .count {
  font-size: .78rem;
  font-weight: 700;
  min-width: 1.4rem;
  padding: .05rem .4rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
}
.tab.active .count { background: rgba(255, 255, 255, .2); color: inherit; }
[data-bs-theme="dark"] .tab.active .count { background: rgba(0, 0, 0, .15); }

/* ---------- Kad tajuk ---------- */
.title-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .9rem;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s, transform .2s;
}
.title-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--surface-2);
  overflow: hidden;
}
.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.status-badge {
  position: absolute;
  left: .5rem;
  top: .5rem;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .55rem;
  font-size: .75rem;
  font-weight: 600;
  color: #fff;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.status-badge.watched   { background: color-mix(in srgb, var(--watched) 92%, #000); }
.status-badge.unwatched { background: color-mix(in srgb, var(--unwatched) 88%, #000); }
.status-badge.planned   { background: color-mix(in srgb, var(--planned) 92%, #000); }

.card-body-lite {
  padding: .75rem .85rem .85rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  flex: 1;
}
.item-name {
  font-size: .98rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .6rem;
  font-size: .82rem;
  color: var(--muted);
}

.stars { color: var(--star); font-size: .9rem; letter-spacing: .08em; white-space: nowrap; }
.stars .off { color: var(--line); }
.stars.unrated { color: var(--muted); font-size: .8rem; letter-spacing: 0; }

.card-actions {
  margin-top: auto;
  padding-top: .5rem;
  display: flex;
  gap: .4rem;
}
.card-actions .btn {
  flex: 1;
  font-size: .82rem;
  padding: .35rem .5rem;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.card-actions .btn:hover { background: var(--surface-2); }
.card-actions .btn.danger:hover { color: #dc3545; border-color: #dc3545; background: transparent; }

/* ---------- Input bintang ---------- */
.star-input { display: inline-flex; gap: .15rem; }
.star-input button {
  background: none;
  border: 0;
  padding: .15rem;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--line);
  cursor: pointer;
  border-radius: .4rem;
  transition: transform .1s, color .1s;
}
.star-input button.on { color: var(--star); }
.star-input button:hover { transform: scale(1.12); }

/* ---------- Pratonton poster ---------- */
.poster-preview {
  width: 96px;
  aspect-ratio: 2 / 3;
  border-radius: .6rem;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.poster-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Keadaan kosong / memuat ---------- */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .75rem; opacity: .7; }
.empty-state h2 { font-size: 1.1rem; font-weight: 700; color: var(--ink); margin-bottom: .35rem; }
.empty-state p { margin-bottom: 1rem; }

.toast { color: #fff; border-radius: .7rem; }
.toast.success { background: var(--watched); }
.toast.error   { background: #c0392b; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .title-card:hover { transform: none; }
}

/* ==========================================================
   Pengurusan pengguna (log masuk, daftar, lupa kata laluan)
   ========================================================== */
.auth-body { min-height: 100vh; display: flex; }
.auth-wrap { margin: auto; width: 100%; max-width: 26rem; padding: 1.5rem 1rem; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.auth-brand { font-size: .95rem; font-weight: 700; color: var(--muted); margin: 0 0 1rem; }
.auth-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 .35rem; }
.auth-sub { color: var(--muted); margin-bottom: 1.25rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: .92rem; margin: 1.25rem 0 0; }
.auth-link { color: var(--ink); font-weight: 600; text-underline-offset: 3px; }
.auth-link:hover { color: var(--planned); }
.auth-card .form-text { color: var(--muted); }

/* Ruangan kata laluan + ikon mata */
.password-field { position: relative; }
.password-field .form-control { padding-right: 2.9rem; }
.toggle-pw {
  position: absolute;
  top: 0;
  right: 0;
  width: 2.9rem;
  height: 2.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: none;
  border: 0;
  border-radius: 0 .6rem .6rem 0;
  color: var(--muted);
  cursor: pointer;
}
.toggle-pw:hover { color: var(--ink); }
.toggle-pw:focus-visible { outline: 2px solid var(--planned); outline-offset: -2px; }

/* Elak ikon semak/silang Bootstrap bertindih dengan ikon mata */
.was-validated .password-field .form-control:invalid,
.was-validated .password-field .form-control:valid {
  background-image: none;
  padding-right: 2.9rem;
}

.dev-box {
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: .6rem;
  padding: .75rem;
  font-size: .85rem;
  word-break: break-all;
}

.user-chip {
  align-items: center;
  gap: .4rem;
  max-width: 11rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chip i { font-size: 1.1rem; }

/* ---------- Paparan Fullscreen Poster ---------- */
.poster img.clickable-poster {
  cursor: zoom-in;
  transition: transform 0.3s ease;
}

.poster img.clickable-poster:hover {
  transform: scale(1.05);
}

/* Background gelap sedikit untuk modal fullscreen */
#posterFullscreenModal .modal-backdrop {
  background-color: rgba(0, 0, 0, 0.9) !important;
}
