@font-face {
  font-family: 'Vinque';
  src: url('/fonts/vinque.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inconsolata', monospace;
  background: #0a0a0a;
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Loading Screen ── */
.loading-screen {
  position: fixed; inset: 0; z-index: 100;
  background: #0a0a0a;
  display: flex; justify-content: center; align-items: center;
  transition: opacity 0.6s ease;
}
.loading-screen.fade-out { opacity: 0; pointer-events: none; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(150, 80, 200, 0.2);
  border-top-color: #9b59b6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Video Background ── */
.bg-video {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.bg-overlay {
  position: fixed; inset: 0; z-index: 1;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

/* ── Video fallback (mobile autoplay blocked) ── */
/* When video.play() is rejected, JS hides the video and adds .video-fallback
   to body. The poster image then covers the background the same way the video
   did. The overlay and z-index stack are unchanged so the UI remains correct. */
body.video-fallback {
  background-image: url('/godafoss-poster.jpg');
  background-size: cover;
  background-position: center;
}

/* ── App Container ── */
.app {
  position: relative; z-index: 2;
  min-height: 100vh;
  display: flex; justify-content: center; align-items: center;
  opacity: 1;
}
.app.hidden { opacity: 0; pointer-events: none; }
.app.flash { animation: flash-in 0.5s ease-out; }
@keyframes flash-in {
  0% { opacity: 0; transform: scale(0.97); }
  50% { opacity: 1; }
  100% { opacity: 1; transform: scale(1); }
}

/* ── Center Box ── */
.center-box {
  text-align: center;
  max-width: 380px;
  width: 100%;
  padding: 20px;
}

/* ── Title ── */
.title {
  font-family: 'Vinque', Georgia, serif;
  font-weight: normal;
  font-size: 3.6rem;
  color: #c084fc;
  letter-spacing: 3px;
  margin-bottom: 36px;
  text-shadow: 0 0 40px rgba(192, 132, 252, 0.3), 0 2px 8px rgba(0,0,0,0.5);
}

/* ── Mode Switching ── */
.mode { display: none; }
.mode.active { display: block; animation: mode-in 0.5s ease; }
@keyframes mode-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── PIN Display ── */
.pin-display {
  display: flex; justify-content: center; gap: 18px; margin-bottom: 18px;
}
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(192, 132, 252, 0.4);
  transition: all 0.15s;
}
.pin-dot.filled {
  background: #c084fc;
  border-color: #c084fc;
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.5);
}

.error { color: #ff6b6b; font-size: 0.85rem; margin-bottom: 16px; }

/* ── PIN Pad ── */
.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; max-width: 280px; margin: 0 auto;
}
.pin-btn {
  width: 76px; height: 76px; border-radius: 50%;
  border: 1px solid rgba(192, 132, 252, 0.2);
  background: rgba(20, 10, 30, 0.6);
  color: #e0d0f0; font-size: 1.5rem;
  cursor: pointer; transition: all 0.15s;
  justify-self: center;
  backdrop-filter: blur(4px);
}
.pin-btn:hover { background: rgba(192, 132, 252, 0.15); border-color: rgba(192, 132, 252, 0.4); }
.pin-btn:active { background: rgba(192, 132, 252, 0.25); transform: scale(0.95); }
.pin-btn-clear { color: rgba(192, 132, 252, 0.5); font-size: 1.1rem; }
.pin-btn-enter { background: rgba(192, 132, 252, 0.15); border-color: rgba(192, 132, 252, 0.4); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}
.pin-display.shake { animation: shake 0.4s; }

/* ── Content Type Selector ── */
.type-selector {
  display: flex; gap: 12px; justify-content: center; margin-bottom: 16px;
}
.type-btn {
  padding: 10px 28px;
  background: rgba(20, 10, 30, 0.6);
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-radius: 8px;
  color: rgba(192, 132, 252, 0.5);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
  font-family: 'Inconsolata', monospace;
}
.type-btn:hover {
  background: rgba(192, 132, 252, 0.1);
  border-color: rgba(192, 132, 252, 0.4);
  color: #c084fc;
}
.type-btn.active {
  background: rgba(192, 132, 252, 0.2);
  border-color: #c084fc;
  color: #c084fc;
  box-shadow: 0 0 15px rgba(192, 132, 252, 0.2);
}

.drop-zone.disabled {
  opacity: 0.4;
  pointer-events: none;
  border-color: rgba(192, 132, 252, 0.1);
}

.drop-zone.disabled .drop-subtext { display: none; }
.drop-zone.disabled .browse-btn { display: none; }

/* ── Drop Zone ── */
.drop-zone {
  border: 2px dashed rgba(192, 132, 252, 0.3);
  border-radius: 16px;
  padding: 50px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: rgba(20, 10, 30, 0.4);
  backdrop-filter: blur(4px);
}
.drop-zone.dragover {
  border-color: #c084fc;
  background: rgba(192, 132, 252, 0.1);
  box-shadow: 0 0 30px rgba(192, 132, 252, 0.15);
}
.drop-text {
  font-family: 'Inconsolata', monospace;
  font-size: 1.2rem; margin-bottom: 8px; color: #e0d0f0;
}
.drop-subtext { color: rgba(192, 132, 252, 0.4); margin-bottom: 12px; font-size: 0.85rem; }

.browse-btn {
  display: inline-block; padding: 10px 24px;
  background: rgba(192, 132, 252, 0.1);
  border: 1px solid rgba(192, 132, 252, 0.3);
  border-radius: 8px; color: #c084fc;
  cursor: pointer; font-size: 0.9rem;
  transition: all 0.2s;
}
.browse-btn:hover { background: rgba(192, 132, 252, 0.2); }

/* ── Custom Scrollbars (upload list + efni list) ── */
.upload-list,
.efni-list {
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: rgba(192, 132, 252, 0.4) rgba(20, 10, 30, 0.6);
}

.upload-list::-webkit-scrollbar,
.efni-list::-webkit-scrollbar {
  width: 6px;
}

.upload-list::-webkit-scrollbar-track,
.efni-list::-webkit-scrollbar-track {
  background: rgba(20, 10, 30, 0.6);
  border-radius: 3px;
}

.upload-list::-webkit-scrollbar-thumb,
.efni-list::-webkit-scrollbar-thumb {
  background: rgba(192, 132, 252, 0.4);
  border-radius: 3px;
}

.upload-list::-webkit-scrollbar-thumb:hover,
.efni-list::-webkit-scrollbar-thumb:hover {
  background: rgba(192, 132, 252, 0.65);
}

/* ── Upload List ── */
.upload-list { margin-top: 20px; max-height: 40vh; overflow-y: auto; }
.upload-item {
  background: rgba(20, 10, 30, 0.6);
  border: 1px solid rgba(192, 132, 252, 0.15);
  border-radius: 10px; padding: 14px; margin-bottom: 10px;
  backdrop-filter: blur(4px);
}
.upload-item-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.upload-item-name {
  font-size: 0.85rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; flex: 1; color: #e0d0f0; margin-right: 8px;
}
.upload-item-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.upload-item-status { font-size: 0.8rem; color: rgba(192, 132, 252, 0.6); }
.upload-item-status.done { color: #a3e635; }
.upload-item-status.error { color: #ff6b6b; }

/* Animated trailing dots for the assembling phase */
@keyframes trailing-dots {
  0%   { content: '.'; }
  33%  { content: '..'; }
  66%  { content: '...'; }
  100% { content: '.'; }
}
.upload-item-status.assembling-dots::after {
  content: '.';
  animation: trailing-dots 1.2s steps(1, end) infinite;
}
.cancel-btn {
  background: none; border: none; color: rgba(192, 132, 252, 0.3);
  cursor: pointer; font-size: 0.9rem; padding: 0 4px;
  transition: color 0.2s; line-height: 1;
}
.cancel-btn:hover { color: #ff6b6b; }
.dismiss-btn {
  background: none; border: none; color: rgba(192, 132, 252, 0.25);
  cursor: pointer; font-size: 0.85rem; padding: 0 4px;
  transition: color 0.2s; line-height: 1;
}
.dismiss-btn:hover { color: rgba(192, 132, 252, 0.7); }
.upload-phase { color: rgba(192, 132, 252, 0.35); font-style: italic; }

.progress-bar {
  height: 3px; background: rgba(192, 132, 252, 0.1);
  border-radius: 2px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: #c084fc;
  border-radius: 2px; transition: width 0.2s; width: 0%;
}
.progress-bar-fill.done { background: #a3e635; }

.upload-item-details {
  display: flex; justify-content: space-between;
  font-size: 0.7rem; color: rgba(192, 132, 252, 0.4); margin-top: 6px;
}

/* ── Status Panel ── */
.status-panel {
  position: fixed; bottom: 16px; right: 16px; z-index: 10;
  transition: all 0.3s ease;
}
.status-panel.hidden { display: none; }
.status-toggle {
  position: absolute; bottom: 0; right: 0;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(20, 10, 30, 0.7);
  border: 1px solid rgba(192, 132, 252, 0.25);
  color: rgba(192, 132, 252, 0.6);
  font-size: 1.1rem; cursor: pointer;
  backdrop-filter: blur(6px);
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.status-toggle:hover { background: rgba(192, 132, 252, 0.15); color: #c084fc; }
.status-content {
  display: none;
  position: absolute; bottom: 50px; right: 0;
  background: rgba(10, 5, 20, 0.85);
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 220px;
  backdrop-filter: blur(10px);
  font-size: 0.8rem;
}
.status-panel.expanded .status-content { display: block; animation: mode-in 0.3s ease; }

.status-drive {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px; color: #ccc;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.online { background: #4ade80; box-shadow: 0 0 6px rgba(74, 222, 128, 0.5); }
.status-dot.offline { background: #f87171; box-shadow: 0 0 6px rgba(248, 113, 113, 0.5); }
.status-drive-info { color: rgba(192, 132, 252, 0.5); font-size: 0.7rem; margin-left: 16px; margin-bottom: 8px; }

.status-plex {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px; color: #ccc;
}

.status-divider {
  height: 1px; background: rgba(192, 132, 252, 0.15);
  margin: 10px 0;
}
.status-total {
  color: #c084fc; font-size: 0.85rem;
  font-family: 'Inconsolata', monospace;
}

.plex-scan-btn {
  width: 100%;
  padding: 6px 12px;
  margin-top: 4px;
  border: 1px solid rgba(192, 132, 252, 0.3);
  border-radius: 6px;
  background: rgba(192, 132, 252, 0.1);
  color: #c084fc;
  font-size: 0.75rem;
  font-family: 'Inconsolata', monospace;
  cursor: pointer;
  transition: all 0.2s ease;
}
.plex-scan-btn:hover { background: rgba(192, 132, 252, 0.2); }
.plex-scan-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.plex-scan-main {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px 20px;
  border: 1px solid rgba(192, 132, 252, 0.3);
  border-radius: 10px;
  background: rgba(192, 132, 252, 0.1);
  color: #c084fc;
  font-size: 0.95rem;
  font-family: 'Inconsolata', monospace;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}
.plex-scan-main:hover {
  background: rgba(192, 132, 252, 0.2);
  border-color: rgba(192, 132, 252, 0.5);
}
.plex-scan-main:disabled { opacity: 0.5; cursor: not-allowed; }
.plex-scan-main.hidden { display: none; }

/* ── Efni Panel ── */
.efni-panel {
  position: fixed; top: 16px; right: 16px; z-index: 10;
}
.efni-panel.hidden { display: none; }

.efni-toggle {
  padding: 8px 16px;
  background: rgba(20, 10, 30, 0.7);
  border: 1px solid rgba(192, 132, 252, 0.25);
  border-radius: 8px;
  color: rgba(192, 132, 252, 0.6);
  font-size: 0.8rem; cursor: pointer;
  backdrop-filter: blur(6px);
  transition: all 0.2s;
  font-family: 'Inconsolata', monospace;
}
.efni-toggle:hover { background: rgba(192, 132, 252, 0.15); color: #c084fc; }

.efni-content {
  position: absolute; top: 44px; right: 0;
  background: rgba(10, 5, 20, 0.9);
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-radius: 12px;
  padding: 14px;
  width: 360px; max-height: 70vh;
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column;
}
.efni-content.hidden { display: none; }

.efni-search-input {
  width: 100%; padding: 8px 12px;
  background: rgba(192, 132, 252, 0.05);
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-radius: 8px;
  color: #e0d0f0; font-size: 0.85rem;
  outline: none; margin-bottom: 10px;
}
.efni-search-input::placeholder { color: rgba(192, 132, 252, 0.3); }
.efni-search-input:focus { border-color: rgba(192, 132, 252, 0.4); }

/* ── Efni Tabs ── */
.efni-tabs {
  display: flex;
  border-bottom: 2px solid rgba(192, 132, 252, 0.1);
  margin-bottom: 10px;
}
.efni-tab {
  background: none; border: none;
  padding: 6px 16px;
  color: rgba(192, 132, 252, 0.4);
  font-size: 0.8rem; cursor: pointer;
  font-family: 'Inconsolata', monospace;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s;
}
.efni-tab:hover { color: rgba(192, 132, 252, 0.7); }
.efni-tab.active {
  color: #e9d5ff;
  border-bottom-color: #c084fc;
}

.efni-list {
  overflow-y: auto; max-height: calc(70vh - 80px);
  flex: 1;
}
.efni-movie-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; margin-bottom: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}
.efni-movie-item:hover { background: rgba(192, 132, 252, 0.08); }
.efni-movie-info {
  flex: 1; overflow: hidden; margin-right: 8px;
}
.efni-movie-name {
  font-size: 0.8rem; color: #e0d0f0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.efni-movie-meta {
  font-size: 0.65rem; color: rgba(192, 132, 252, 0.4);
}
.efni-delete-btn {
  background: none; border: 1px solid rgba(248, 113, 113, 0.3);
  color: rgba(248, 113, 113, 0.6); border-radius: 4px;
  padding: 3px 8px; font-size: 0.7rem;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.efni-delete-btn:hover {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171; border-color: #f87171;
}
.efni-delete-btn.confirm {
  background: rgba(248, 113, 113, 0.3);
  color: #fff; border-color: #f87171;
}
.efni-empty { color: rgba(192, 132, 252, 0.3); text-align: center; padding: 20px; font-size: 0.85rem; }

/* ── TV Show expand/collapse ── */
.efni-show-item {
  cursor: pointer;
  margin-bottom: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}
.efni-show-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px;
}
.efni-show-item:hover { background: rgba(192, 132, 252, 0.08); }
.efni-show-name {
  font-size: 0.8rem; color: #e0d0f0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.efni-show-arrow {
  color: rgba(192, 132, 252, 0.4);
  font-size: 0.7rem; flex-shrink: 0;
  transition: transform 0.2s;
}
.efni-show-item.expanded .efni-show-arrow { transform: rotate(90deg); }
.efni-show-item.expanded .efni-show-name { color: #c084fc; }

.efni-episodes {
  display: none;
  margin-left: 12px; margin-bottom: 8px;
}
.efni-show-item.expanded .efni-episodes { display: block; }

.efni-episode {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 10px;
  font-size: 0.75rem;
  border-bottom: 1px solid rgba(192, 132, 252, 0.05);
}
.efni-episode-name { color: rgba(229, 213, 255, 0.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.efni-episode-size { color: rgba(192, 132, 252, 0.3); margin-left: 8px; flex-shrink: 0; }
.efni-show-more {
  color: rgba(192, 132, 252, 0.4); font-size: 0.7rem;
  padding: 4px 10px; cursor: pointer;
}
.efni-show-more:hover { color: #c084fc; }

/* ── Radarr Search ── */
.radarr-search {
  margin-bottom: 16px;
  position: relative;
}
.radarr-search.hidden { display: none; }

.radarr-input {
  width: 100%; padding: 12px 16px;
  background: rgba(20, 10, 30, 0.6);
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-radius: 10px;
  color: #e0d0f0; font-size: 0.95rem;
  outline: none;
  backdrop-filter: blur(4px);
  font-family: 'Inconsolata', monospace;
  transition: border-color 0.2s;
}
.radarr-input::placeholder { color: rgba(192, 132, 252, 0.3); }
.radarr-input:focus { border-color: rgba(192, 132, 252, 0.5); }

.radarr-results {
  position: absolute; top: 100%; left: 0; right: 0;
  margin-top: 4px;
  background: rgba(10, 5, 20, 0.95);
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-radius: 10px;
  max-height: 320px; overflow-y: auto;
  z-index: 20;
  backdrop-filter: blur(10px);
  scrollbar-width: thin;
  scrollbar-color: rgba(192, 132, 252, 0.4) rgba(20, 10, 30, 0.6);
}
.radarr-results.hidden { display: none; }

.radarr-result {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(192, 132, 252, 0.05);
}
.radarr-result:last-child { border-bottom: none; }
.radarr-result:hover { background: rgba(192, 132, 252, 0.1); }
.radarr-result.has-file { opacity: 0.5; cursor: default; }
.radarr-result.has-file:hover { background: transparent; }
.radarr-result.pending { opacity: 0.7; cursor: default; }
.radarr-result.shake { animation: shake 0.4s; }

.radarr-poster {
  width: 36px; height: 54px;
  object-fit: cover; border-radius: 4px;
  background: rgba(192, 132, 252, 0.1);
  flex-shrink: 0;
}

.radarr-info { flex: 1; overflow: hidden; text-align: left; }
.radarr-title {
  font-size: 0.85rem; color: #e0d0f0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.radarr-year { font-size: 0.7rem; color: rgba(192, 132, 252, 0.4); }
.radarr-status-text {
  font-size: 0.65rem; color: #facc15;
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.radarr-status-text--available { color: #a3e635; }
.radarr-check { color: #a3e635; font-size: 0.8rem; flex-shrink: 0; }
.radarr-pending { color: #facc15; font-size: 0.8rem; flex-shrink: 0; }

.radarr-msg {
  padding: 16px; text-align: center;
  color: rgba(192, 132, 252, 0.4); font-size: 0.85rem;
}

.radarr-added {
  color: #a3e635; font-size: 0.8rem;
  padding: 4px 0; text-align: center;
  animation: fade-out 2s ease forwards;
}
@keyframes fade-out {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Mobile Responsive ── */
@media (max-width: 480px) {
  .title { font-size: 2.4rem; margin-bottom: 24px; }
  .center-box { padding: 12px; }
  .pin-btn { width: 64px; height: 64px; font-size: 1.3rem; }
  .pin-pad { gap: 10px; max-width: 240px; }
  .drop-zone { padding: 36px 16px; }
  .drop-text { font-size: 1rem; }
  .browse-btn { padding: 8px 20px; font-size: 0.85rem; }
  .upload-list { max-height: 35vh; }
  .upload-item { padding: 10px; }
  .upload-item-name { font-size: 0.75rem; }

  .type-btn { padding: 8px 20px; font-size: 0.85rem; }

  .radarr-input { font-size: 0.85rem; padding: 10px 12px; }
  .radarr-results { max-height: 250px; }

  .efni-panel { top: 10px; right: 10px; }
  .efni-content { width: calc(100vw - 28px); right: -6px; }

  .status-panel { bottom: 12px; right: 12px; }
  .status-content {
    min-width: 200px; max-width: calc(100vw - 32px);
    right: 0; bottom: 46px;
    padding: 12px 14px; font-size: 0.75rem;
  }
  .status-toggle { width: 36px; height: 36px; font-size: 1rem; }
}

@media (max-height: 600px) {
  .title { font-size: 2rem; margin-bottom: 16px; }
  .pin-btn { width: 56px; height: 56px; font-size: 1.1rem; }
  .pin-pad { gap: 8px; }
  .drop-zone { padding: 28px 12px; }
}
