/* ─── Hyperion – Global Stylesheet ────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&display=swap');

:root {
  --bg:          #0e0e12;
  --bg-card:     #18181f;
  --bg-surface:  #222230;
  --bg-input:    #16161c;
  --accent:      #5b9cf6;
  --accent-dim:  #3a7dd4;
  --accent-glow: rgba(91,156,246,0.12);
  --text:        #e8e8ee;
  --text-sub:    #999aaa;
  --text-dim:    #666677;
  --border:      rgba(255,255,255,0.08);
  --border-hi:   rgba(91,156,246,0.4);
  --radius:      10px;
  --radius-lg:   14px;
  --shadow:      0 4px 24px rgba(0,0,0,0.5);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.4);
  --font:        'Rajdhani', -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --transition:  0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }

button, .btn {
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #7ab4fa; transform: translateY(-1px); }
.btn-primary:active { transform: none; }
.btn-ghost { background: transparent; color: var(--text-sub); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #e74c3c; }

/* ─── Navigation ──────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(26,26,31,0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 24px rgba(91,156,246,0.07);
  padding: 0 24px; height: 60px;
  display: flex; align-items: center; gap: 24px;
}
.nav::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(91,156,246,0.5) 10%,
    rgba(147,197,253,0.9) 35%,
    rgba(172,216,255,1) 50%,
    rgba(147,197,253,0.9) 65%,
    rgba(91,156,246,0.5) 90%,
    transparent 100%
  );
}
.nav-logo { font-size: 22px; font-weight: 800; color: #ffffff; letter-spacing: -0.5px; text-decoration: none; flex-shrink: 0; }
.nav-links { display: flex; gap: 6px; }
.nav-links a { color: var(--text-sub); padding: 7px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; letter-spacing: 0.2px; transition: color var(--transition), background var(--transition), box-shadow var(--transition); }
.nav-links a:hover { color: var(--text); background: var(--bg-surface); text-decoration: none; }
.nav-links a.active { color: #fff; background: var(--accent); box-shadow: 0 0 12px rgba(91,156,246,0.35); text-decoration: none; }

/* ─── Nav search ──────────────────────────────────────────────────────────── */
.nav-search-wrap { flex: 1; display: flex; justify-content: center; padding: 0 16px; }
.nav-search-box { position: relative; width: 100%; max-width: 380px; }
.nav-search-box input {
  width: 100%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px; color: var(--text); font-family: var(--font); font-size: 14px;
  padding: 8px 36px 8px 16px; outline: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.nav-search-box input:focus {
  border-color: var(--accent); background: rgba(91,156,246,0.07);
  box-shadow: 0 0 0 3px rgba(91,156,246,0.15);
}
.nav-search-box input::placeholder { color: var(--text-dim); }
.nav-search-box .search-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-size: 15px; pointer-events: none; }
.nav-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.nav-user { font-size: 13px; color: var(--text-sub); }
.nav-user strong { color: var(--text); }

/* ─── Page structure ──────────────────────────────────────────────────────── */
.page { max-width: 1400px; margin: 0 auto; padding: 32px 24px 80px; }
.section-title {
  font-size: 22px; font-weight: 700; margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); margin-left: 8px; }

/* ─── Login ────────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 60% 40%, rgba(91,156,246,0.07) 0%, transparent 60%), var(--bg);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 48px 40px; box-shadow: var(--shadow);
}
.login-logo { font-size: 36px; font-weight: 900; color: #ffffff; letter-spacing: -1px; margin-bottom: 4px; }
.login-tagline { color: var(--text-sub); font-size: 14px; margin-bottom: 40px; }
.login-form label { display: block; font-size: 13px; font-weight: 600; color: var(--text-sub); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.login-form input[type="email"] {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-family: var(--font);
  font-size: 15px; padding: 12px 16px; margin-bottom: 16px; outline: none;
  transition: border-color var(--transition);
}
.login-form input[type="email"]:focus { border-color: var(--accent); }
.login-form .btn-primary { width: 100%; padding: 13px; font-size: 15px; }
.login-status { margin-top: 16px; font-size: 14px; text-align: center; min-height: 20px; color: var(--text-sub); }
.login-status.success { color: #2ecc71; }
.login-status.error   { color: #e74c3c; }

/* ─── Library toolbar ─────────────────────────────────────────────────────── */
.library-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; flex-wrap: wrap; }
.lib-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-tab {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text-sub); padding: 6px 14px;
  font-size: 13px; font-weight: 500; cursor: pointer; transition: all var(--transition);
}
.lib-tab:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.lib-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.toolbar-spacer { flex: 1; }
.search-box { position: relative; flex-shrink: 0; }
.search-box input {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: var(--font); font-size: 14px;
  padding: 8px 36px 8px 14px; width: 240px; outline: none; transition: border-color var(--transition);
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-dim); }
.search-icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-size: 16px; pointer-events: none; }
.genre-filter {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: var(--font); font-size: 14px; padding: 8px 12px; outline: none; cursor: pointer;
}

