/* ================================================
   ALBUM DE FIGURINHAS - Copa do Mundo Qatar 2022
   Design: Industrial/Editorial — clean, grid-focused
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg: #f0ede8;
  --bg-card: #fff;
  --surface: #e8e3dc;
  --surface-2: #d8d3cc;
  --border: #ccc7be;

  --text: #1a1a18;
  --text-muted: #6b6860;
  --text-light: #9e9a94;

  --accent: #FF6200;
  --accent-gold: #8B6914;
  --main-grey: #282930;

  --have: #16a34a;
  --have-bg: #dcfce7;
  --have-border: #86efac;

  --highlight: #fef08a;
  --highlight-border: #facc15;

  --cell-size: 42px;
  --cell-gap: 4px;

  --radius: 4px;
  --radius-lg: 8px;

  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);

  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;

  --header-h: 64px;
  --toolbar-h: 56px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Header ---- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--main-grey);
  color: #fff;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}

.header-logo {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 1px;
  line-height: 1;
  white-space: nowrap;
}
.header-logo span {
  color: var(--accent);
}

.header-spacer { flex: 1; }

.header-stats {
  display: flex;
  gap: 24px;
  align-items: center;
}

.stat-block {
  text-align: right;
}
.stat-block .stat-num {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
  color: #fff;
}
.stat-block .stat-label {
  font-size: 10px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.progress-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 30px;
  padding: 6px 14px;
}
.progress-pill .pct {
  font-family: var(--font-display);
  font-size: 20px;
  color: #fff;
}
.progress-pill .pct-bar {
  width: 80px;
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-pill .pct-fill {
  height: 100%;
  background: #4ade80;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ---- Toolbar ---- */
.toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 90;
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  flex: 1;
  max-width: 320px;
  transition: border-color 0.2s;
}
.search-wrap:focus-within {
  border-color: var(--main-grey);
  background: #fff;
}
.search-wrap svg {
  color: var(--text-muted);
  flex-shrink: 0;
}
#searchInput {
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  width: 100%;
  outline: none;
  padding: 8px 0;
  text-transform: uppercase;
}
#searchInput::placeholder {
  text-transform: none;
  font-family: var(--font-body);
  color: var(--text-light);
  font-size: 13px;
}

.toolbar-spacer { flex: 1; }

/* ---- Toolbar action buttons (Export / Import) ---- */
.toolbar-action-btn {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.toolbar-action-btn:hover {
  border-color: var(--main-grey);
  color: var(--main-grey);
  background: var(--surface);
}

.toolbar-filters {
  display: flex;
  gap: 6px;
  align-items: center;
}

.filter-btn {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-btn:hover {
  border-color: var(--main-grey);
  color: var(--main-grey);
}
.filter-btn.active {
  background: var(--main-grey);
  border-color: var(--main-grey);
  color: #fff;
}
.filter-btn.danger.active {
  background: var(--accent);
  border-color: var(--accent);
}

#clearAll {
  background: transparent;
  border: none;
  color: var(--text-light);
  font-size: 12px;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: var(--radius);
  transition: all 0.15s;
}
#clearAll:hover { color: var(--accent); background: #fee2e2; }

/* ---- Toast ---- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--main-grey);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 30px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.error { background: var(--accent); }
#toast.success { background: #16a34a; }

/* ---- Main Layout ---- */
main {
  padding: 24px 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ---- Section ---- */
.album-section {
  margin-bottom: 32px;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.section-group-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-light);
  background: var(--surface);
  padding: 2px 7px;
  border-radius: 3px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.5px;
  color: var(--text);
  flex: 1;
}

.section-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.section-count b {
  color: var(--have);
  font-weight: 600;
}

.section-mini-bar {
  width: 80px;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  align-self: center;
}
.section-mini-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--have);
  transition: width 0.4s ease;
}

/* ---- Sticker Grid ---- */
.sticker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cell-gap);
}

/* ---- Sticker Cell ---- */
.sticker-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.14s ease;
  position: relative;
  overflow: hidden;
}

