/* Deck Builder – page-specific styles */

/* Infinite-scroll sentinel: must span all grid columns so IntersectionObserver fires correctly */
.grid-sentinel { grid-column: 1 / -1; height: 1px; }

/* ── Layout ─────────────────────────────────────────────────────────── */
html, body { height: 100%; overflow: hidden; }

body {
  background-color: #0d1117;
  background-image:
    radial-gradient(1200px circle at 14% -12%, rgba(56,139,253,0.16), transparent 58%),
    radial-gradient(900px circle at 86% -8%, rgba(0,255,204,0.10), transparent 56%),
    linear-gradient(to bottom, rgba(13,17,23,0.94), #0d1117),
    radial-gradient(rgba(125,140,158,0.40) 2px, transparent 2px);
  background-size: auto, auto, 100% 100%, 20px 20px;
  background-repeat: no-repeat, no-repeat, no-repeat, repeat;
  background-position: top left, top right, top left, top left;
}

/* .db-layout below assumes a 52px-tall topbar */
rk-topbar {
  height: 52px;
  padding: 0.5rem 1.5rem;
  box-sizing: border-box;
}

.user-info { color: #aaa; font-size: 0.85rem; }
.user-info strong { color: #00ffcc; }

.db-layout {
  display: grid;
  grid-template-columns: 570px 1fr 400px;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ── Left panel ─────────────────────────────────────────────────────── */
.panel-left {
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(13,13,13,0.62);
}
.filters-bar {
  padding: 0.75rem;
  border-bottom: 1px solid #222;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(17,17,17,0.74);
}
.filters-bar input,
.filters-bar select {
  width: 100%;
  box-sizing: border-box;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}
.filters-bar input:focus,
.filters-bar select:focus { border-color: #00ffcc; }
.filters-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.6rem; }
.filter-label { font-size: 0.75rem; color: #888; margin-bottom: 6px; padding-left: 2px; }
.card-count { font-size: 0.8rem; color: #666; text-align: center; }
.bulk-btns {
  display: flex;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem 0.5rem;
  margin: 0 0.1rem;
}
.btn-bulk {
  flex: 1;
  padding: 6px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: filter .15s, transform .1s;
  white-space: nowrap;
}
.btn-bulk:hover:not(:disabled)  { filter: brightness(1.18); transform: translateY(-1px); }
.btn-bulk:active:not(:disabled) { filter: brightness(0.9);  transform: translateY(0); }
#btn-select-visible   { background: #1a6b3a; color: #7fffb0; border: 1px solid #2ea05a; }
#btn-unselect-visible { background: #5a2020; color: #ffaaaa; border: 1px solid #8b3030; }
.btn-bulk-reset       { background: #1d2e4a; color: #7ab8ff; border: 1px solid #2a4a7a; }

.card-grid-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.card-grid-wrap::-webkit-scrollbar { width: 6px; }
.card-grid-wrap::-webkit-scrollbar-track { background: #111; }
.card-grid-wrap::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
  padding: 12px 8px 8px;
}

.grid-card {
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  background: #1a1a1a;
  user-select: none;
}
.grid-card:hover { border-color: #00ffcc; transform: scale(1.05); box-shadow: 0 0 12px rgba(0,255,204,0.4); z-index: 2; }
.grid-card.in-deck { border-color: rgba(0,255,204,0.5); }
.grid-card.focused { border-color: #00ffcc; box-shadow: 0 0 16px rgba(0,255,204,0.6); }

.grid-card img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}
.grid-card-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  padding: 12px 4px 4px;
  font-size: 0.62rem;
  text-align: center;
  line-height: 1.2;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
/* Hide name label and type badge once the card image loads */
.grid-card.img-loaded .grid-card-label,
.grid-card.img-loaded .badge-type { display: none; }

.badge-replicate {
  position: absolute;
  top: 3px; right: 3px;
  background: #a855f7;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  pointer-events: none;
}
.badge-qty {
  position: absolute;
  top: 3px; left: 3px;
  background: rgba(0,255,204,0.9);
  color: #000;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  pointer-events: none;
}
.badge-type {
  position: absolute;
  bottom: 22px; left: 3px;
  font-size: 0.55rem;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
  pointer-events: none;
}
.badge-type.rock    { background: #1a4a1a; color: #4CAF50; }
.badge-type.paper   { background: #1a1a4a; color: #2196F3; }
.badge-type.scissors { background: #4a2a0a; color: #FF9800; }

/* ── Middle panel (focus zone) ──────────────────────────────────────── */
.panel-middle {
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 1rem;
  gap: 0.75rem;
  background: rgba(15,15,15,0.42);
}

#focus-content {
  margin-top: auto;
  margin-bottom: auto;
}
.panel-middle::-webkit-scrollbar { width: 6px; }
.panel-middle::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.focus-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #444;
  font-size: 0.9rem;
  text-align: center;
  gap: 0.5rem;
}
.focus-empty svg { opacity: 0.3; }

.focus-card-img {
  width: 100%;
  max-width: 440px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  flex-shrink: 0;
}
.focus-card-img img {
  width: 100%;
  aspect-ratio: 1086 / 1512;
  object-fit: cover;
  display: block;
}

.focus-info { width: 100%; max-width: 440px; margin-top: 1rem; }
.focus-name { font-size: 1.15rem; font-weight: 700; color: #fff; margin: 0 0 0.25rem; }
.focus-meta { font-size: 0.8rem; color: #888; margin-bottom: 0.5rem; }
.focus-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 6px;
}
.focus-type-badge.rock    { background: #1a4a1a; color: #4CAF50; }
.focus-type-badge.paper   { background: #1a1a4a; color: #2196F3; }
.focus-type-badge.scissors { background: #4a2a0a; color: #FF9800; }

.focus-power { display: inline-block; font-size: 0.8rem; color: #aaa; }

.focus-keywords { margin: 0.5rem 0; }
.keyword-chip {
  display: block;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
}
.keyword-chip .kw-name { color: #00ffcc; font-weight: 600; }
.keyword-chip .kw-desc { color: #999; margin-top: 2px; font-size: 0.75rem; line-height: 1.4; }
.keyword-chip.title-kw .kw-name { text-decoration: underline; color: #f0a0ff; }

.focus-qty { font-size: 0.85rem; color: #aaa; margin-bottom: 0.5rem; }
.focus-qty strong { color: #00ffcc; }

.focus-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn { padding: 0.5rem 1rem; border-radius: 8px; border: none; cursor: pointer; font-size: 0.85rem; font-weight: 600; transition: transform 0.15s, box-shadow 0.15s; }
.btn:hover { transform: scale(1.04); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-add  { background: linear-gradient(90deg, #00ffcc, #00ccff); color: #000; box-shadow: 0 0 8px rgba(0,255,204,0.4); }
.btn-add:hover  { box-shadow: 0 0 16px rgba(0,255,204,0.7); }
.btn-remove { background: linear-gradient(90deg, #ff0066, #ff6600); color: #fff; box-shadow: 0 0 8px rgba(255,0,102,0.3); }
.btn-remove:hover { box-shadow: 0 0 16px rgba(255,0,102,0.6); }

/* ── Right panel (deck) ─────────────────────────────────────────────── */
.panel-right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(13,13,13,0.58);
}

.deck-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #222;
  background: rgba(17,17,17,0.72);
}

.deck-selector-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.6rem;
}
.deck-selector {
  flex: 1;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.deck-selector:focus { border-color: #00ffcc; }

.btn-icon { padding: 0.45rem 0.6rem; font-size: 0.8rem; }
.btn-new  { background: linear-gradient(90deg, #00ffcc, #00ccff); color: #000; box-shadow: 0 0 6px rgba(0,255,204,0.3); }
.btn-copy { background: #1a1a1a; border: 1px solid #444; color: #ccc; }
.btn-delete { background: #2a0a0a; border: 1px solid #550000; color: #ff6666; }
.btn-copy:hover { border-color: #00ccff; color: #00ccff; }
.btn-delete:hover { background: #3a0a0a; border-color: #ff0000; }

.deck-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.deck-name-input {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.deck-name-input:hover { border-color: #333; background: #1a1a1a; }
.deck-name-input:focus { border-color: #00ffcc; background: #1a1a1a; }

.deck-cards-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}
.deck-cards-list::-webkit-scrollbar { width: 6px; }
.deck-cards-list::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.deck-type-group { margin-bottom: 0.75rem; }
.deck-type-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}
.deck-type-label:hover { filter: brightness(1.25); }
.deck-type-label.rock    { background: rgba(76,175,80,0.1); color: #4CAF50; }
.deck-type-label.paper   { background: rgba(33,150,243,0.1); color: #2196F3; }
.deck-type-label.scissors { background: rgba(255,152,0,0.1); color: #FF9800; }
.deck-type-label .type-count { margin-left: auto; font-size: 0.65rem; opacity: 0.7; }
.deck-type-label .type-chevron { font-size: 0.65rem; opacity: 0.5; }
.deck-type-group.collapsed { margin-bottom: 0.25rem; }

.deck-card-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.deck-card-row:hover { background: #1a1a1a; }
.deck-card-row.focused { background: rgba(0,255,204,0.07); }
@keyframes deck-row-flash {
  0%   { background: rgba(0,255,204,0.28); }
  100% { background: rgba(0,255,204,0.07); }
}
.deck-card-row.click-flash { animation: deck-row-flash 0.45s ease-out; }

.deck-card-mini {
  width: 48px;
  height: 67px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: #1a1a1a;
}
.deck-card-mini img { width: 100%; height: 100%; object-fit: cover; }

.deck-card-info { flex: 1; min-width: 0; }
.deck-card-name { font-size: 1.05rem; color: #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.2rem; }
.deck-card-sub  { font-size: 0.8rem; color: #666; }

.deck-card-qty-badge {
  background: #a855f7;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}
.deck-card-remove {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.8rem;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.deck-card-remove:hover { color: #ff4444; background: rgba(255,68,68,0.1); }

.deck-empty-msg { text-align: center; color: #444; font-size: 0.85rem; padding: 2rem 1rem; }

/* ── Deck stats / save ──────────────────────────────────────────────── */
.deck-footer {
  border-top: 1px solid #222;
  padding: 0.75rem 1rem;
  background: rgba(17,17,17,0.72);
}
.deck-stats { margin-bottom: 0.6rem; }
.deck-stats-row { display: flex; justify-content: space-between; font-size: 0.78rem; color: #888; margin-bottom: 0.25rem; }
.deck-stats-row .highlight { color: #fff; }
.deck-stats-row .stat-item { display: flex; gap: 0.3rem; }
.stat-rock    { color: #4CAF50; }
.stat-paper   { color: #2196F3; }
.stat-scissors { color: #FF9800; }

.progress-bar-wrap { height: 6px; background: #222; border-radius: 3px; overflow: hidden; margin: 0.5rem 0; }
.progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease, background 0.3s ease;
}
.progress-bar.ok   { background: linear-gradient(90deg, #00ffcc, #00cc99); }
.progress-bar.warn { background: linear-gradient(90deg, #FF9800, #ff6600); }
.progress-bar.over { background: #ff0066; }

.card-total-text { font-size: 0.85rem; text-align: center; color: #aaa; margin-bottom: 0.5rem; }
.card-total-text .cnt { font-size: 1.1rem; font-weight: 700; }
.card-total-text .cnt.ok   { color: #00ffcc; }
.card-total-text .cnt.warn { color: #FF9800; }
.card-total-text .cnt.over { color: #ff0066; }

.validation-msg { font-size: 0.75rem; color: #ff9966; margin-bottom: 0.5rem; min-height: 1rem; text-align: center; }

.btn-save {
  width: 100%;
  padding: 0.65rem;
  background: linear-gradient(90deg, #00ffcc, #00ccff);
  color: #000;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0,255,204,0.4);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  letter-spacing: 0.02em;
}
.btn-save:hover:not(:disabled) { transform: scale(1.02); box-shadow: 0 0 24px rgba(0,255,204,0.7); }
.btn-save:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

.deck-io-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
}
.btn-io {
  flex: 1;
  padding: 0.4rem 0.3rem;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #aaa;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-io:hover { border-color: #00ffcc; color: #00ffcc; }
.btn-io-img { border-color: #444; color: #888; }
.btn-io-img:hover { border-color: #a855f7; color: #a855f7; }

/* ── Modals ──────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.hidden { display: none; }

.modal-box {
  background: #161616;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}
.modal-box h2 { margin: 0 0 0.5rem; color: #00ffcc; font-size: 1.4rem; }
.modal-box p  { color: #888; font-size: 0.9rem; margin: 0 0 1.5rem; }

.modal-form { display: flex; flex-direction: column; gap: 0.75rem; }
.modal-form input {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
.modal-form input:focus { border-color: #00ffcc; }
.modal-form input::placeholder { color: #555; }

.modal-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.btn-login {
  background: linear-gradient(90deg, #00ffcc, #00ccff);
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 0.7rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 10px rgba(0,255,204,0.3);
}
.btn-login:hover { transform: scale(1.02); box-shadow: 0 0 20px rgba(0,255,204,0.5); }
.btn-guest { background: #1a1a1a; border: 1px solid #333; color: #aaa; padding: 0.6rem; border-radius: 10px; font-size: 0.9rem; cursor: pointer; transition: border-color 0.15s; }
.btn-guest:hover { border-color: #555; color: #ccc; }
.modal-link { text-align: center; font-size: 0.82rem; }
.modal-link a { color: #00ccff; background: none; box-shadow: none; text-decoration: underline; }
.modal-error { color: #ff6666; font-size: 0.82rem; text-align: center; min-height: 1rem; }

.modal-confirm { text-align: center; }
.modal-confirm h3 { color: #ff4444; margin: 0 0 0.75rem; }
.modal-confirm p  { color: #aaa; }
.modal-confirm-actions { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1rem; }
.btn-danger { background: linear-gradient(90deg, #ff0066, #ff4400); color: #fff; border: none; padding: 0.6rem 1.2rem; border-radius: 8px; font-weight: 600; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.btn-danger:hover { transform: scale(1.04); box-shadow: 0 0 16px rgba(255,0,102,0.5); }
.btn-cancel { background: #1a1a1a; border: 1px solid #444; color: #aaa; padding: 0.6rem 1.2rem; border-radius: 8px; cursor: pointer; }

/* ── Toast ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1a1a1a;
  border: 1px solid #333;
  color: #fff;
  padding: 0.75rem 1.4rem;
  border-radius: 12px;
  font-size: 0.9rem;
  z-index: 300;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { border-color: #00ffcc; box-shadow: 0 0 16px rgba(0,255,204,0.3); }
.toast.error   { border-color: #ff0066; box-shadow: 0 0 16px rgba(255,0,102,0.3); }
.toast.warn    { border-color: #FF9800; box-shadow: 0 0 16px rgba(255,152,0,0.3); }

/* ── Scrollbar global ───────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: #333 #111; }

/* ── Loading overlay ────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #00ffcc;
  font-size: 1.1rem;
  gap: 1rem;
}
.loading-overlay.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 24px; height: 24px;
  border: 3px solid #333;
  border-top-color: #00ffcc;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  html, body { overflow: auto; }
  .db-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    overflow: visible;
  }
  .panel-left   { height: 60vh; }
  .panel-middle { height: 500px; }
  .panel-right  { height: 70vh; }
}