/* ─── Title grid ──────────────────────────────────────────────────────────── */
.title-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.title-card {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-card); cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.title-card:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 0 0 2px var(--accent), 0 12px 32px rgba(91,156,246,0.25); z-index: 1; }
.title-card .poster { width: 100%; aspect-ratio: 2/3; object-fit: cover; background: var(--bg-surface); display: block; }
.poster-placeholder {
  width: 100%; aspect-ratio: 2/3; background: var(--bg-surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; gap: 8px; text-align: center;
}
.poster-placeholder .icon { font-size: 32px; color: var(--text-dim); }
.poster-placeholder .ptitle { font-size: 13px; font-weight: 600; color: var(--text-sub); line-height: 1.3; }
.poster-placeholder .pyear  { font-size: 11px; color: var(--text-dim); }
.title-card .card-info { padding: 10px 10px 12px; }
.card-info .ctitle { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.card-info .cmeta  { font-size: 11px; color: var(--text-dim); }
.watched-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(46,204,113,0.9); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 4px; backdrop-filter: blur(4px);
}
.title-card:hover .card-hover { opacity: 1; }
.card-hover {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.88) 0%, rgba(0,0,0,0.2) 60%, transparent 100%);
  opacity: 0; transition: opacity var(--transition);
  display: flex; flex-direction: column; justify-content: flex-end; padding: 12px;
}
.card-hover .hover-title { font-size: 13px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.card-hover .hover-genre { font-size: 11px; color: #ccc; }
.card-hover .hover-actions { display: flex; gap: 6px; margin-top: 8px; }
.hover-btn {
  flex: 1; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25);
  color: #fff; font-size: 11px; font-weight: 600; padding: 5px; border-radius: 5px;
  text-align: center; cursor: pointer; transition: background var(--transition);
}
.hover-btn:hover { background: rgba(91,156,246,0.7); border-color: var(--accent); }
.hover-btn.watched-on { background: rgba(46,204,113,0.5); border-color: #2ecc71; }

/* ─── Recently Added strip ────────────────────────────────────────────────── */
.recently-strip {
  display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 40px;
  scrollbar-width: thin; scrollbar-color: var(--bg-surface) transparent;
}
.recently-strip::-webkit-scrollbar { height: 4px; }
.recently-strip::-webkit-scrollbar-thumb { background: var(--bg-surface); border-radius: 2px; }
.recent-card { flex-shrink: 0; width: 130px; border-radius: var(--radius); overflow: hidden; background: var(--bg-card); position: relative; }
.recent-card .new-badge {
  position: absolute; top: 6px; left: 6px; background: var(--accent); color: #111;
  font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px;
}
.recent-card .recent-title { padding: 8px 8px 10px; font-size: 11px; font-weight: 600; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Pagination ──────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 40px; flex-wrap: wrap; }
.pagination button { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-sub); padding: 7px 14px; border-radius: 6px; font-size: 13px; }
.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination button.active { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }
.pagination .page-info { font-size: 13px; color: var(--text-dim); }

/* ─── Modal ─────────────────────────────────────────────────────────────────  */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: rgba(10,10,18,0.58); border: 1px solid rgba(91,156,246,0.22); border-radius: var(--radius-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow), 0 0 0 1px rgba(91,156,246,0.08);
  backdrop-filter: blur(36px) saturate(1.8);
  -webkit-backdrop-filter: blur(36px) saturate(1.8);
  transform: translateY(20px); transition: transform var(--transition), box-shadow var(--transition);
}
.modal-overlay.open .modal { transform: none; box-shadow: var(--shadow), 0 0 0 2px rgba(91,156,246,0.35), 0 0 48px rgba(91,156,246,0.12); }
.modal-header { padding: 24px 28px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 24px; cursor: pointer; padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 28px 28px; font-size: 14px; line-height: 1.6; }

/* ─── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-sub); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-family: var(--font);
  font-size: 14px; padding: 10px 14px; outline: none; transition: border-color var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ─── Admin ────────────────────────────────────────────────────────────────── */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 36px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .stat-value { font-size: 36px; font-weight: 800; color: var(--accent); line-height: 1; margin-bottom: 6px; }
