/* ==========================================================================
   Game ID — Library Page
   Matches Figma wireframe: horizontal filter chips, 240px cards, flat hover
   ========================================================================== */

.library-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  max-width: 100%;
}

/* ---- Filter bar (horizontal chip dropdowns per Figma) --------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--page-gutter);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-primary);
  background: var(--bg-chip);
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-circular);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-standard);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'%3E%3Cpath d='M2 4l3 3 3-3' stroke='%23949494' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.filter-chip:hover {
  border-color: var(--stroke-subtle);
}

.filter-chip:focus {
  border-color: var(--brand-rest);
}

.filter-spacer {
  flex: 1;
}

.sort-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-primary);
  background: var(--bg-chip);
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-circular);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-standard);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'%3E%3Cpath d='M2 4l3 3 3-3' stroke='%23949494' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.sort-chip:hover { border-color: var(--stroke-subtle); }

.view-toggle {
  display: flex;
  gap: 2px;
}

.view-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-tertiary);
  background: transparent;
  border: 1px solid var(--stroke-divider);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--t-fast) var(--ease-standard);
}

.view-btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.view-btn:last-child  { border-radius: 0 var(--r-md) var(--r-md) 0; }

.view-btn:hover { color: var(--fg-primary); background: var(--bg-nav-hover); }
.view-btn.active { color: var(--brand-hover); background: rgba(15,108,189,0.1); border-color: var(--brand-rest); }

/* ---- body ---------------------------------------------------------------- */
.library-body {
  display: flex;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

/* ---- Filters sidebar ----------------------------------------------------- */
.filters-sidebar {
  width: 280px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 0 16px 16px 16px;
  border-right: 1px solid var(--stroke-divider);
  margin-right: 4px;
  transition: opacity var(--t-normal) var(--ease-standard);
}

.filters-sidebar.collapsed {
  display: none;
}

.filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.filters-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-primary);
}

.clear-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-rest);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}

.clear-btn:hover { background: rgba(15,108,189,0.08); }

.filter-group {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--stroke-divider);
}

.filter-group:last-child { border-bottom: none; }

.filter-group-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-secondary);
  margin-bottom: 8px;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--fg-secondary);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}

.checkbox-list label:hover { background: var(--bg-nav-hover); }

.checkbox-list input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--brand-rest);
  cursor: pointer;
  flex-shrink: 0;
}

.cb-label { flex: 1; min-width: 0; }
.cb-count {
  font-size: 11px;
  color: var(--fg-quaternary);
  font-weight: 600;
  flex-shrink: 0;
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-inputs input {
  flex: 1;
  height: 32px;
  padding: 0 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--fg-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color var(--t-fast);
}

.range-inputs input:focus { border-color: var(--brand-rest); }
.range-inputs input::placeholder { color: var(--fg-quaternary); }

.range-sep { color: var(--fg-quaternary); font-size: 12px; }

.filter-note {
  font-size: 11px;
  color: var(--fg-quaternary);
  margin-top: 6px;
  line-height: 1.4;
}

/* ---- Results ------------------------------------------------------------- */
.library-results {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
  padding: 0 var(--page-gutter);
}

.result-count {
  font-size: 12px;
  color: var(--fg-tertiary);
  margin-bottom: 16px;
}

/* ---- Card grid ----------------------------------------------------------- */
.library-grid {
  display: grid;
  gap: 16px;
}

.library-grid.view-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.library-grid.view-list {
  grid-template-columns: 1fr;
}

.library-grid.view-compact {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* ---- Game card ----------------------------------------------------------- */
.game-card {
  background: var(--bg-layer);
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-standard);
  /* Figma: flat — no shadow, no hover lift */
}

.game-card:hover { border-color: var(--stroke-subtle); }

.view-list .game-card,
.view-compact .game-card {
  display: flex;
  flex-direction: row;
}

.game-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-list .game-cover,
.view-compact .game-cover {
  width: 120px;
  min-height: 160px;
  aspect-ratio: auto;
}

.view-compact .game-cover {
  width: 100px;
  min-height: 133px;
}

.cover-fallback {
  width: 36px;
  height: 36px;
  border-radius: var(--r-circular);
  border: 2px solid var(--fg-quaternary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-quaternary);
  opacity: 0.5;
}

.cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rating-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  border-radius: var(--r-sm);
}

.conf-dot {
  position: absolute;
  bottom: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--r-circular);
  border: 1.5px solid rgba(0,0,0,0.3);
}

.conf-dot.conf-high   { background: var(--conf-high); }
.conf-dot.conf-medium { background: var(--conf-medium); }
.conf-dot.conf-low    { background: var(--conf-low); }

.game-info {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
}

.view-list .game-info {
  flex-direction: row;
  align-items: center;
  gap: 16px;
  flex: 1;
  padding: 10px 14px;
}

.view-compact .game-info {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex: 1;
  padding: 8px 12px;
}

.game-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-primary);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 6px;
}

.view-list .game-title,
.view-compact .game-title {
  -webkit-line-clamp: 1;
  margin-bottom: 0;
  flex-shrink: 1;
  min-width: 0;
  flex: 1;
}

.game-meta {
  font-size: 11px;
  color: var(--fg-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-compact .game-meta { display: none; }

.game-meta-icon {
  width: 12px;
  height: 12px;
  color: var(--fg-tertiary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.game-meta-icon svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.game-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.view-compact .game-footer { margin-top: 0; }

.game-platform {
  font-size: 11px;
  color: var(--fg-tertiary);
}

.price-tag {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-primary);
}

.price-free { color: var(--status-success-fg); }
.price-unknown { color: var(--fg-quaternary); }

.unmatched-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 600;
  border-radius: var(--r-circular);
  background: var(--bg-chip);
  color: var(--fg-tertiary);
}

/* ---- Pagination ---------------------------------------------------------- */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 20px;
  margin-top: 4px;
}

.pagination-info {
  font-size: 12px;
  color: var(--fg-tertiary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-size-select {
  height: 32px;
  padding: 0 28px 0 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--fg-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-md);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23949494' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
  outline: none;
}

.page-size-select:focus { border-color: var(--brand-rest); }

.page-btn {
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-secondary);
  background: transparent;
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-standard);
  padding: 0 8px;
}

.page-btn:hover {
  background: var(--bg-nav-hover);
  color: var(--fg-primary);
}

.page-btn.active {
  background: var(--brand-rest);
  border-color: var(--brand-rest);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.page-btn-arrow {
  font-size: 14px;
}

/* ---- No results ---------------------------------------------------------- */
.no-results {
  text-align: center;
  padding: 48px 20px;
}

.no-results p:first-child {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-primary);
  margin-bottom: 8px;
}

.no-results p:last-child {
  font-size: 12px;
  color: var(--fg-tertiary);
}

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1100px) {
  .filters-sidebar { width: 240px; }
}

@media (max-width: 860px) {
  .filters-sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    z-index: 100;
    background: var(--bg-layer);
    border-right: 1px solid var(--stroke-divider);
    width: 280px;
    padding: 16px;
  }

  .filters-sidebar.collapsed { display: none; }

  .library-grid.view-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}
