/* ─── MOVIES DOMAIN ──────────────────────────────────────────── */
.movies-page {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  padding-top: var(--nav-h);
}

/* Atmospheric background — same system as Photos' .photos-bg (fixed,
   blurred/dimmed backdrop behind the page content, --movies-bg-image as
   a custom property rather than a hardcoded background-image), with a
   cinema-themed image instead of a photo. Legibility over it comes from
   the header text-shadow below, same approach as Photos. */
:root {
  --movies-bg-image: url('/assets/backgrounds/movies.jpg');
}

.movies-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: var(--movies-bg-image);
  background-size: cover;
  background-position: center;
  filter: blur(0.5px) brightness(0.6) saturate(1.15);
  transform: scale(1.02);
}

.movies-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(20,4,6,0.25), rgba(10,3,4,0.4));
}

[data-theme="light"] .movies-bg { filter: blur(0.5px) brightness(0.85) saturate(1.1); }
[data-theme="light"] .movies-bg::after { background: linear-gradient(180deg, rgba(30,10,10,0.18), rgba(20,8,8,0.28)); }

/* ─── LEFT: Upload tile ──────────────────────────────────────── */
.movies-side {
  padding: 1.5rem 0 1.5rem 5%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.movies-tile {
  position: relative;
  width: 56%;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-md);
  border: 1.5px solid transparent;
  transition: transform var(--transition), box-shadow var(--transition);
}

.movies-tile:hover {
  transform: scale(1.03);
  box-shadow: var(--shadow-lg);
}

.movies-tile-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
}

.movies-tile-upload {
  background: linear-gradient(155deg, #3b7dd8, #2c5fa8);
  border-color: rgba(255,255,255,0.25);
}

/* ─── MAIN: Library grid ─────────────────────────────────────── */
.movies-main {
  padding: 1.5rem 5% 2.5rem 0;
  min-width: 0;
}

.movies-header {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1.4rem;
}

.movies-header-icon {
  color: var(--text-secondary);
  opacity: 0.85;
  margin-bottom: 0.15rem;
  filter: drop-shadow(0 1px 6px rgba(0,0,0,0.4));
}

.movies-header h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-shadow: 0 1px 3px rgba(0,0,0,0.45), 0 2px 16px rgba(0,0,0,0.3);
}

.movies-count {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-shadow: 0 1px 3px rgba(0,0,0,0.45), 0 2px 12px rgba(0,0,0,0.25);
}

[data-theme="light"] .movies-header-icon { filter: drop-shadow(0 1px 6px rgba(255,255,255,0.55)); }
[data-theme="light"] .movies-header h1,
[data-theme="light"] .movies-count { text-shadow: 0 1px 3px rgba(255,255,255,0.6), 0 2px 14px rgba(255,255,255,0.4); }

.movies-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.85rem;
  grid-column: 1 / -1;
}

/* Non-modal — a conversion can run a long time; the page stays fully
   usable while this is visible, nothing else is blocked by it. */
.movies-convert-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.movies-convert-banner[hidden] { display: none; }

.movies-convert-spinner {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  flex-shrink: 0;
  animation: movies-convert-spin 0.8s linear infinite;
}
@keyframes movies-convert-spin { to { transform: rotate(360deg); } }

.movies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.85rem;
}

/* No real thumbnails in v1 (no frame-extraction dependency installed) —
   a consistent placeholder tile with the filename, not a broken image. */
.movie-tile {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(155deg, #2a2f3a, #1b1f27);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.movie-tile:hover {
  transform: scale(1.03);
  box-shadow: var(--shadow-md);
  z-index: 2;
}

.movie-tile-poster {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.35);
}

.movie-tile:hover .movie-tile-poster { color: rgba(255,255,255,0.55); }

/* F26 — real thumbnail, same object-fit:cover treatment as Photos' own
   grid image (.photo-thumb img) so it always fills the 16:9 tile
   regardless of the extracted frame's exact aspect ratio. */
.movie-tile-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.movie-tile-name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0.5rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movie-tile-unsupported {
  position: absolute;
  top: 0.4rem; right: 0.4rem;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.85);
}

/* ─── MOVIE TILE ⋮ MENU (F22) ──────────────────────────────────
   Top-left (the unsupported badge already owns top-right). The
   dropdown itself is NOT a child of .movie-tile: that element's own
   overflow:hidden (needed for its rounded-corner card look) would
   otherwise clip a menu this much bigger than a ~107px-tall tile. One
   shared element is appended to <body> once (movies.js) and positioned
   with position:fixed from the clicked button's real screen position,
   which sidesteps the clipping entirely regardless of which tile. */
.movie-tile-menu-btn {
  position: absolute;
  top: 0.35rem; left: 0.35rem;
  z-index: 3;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}
.movie-tile-menu-btn:hover { background: rgba(0,0,0,0.65); color: #fff; }

.movie-tile-menu {
  position: fixed;
  z-index: 1200;
  min-width: 170px;
  background: #24242c;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  padding: 0.4rem;
  cursor: default;
}
.movie-tile-menu[hidden] { display: none; }

.movie-tile-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border: none;
  border-radius: 6px;
  background: none;
  color: #fff;
  font-size: 0.82rem;
  cursor: pointer;
}
.movie-tile-menu-item:hover { background: rgba(255,255,255,0.1); }