.sticker-cell:hover {
  border-color: var(--main-grey);
  background: #eef3fa;
  transform: scale(1.08);
  z-index: 2;
  box-shadow: var(--shadow);
}

.sticker-cell .sticker-code {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1;
  text-align: center;
}

.sticker-cell .sticker-check {
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  position: absolute;
  transition: opacity 0.15s;
}

/* ---- HAVE state ---- */
.sticker-cell.have {
  background: var(--have-bg);
  border-color: var(--have-border);
}
.sticker-cell.have .sticker-code {
  color: #166534;
  font-weight: 600;
}
.sticker-cell.have .sticker-check {
  opacity: 1;
}
.sticker-cell.have:hover {
  background: #bbf7d0;
  border-color: var(--have);
}

/* ---- HIGHLIGHT state (search result) ---- */
.sticker-cell.highlighted {
  background: var(--highlight) !important;
  border-color: var(--highlight-border) !important;
  box-shadow: 0 0 0 3px var(--highlight-border), var(--shadow) !important;
  transform: scale(1.15) !important;
  z-index: 10 !important;
  animation: pulse-highlight 1.2s ease 3;
}
@keyframes pulse-highlight {
  0%, 100% { box-shadow: 0 0 0 3px var(--highlight-border); }
  50% { box-shadow: 0 0 0 6px rgba(250, 204, 21, 0.4); }
}

/* ---- Tooltip ---- */
.sticker-cell[data-label]:hover::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--main-grey);
  color: #fff;
  font-family: var(--font-body);
  font-size: 11px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 20;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Color bar on left side of each section ---- */
.album-section {
  padding-left: 8px;
  border-left: 4px solid transparent;
  transition: border-color 0.2s;
}
.album-section:hover {
  border-left-color: var(--section-color, var(--border));
}

/* ---- "Empty" section for filtering ---- */
.album-section.hidden {
  display: none;
}

/* ---- Section anchor offset ---- */
.section-anchor {
  scroll-margin-top: calc(var(--header-h) + var(--toolbar-h) + 16px);
}

/* ---- Jump nav ---- */
#jumpNav {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 80;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 4px;
  box-shadow: var(--shadow);
  max-height: 80vh;
  overflow-y: auto;
}

.jump-item {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.jump-item:hover {
  background: var(--surface);
  color: var(--text);
}
.jump-item.active {
  background: var(--main-grey);
  color: #fff;
}

/* ---- Import Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 0.18s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.5px;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all 0.15s;
}
.modal-close:hover {
  background: var(--surface);
  color: var(--text);
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}
.modal-desc strong {
  color: var(--text);
}

#importTextarea {
  width: 100%;
  height: 120px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
#importTextarea:focus {
  border-color: var(--main-grey);
  background: #fff;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.import-error {
  font-size: 12px;
  color: var(--accent);
  flex: 1;
  min-height: 16px;
}
.import-confirm-btn {
  background: var(--main-grey);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 20px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.import-confirm-btn:hover {
  background: #0f2540;
}

/* ---- Footer ---- */
footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-light);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  :root {
    --cell-size: 38px;
  }
  #jumpNav { display: none; }
  .header-stats { gap: 12px; }
  .progress-pill .pct-bar { width: 50px; }
}

@media (max-width: 640px) {
  :root {
    --cell-size: 34px;
    --cell-gap: 3px;
    --header-h: 56px;
  }
  .header-logo { font-size: 20px; }
  .stat-block .stat-num { font-size: 18px; }
  .progress-pill { display: none; }
  .toolbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .search-wrap { max-width: 100%; }
  .toolbar-filters { width: 100%; }
  main { padding: 16px 12px; }
  .section-title { font-size: 18px; }
}

@media (max-width: 400px) {
  :root {
    --cell-size: 30px;
    --cell-gap: 3px;
  }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ---- Selection ---- */
::selection { background: rgba(26, 58, 92, 0.2); }