.stat-card .stat-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-sub { font-size: 11px; color: var(--text-dim); margin-top: 6px; }
.requests-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.requests-table th { text-align: left; padding: 10px 14px; color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); font-weight: 600; }
.requests-table td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
.requests-table tr:hover td { background: var(--accent-glow); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-pending        { background: rgba(91,156,246,0.2);  color: var(--accent); }
.badge-fulfilled      { background: rgba(46,204,113,0.2);  color: #2ecc71; }
.badge-cancelled      { background: rgba(255,255,255,0.1); color: var(--text-dim); }
.badge-clarify        { background: rgba(231,76,60,0.2);   color: #e74c3c; }
.badge-clarify-sent   { background: rgba(52,152,219,0.2);  color: #3498db; }
.priority-high   { color: #e74c3c; }
.priority-medium { color: #f5a623; }
.priority-low    { color: var(--text-sub); }
.age-label { font-size: 12px; color: var(--text-dim); }
.age-old   { color: #e74c3c; }

/* ─── Loading / empty states ─────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 80px 20px; color: var(--text-dim); gap: 12px; }
.spinner { width: 24px; height: 24px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-dim); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg-surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 16px; font-size: 14px; color: var(--text); box-shadow: var(--shadow); animation: slideIn 0.2s ease; max-width: 320px; }
.toast.toast-success { border-left-color: #2ecc71; }
.toast.toast-error   { border-left-color: #e74c3c; }
.toast.toast-warning { border-left-color: #f39c12; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── Alpha jump bar ─────────────────────────────────────────────────────── */
#alpha-bar {
  position: fixed;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  z-index: 200; user-select: none;
  background: rgba(14,14,22,0.55); backdrop-filter: blur(8px);
  border-radius: 10px; padding: 6px 2px;
  border: 1px solid rgba(255,255,255,0.07);
}
.alpha-letter {
  font-size: 13px; font-weight: 700; line-height: 1;
  padding: 3px 9px; border-radius: 4px; cursor: pointer;
  color: var(--text-sub); transition: color 0.12s, background 0.12s;
  letter-spacing: 0; min-width: 24px; text-align: center;
}
.alpha-letter:hover { color: var(--text); background: rgba(255,255,255,0.1); }
.alpha-letter.active { color: var(--accent); background: var(--accent-glow); }
@media (max-width: 900px) { #alpha-bar { display: none; } }

/* ─── Search autocomplete dropdown ───────────────────────────────────────── */
#search-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  z-index: 9999;
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}
#search-suggestions.open { display: block; }
.suggest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background: rgba(91,156,246,0.12); }
.suggest-poster {
  width: 34px;
  height: 51px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-input);
  flex-shrink: 0;
}
.suggest-info { flex: 1; min-width: 0; }
.suggest-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggest-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.suggest-pick { color: var(--accent); font-weight: 700; margin-left: 4px; }
.suggest-footer {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  background: rgba(255,255,255,0.03);
  border-top: 1px solid var(--border);
}

/* ─── Bottom nav (mobile only) ───────────────────────────────────────────── */
.bottom-nav { display: none; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Nav */
  .nav { padding: 0 12px; gap: 10px; height: 54px; }
  .nav-links { display: none; }
  /* Logo: hide the image on mobile — clean white text only */
  .nav-logo img { display: none !important; }
  .nav-logo span { margin-left: 0 !important; color: #ffffff !important; }
  /* Hide Ko-fi button and username on mobile to save space */
  .nav-right .nav-user { display: none; }
  .nav-right a[href*="ko-fi"] { display: none !important; }
  /* Shrink search box in nav */
  .nav-search-wrap { padding: 0 4px; }

  /* Page */
  .page { padding: 20px 16px calc(74px + env(safe-area-inset-bottom)); }
  .title-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .search-box input { width: 180px; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-direction: column; }
  /* Library toolbar: tighter on mobile, scroll instead of wrap */
  .library-toolbar { margin-bottom: 12px; gap: 6px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .library-toolbar::-webkit-scrollbar { display: none; }
  .lib-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .lib-tabs::-webkit-scrollbar { display: none; }
  .genre-filter, .search-box input { flex-shrink: 0; }
  .search-box { flex-shrink: 0; }
  .toolbar-spacer { display: none; }
  .recently-strip { margin-bottom: 10px; }
  .lib-tab { padding: 4px 12px; font-size: 12px; border-radius: 16px; }
  .lib-tabs { gap: 6px; }
  .library-toolbar { gap: 6px; }

  /* Toast: move above bottom nav */
  #toast-container { bottom: calc(80px + env(safe-area-inset-bottom)); }

  /* Bottom nav */
  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(18, 18, 26, 0.97);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255,255,255,0.09);
    z-index: 300;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 1px; padding: 3px 0 4px; text-decoration: none;
    color: var(--text-dim); font-size: 9px; font-weight: 600;
    letter-spacing: 0.2px; transition: color 0.15s;
    user-select: none;
  }
  .bottom-nav-icon { font-size: 16px; line-height: 1; }
  .bottom-nav-label { font-size: 9px; }
  .bottom-nav-item.active { color: var(--accent); }
  .bottom-nav-item.disabled { opacity: 0.28; pointer-events: none; }
}
@media (max-width: 480px) {
  .title-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .lib-tab { padding: 4px 11px; font-size: 12px; }
}