.movie-tile-menu-prompt {
  padding: 0.4rem 0.5rem 0.6rem;
  font-size: 0.8rem;
  color: #fff;
  line-height: 1.35;
}
.movie-tile-menu-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0 0.3rem 0.2rem;
}
.movie-tile-menu-cancel,
.movie-tile-menu-confirm {
  flex: 1;
  padding: 0.5rem 0;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.movie-tile-menu-cancel { background: rgba(255,255,255,0.1); color: #fff; }
.movie-tile-menu-cancel:hover { background: rgba(255,255,255,0.16); }
.movie-tile-menu-confirm { background: #d64545; color: #fff; }
.movie-tile-menu-confirm:hover { background: #e05555; }

/* ─── FOLDER GROUP HEADER (F27) ─────────────────────────────────
   Spans the full grid width so it reads as a section label between
   groups of tiles, not a grid cell of its own. */
.movies-group-header {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 0.3rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

/* ─── MOVIE VIEWER — reuses the same .pv-* chrome shape as Photos ───── */
.pv-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8,8,10,0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.pv-overlay[hidden] { display: none; }

.pv-stage {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4.5rem 5rem;
  min-height: 0;
}

.pv-stage video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  background: #000;
}

.mv-unsupported {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  color: rgba(255,255,255,0.75);
  background: rgba(0,0,0,0.55);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
}
.mv-unsupported[hidden] { display: none; }

.pv-btn {
  position: relative;
  z-index: 3;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--transition);
}

.pv-btn:hover { background: rgba(255,255,255,0.2); }

.pv-close  { position: absolute; top: 1.25rem; right: 1.25rem; }
.pv-prev   { position: absolute; left: 1.25rem; top: 50%; transform: translateY(-50%); }
.pv-next   { position: absolute; right: 1.25rem; top: 50%; transform: translateY(-50%); }

.pv-bottom {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.5rem;
}

.pv-counter {
  color: rgba(255,255,255,0.6);
  font-size: 0.78rem;
  min-width: 60px;
  text-align: center;
}

.pv-delete:hover { background: rgba(220,38,38,0.6); }

/* ─── UPLOAD CONFLICT / PROGRESS DIALOGS ─────────────────────── */
.sync-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sync-overlay[hidden] { display: none; }

.sync-panel {
  width: min(360px, 90vw);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sync-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.sync-row { display: flex; flex-direction: column; gap: 0.4rem; }
.sync-row[hidden] { display: none; }

.sync-trigger {
  padding: 0.65rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: inherit;
}
.sync-trigger:hover { opacity: 0.9; }
.sync-trigger:disabled { opacity: 0.5; cursor: default; }

.conflict-cancel {
  padding: 0.6rem;
  border-radius: var(--radius);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}
.conflict-cancel:hover { color: var(--text-primary); border-color: var(--border-strong); }

.sync-status {
  font-size: 0.74rem;
  color: var(--text-tertiary);
  line-height: 1.5;
}

.sync-progress-bar {
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.sync-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

/* ─── FOOTER (same pattern as Home/Photos) ───────────────────── */
.principles-strip {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1.75rem;
  padding: 1.5rem 5%;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
}

.principle-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.principle-item svg { flex-shrink: 0; opacity: 0.7; }

@media (max-width: 700px) {
  .principle-item { font-size: 0.66rem; }
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .movies-page {
    grid-template-columns: 1fr;
  }
  .movies-side {
    flex-direction: row;
    padding: 1rem 5% 0;
  }
  .movies-tile {
    width: auto;
    margin: 0;
    flex: 1;
    aspect-ratio: auto;
    flex-direction: row;
    padding: 0.75rem 1rem;
    font-size: 0.72rem;
    gap: 0.6rem;
  }
  .movies-tile-icon { width: 28px; height: 28px; }
  .movies-main { padding: 1rem 5% 2rem; }

  /* Same reasoning as Photos: the shared navbar hides its center nav
     below 900px, but here it holds the Photos/Movies/Music/Books
     domains, so it needs to stay visible. */
  .navbar { flex-wrap: wrap; height: auto; padding: 0.55rem 4%; row-gap: 0.4rem; }
  .navbar-nav {
    display: flex;
    position: static;
    left: auto;
    transform: none;
    order: 3;
    flex-basis: 100%;
    width: 100%;
    justify-content: center;
    gap: 0.3rem;
  }
  .navbar-nav .nav-item { padding: 0.3rem 0.55rem; font-size: 0.72rem; }
  .movies-page { padding-top: 5.5rem; }
}

@media (max-width: 700px) {
  .pv-stage { padding: 4rem 1rem; }
  .pv-prev  { left: 0.5rem; }
  .pv-next  { right: 0.5rem; }
  .pv-btn   { width: 34px; height: 34px; }
}

@media (max-width: 480px) {
  .movies-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.5rem; }
  .movies-side { flex-direction: column; }
}
