:root {
  --bg: #0f1216;
  --fg: #e6e6e6;
  --muted: #9aa0a6;
  --card: #171b22;
  --accent: #4f8cff;
  --danger: #ff5c5c;
  --border: #2a2f38;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans";
}

.nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
}

.menu a {
  color: var(--fg);
  text-decoration: none;
  margin-right: 12px;
}

.menu a:hover {
  color: var(--accent);
}

.actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

input,
select,
textarea {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
}

main {
  padding: 16px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.spacer {
  flex: 1;
}

.btn {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, border-color 0.2s ease;
}

.btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}

.card:hover {
  transform: scale(1.03);
  border-color: var(--accent);
}

.card img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
}

.card .pad {
  padding: 8px;
  font-size: 0.9em;
}

.muted {
  color: var(--muted);
  font-size: 0.85em;
}

.detail-layout {
  display: flex;
  gap: 24px;
}

.detail-layout img {
  width: 200px;
  height: 300px;
  object-fit: cover;
  border-radius: 10px;
}

.detail-layout .info {
  flex: 1;
}

.detail-layout .info h2 {
  margin-top: 0;
  font-size: 1.6em;
}

.detail-layout .info .muted {
  color: var(--muted);
  margin-bottom: 8px;
}

#refreshItemPosterBtn{
display: block; 
margin: 10px 0 0;
}
.section {
  margin-top: 16px;
}

.section div {
  margin-bottom: 4px;
}

.form .row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.form .row-inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.list-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.list-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.poster-mini {
  width: 36px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.btn.loading {
  position: relative;
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

/*Popup Alert*/
.popup {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;

  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup.hidden {
  display: none;
}

.popup-content {
  background: var(--card);
  padding: 20px;
  border-radius: 8px;
  min-width: 280px;

}

.export-option {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;   /* ✅ no bg by default */
  color: var(--fg);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.export-option:hover {
  background: var(--accent); /* ✅ accent bg on hover */
  color: #fff;
  border-color: var(--accent);
}

.popup-close {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  
  background: var(--accent);color: var(--fg);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.popup-close:hover {
  background: #ff5c5c;   /* ✅ matches other buttons */
  border: var(--border);
  color: #fff;
}

.btn.loading {
  position: relative;
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Base grid layout */
.grid, .list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

/* Card styling */
.card, .list-card {
  background: var(--card, #222);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card img, .list-card img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* Header/nav responsive */
header.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px;
}

header.nav .brand {
  flex: 1 1 100%;
  font-size: 1.2em;
  margin-bottom: 8px;
}

header.nav .menu {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

header.nav .actions {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 6px;
}

/* Popup */
.popup-content {
  width: 90%;
  max-width: 400px;
}

/* Forms */
.form .row, .form .row-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Selection overlay */
.card {
  position: relative;
}
.card.selected::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 150, 255, 0.25);
  border: 2px solid #0096ff;
  pointer-events: none;
}
.card .selector-dot {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0,0,0,0.4);
}
.card.selected .selector-dot {
  background: #0096ff;
  border-color: #fff;
}

/* Selection toolbar */
#selectionToolbar {
  display: none;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid #222;
}
#selectionToolbar.visible {
  display: flex;
}
#selectionCount {
  margin-right: auto;
  color: #ccc;
}

/* Poster Grid */
.poster-tile {
  position: relative;
  display: inline-block;
  /*margin: 2px;
  width: 150px;*/
  cursor: pointer;
  vertical-align: top;
}

.poster-tile img.poster {
  width: 100%;
  border-radius: 4px;
  display: block;
}

.poster-tile .card-meta {
  margin-top: 4px;
  text-align: center;
  font-size: 12px;
}

.poster-tile .card-meta .title {
  color: #fff;
  font-weight: bold;
  display: block;
  margin-bottom: 2px;
}

.poster-tile .card-meta .meta-line {
  color: #aaa;
  font-size: 11px;
}

/* Stats Back Btn */
.back-bar {
  margin: 8px 0;
}
/*
#backToStatsBtn {
  background: #333;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}
#backToStatsBtn:hover {
  background: #444;
}*/

.list-add-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap; /* allow wrapping */
  margin: 40px 0 20px 0;
}

.list-add-header h2 {
  
  flex: 1 1 auto;
}

.list-add-header .actions {
  display: flex;
  gap: 8px;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.list-add-header input {
  max-width: 160px; /* 160px to keep inputs compact */
}

.apiStatsSection .btn {
    margin: 8px 8px 8px 0;
  }
  #apiKeyInput {
    width: 250px;
    margin: 8px 8px 8px 0;
  }
#importSectionMargin {
    margin-bottom: 90px; 
  }

/* Media queries for small screens */
@media (max-width: 600px) {
  body {
    font-size: 14px;
    margin: 0;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .page-header .spacer {
    display: none;
  }
.detail-layout {
  flex-direction: column;
}
  .form .row, .form .row-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form label {
    margin-bottom: 4px;
  }

  header.nav .menu {
    flex-direction: column;
    align-items: flex-start;
  }

  header.nav .actions {
    flex-direction: column;
    width: 100%;
  }

  .grid, .list-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); /* single column on narrow screens */
  }

  .list-add-header {
    flex-direction: column;   /* stack heading and actions vertically */
    align-items: stretch;     /* make inputs full width */
    margin-top: 40px !important;
  }

  .list-add-header .actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .list-add-header .actions input {
    flex: 1 1 100%;           /* inputs take full width */
    min-width: 0;
    max-width: none;
  }

  .apiStatsSection .btn {
    margin: 5px 5px 5px 0;
  }
  #apiKeyInput {
    width: -webkit-fill-available;
    margin: 5px 5px 5px 0;
  }
  #importSectionMargin {
    margin-bottom: 60px; 
  }
}

/* Section styling */
.import-ui {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 30px;
}

.toolbar-title {
  margin: 0 0 12px 0;
  font-size: 1.4em; /* same as Current Collections */
  font-weight: 600;
  color: var(--fg);
}

/* Toolbar */
.file-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.file-label {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.file-label:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.file-label .material-icons {
  font-size: 18px;
}

/* Progress wrapper groups bar + label */
.progress-wrapper {
  width: 100%;        /* full width */
  max-width: 300px;
  margin-top: 16px;
}

/* Bar container */
.progress-container {
  width: 100%;          /* bar fills wrapper */
  background: var(--border);
  border-radius: 6px;
  height: 14px;
  margin-bottom: 6px;   /* spacing before label */
  overflow: hidden;
}

/* Progress bar itself */
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* Label below bar */
.progress-label {
  font-size: 0.9em;
  color: var(--fg);
  text-align: left; /* or center if you prefer */
}

/* Indeterminate animation */
.progress-bar.indeterminate {
  width: 30%;
  animation: indeterminate 1.2s infinite linear;
}

@keyframes indeterminate {
  0%   { margin-left: -30%; }
  50%  { margin-left: 50%; }
  100% { margin-left: 100%; }
}

.hidden {
  display: none;
}



