/* ── RESET & VARIÁVEIS ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:     #1e8449;
  --brand-dk:  #145a32;
  --brand-lt:  #eafaf1;
  --bg:        #3a3a3a;
  --bg-light:  #4a4a4a;
  --card:      #ffffff;
  --text:      #f0f0f0;
  --text-dark: #1e150d;
  --muted:     #aaaaaa;
  --border:    #555555;
  --border-card: #e5d9ce;
  --green:     #27AE60;
  --green-lt:  #eafbf1;
  --red:       #E74C3C;
  --red-lt:    #fdecec;
  --blue:      #2980B9;
  --blue-lt:   #e8f4fd;
  --purple:    #8E44AD;
  --radius:    14px;
  --shadow:    0 2px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ── LOGIN PAGE ────────────────────────────────── */
.page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-wrapper { width: 100%; max-width: 440px; }

.login-box {
  background: var(--card);
  border-radius: 24px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  border: 1px solid #666;
}

.login-hero { text-align: center; margin-bottom: 32px; }

.login-hero h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.5px;
}

.login-hero p {
  color: #777;
  margin-top: 6px;
  font-size: 14px;
}

/* ── AUTH TABS ─────────────────────────────────── */
.auth-tabs {
  display: flex;
  background: #f0f0f0;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
  border: 1px solid #ddd;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 700;
  color: #888;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--card);
  color: var(--brand);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.auth-hint {
  text-align: center;
  font-size: 13px;
  color: #888;
  margin-top: 16px;
}

/* ── FORMS ─────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 7px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  background: #fafafa;
  color: #1e150d;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--brand);
  background: #fff;
}

.form-input::placeholder { color: #bbb; }

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

/* ── BUTTONS ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-dk);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255,107,53,0.4);
}

.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-light);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--brand); color: var(--brand); }

.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; width: auto; }
.btn-xs { padding: 5px 10px; font-size: 12px; border-radius: 6px; width: auto; }

.btn-green  { background: var(--green); color: #fff; width: auto; }
.btn-green:hover { background: #1e9e50; }

/* ── ALERTS ─────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.alert-error   { background: var(--red-lt);   color: #c0391f; border: 1px solid #f5b7b1; }
.alert-success { background: var(--green-lt);  color: #1a8a48; border: 1px solid #a9dfbf; }
.alert-info    { background: var(--blue-lt);   color: #1a5276; border: 1px solid #aed6f1; }

/* ── LAYOUT INTERNO ─────────────────────────────── */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

/* ── HEADER ─────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, #a9dfbf 0%, #27ae60 60%, #145a32 100%);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-logo {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.3px;
}

.header-right { display: flex; align-items: center; gap: 12px; }

.header-user-name {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) { .header-user-name { display: none; } }

.btn-logout {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  transition: background 0.2s;
}

.btn-logout:hover { background: rgba(255,255,255,0.35); }

/* ── NAV ────────────────────────────────────────── */
.app-nav {
  background: #2e2e2e;
  border-bottom: 1px solid #555;
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.app-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  padding: 15px 22px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: #aaa;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all 0.2s;
}

.nav-btn:hover { color: var(--brand); background: rgba(255,107,53,0.08); }
.nav-btn.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ── CONTENT ────────────────────────────────────── */
.app-content { flex: 1; padding: 24px; max-width: 1100px; margin: 0 auto; width: 100%; }

/* ── CARDS ──────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── FIGURINHAS GRID ─────────────────────────────── */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  align-items: start;
}

.sticker-cell {
  aspect-ratio: 1.4;
  border-radius: 6px;
  border: 1.5px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s;
  font-weight: 800;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  min-width: 0;
  padding: 3px;
}

.sticker-cell:hover { transform: scale(1.08); z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.sticker-cell .cell-num { font-size: 12px; font-weight: 800; line-height: 1.2; text-align: center; }

/* Estado: faltando (vermelho) */
.sticker-cell.s-missing {
  background: #fdecec;
  border-color: #E74C3C;
  color: #c0391f;
}

/* Estado: colada (verde) */
.sticker-cell.s-colada {
  background: #eafbf1;
  border-color: #27AE60;
  color: #1a8a48;
}

/* Estado: repetida (azul) */
.sticker-cell.s-repeated {
  background: #e8f4fd;
  border-color: #2980B9;
  color: #1a5276;
}

/* FWC e CC — mesmo padrão de cores (sem diferenciação) */
.sticker-cell.s-fwc  { background: #fdecec; border-color: #E74C3C; color: #c0391f; }
.sticker-cell.s-cc   { background: #fdecec; border-color: #E74C3C; color: #c0391f; }

/* Controles de repetida */
.sticker-cell .rep-controls {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-top: 1px;
}

.sticker-cell .rep-btn {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--blue);
  background: #fff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.1s;
  flex-shrink: 0;
}

.sticker-cell .rep-btn:hover { background: var(--blue); color: #fff; }

.sticker-cell .rep-count {
  font-size: 12px;
  font-weight: 800;
  color: var(--blue);
  min-width: 14px;
  text-align: center;
}

/* Botão de remover colada */
.sticker-cell.s-colada .remove-btn {
  position: absolute;
  top: -5px; right: -5px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #27AE60;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.sticker-cell.s-colada:hover .remove-btn { display: flex; }
.sticker-cell.s-colada .remove-btn:hover { background: var(--red); }

/* Legenda */
.sticker-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 12px;
  font-weight: 600;
  color: #666;
}

.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 14px; height: 14px; border-radius: 4px; border: 2px solid; }
.dot-missing  { background: var(--red-lt);  border-color: var(--red);   }
.dot-colada   { background: #e0e0e0;        border-color: #999;         }
.dot-repeated { background: var(--green-lt); border-color: var(--green); }

/* ── STATS ──────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: #2e2e2e;
  border: 1px solid #555;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.stat-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
}

.stat-lbl {
  font-size: 12px;
  color: #aaa;
  font-weight: 600;
  margin-top: 4px;
}

/* ── TROCAS ─────────────────────────────────────── */
.match-card {
  background: var(--card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
  transition: box-shadow 0.2s, transform 0.2s;
}

.match-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.match-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff;
  flex-shrink: 0;
}

.match-body { flex: 1; min-width: 0; }
.match-name { font-weight: 800; font-size: 15px; color: var(--text-dark); }
.match-contact { font-size: 13px; color: #888; margin-top: 2px; margin-bottom: 8px; }

.match-section { margin-top: 10px; }
.match-section-title {
  font-size: 13px;
  color: #666;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
}
.match-section-title strong {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-dark);
}

.match-sticker-label { width: 100%; font-size: 12px; color: #888; font-weight: 700; margin-top: 6px; margin-bottom: 2px; }

.match-stickers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.sticker-tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.tag-give { background: var(--green-lt); color: #1a8a48; border: 1px solid var(--green); }
.tag-need { background: var(--red-lt);   color: #c0391f; border: 1px solid var(--red);   }

.match-score {
  flex-shrink: 0;
  background: var(--brand);
  color: #fff;
  border-radius: 12px;
  padding: 8px 14px;
  text-align: center;
  min-width: 56px;
}

.score-num   { font-size: 22px; font-weight: 800; line-height: 1; }
.score-label { font-size: 10px; opacity: 0.85; font-weight: 600; margin-top: 2px; display: block; }

/* ── MURAL ──────────────────────────────────────── */
.post-composer {
  background: var(--card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.post-composer .card-title { color: var(--text-dark); }

.sticker-add-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border-card);
  background: #fff;
  color: #888;
  font-size: 22px;
  font-weight: 300;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  line-height: 1;
}

.sticker-add-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-lt); }

.sticker-selected-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: #777;
}

.sticker-selected-preview img {
  width: 36px; height: 36px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.sticker-selected-preview .remove-sticker {
  cursor: pointer;
  color: var(--red);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  background: none;
  border: none;
  padding: 0 4px;
}

/* Popup de stickers */
.sticker-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sticker-popup {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
}

.sticker-popup h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 16px;
}

.sticker-popup-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.sticker-popup-item {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid #eee;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
  background: #fafafa;
}

.sticker-popup-item:hover { border-color: var(--brand); transform: scale(1.08); }
.sticker-popup-item.selected { border-color: var(--brand); background: var(--brand-lt); box-shadow: 0 0 0 2px var(--brand); }

.sticker-popup-item img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 6px;
}

.sticker-popup-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-cancel { background: #f0f0f0; color: #555; border: none; padding: 9px 18px; border-radius: 8px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.btn-cancel:hover { background: #e0e0e0; }
.btn-confirm { background: var(--brand); color: #fff; border: none; padding: 9px 18px; border-radius: 8px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.btn-confirm:hover { background: var(--brand-dk); }

.post-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.post-actions-left { display: flex; align-items: center; gap: 8px; flex: 1; }

.mural-post {
  background: var(--card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.post-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

.post-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff;
  flex-shrink: 0;
}

.post-author-name { font-weight: 800; font-size: 15px; color: var(--text-dark); }
.post-time { font-size: 12px; color: #888; }

.post-sticker-img {
  display: block;
  width: 120px; height: 120px;
  object-fit: contain;
  margin: 10px auto 14px;
  border-radius: 10px;
}

.post-text {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-dark);
  margin-bottom: 14px;
  word-break: break-word;
}

.reactions { display: flex; gap: 8px; flex-wrap: wrap; }

.reaction-btn {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; gap: 5px;
  font-weight: 600; font-family: inherit;
  color: #666;
}

.reaction-btn:hover { border-color: var(--brand); background: var(--brand-lt); color: var(--brand); }
.reaction-btn.reacted { background: var(--brand-lt); border-color: var(--brand); color: var(--brand); }

/* ── EMPTY STATE ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: #aaa;
}

.empty-state h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: 14px; }

/* ── SECTION HEADER ─────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 13px;
  font-weight: 800;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ── LOADING ─────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 30px;
  color: #aaa;
  font-weight: 600;
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid #555;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}

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

/* ── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 700px) {
  .app-content { padding: 12px; }
  .card { padding: 14px; }
  .stats-row { gap: 8px; }
  .stat-num { font-size: 22px; }
  .sticker-grid { grid-template-columns: repeat(5, 1fr); gap: 3px; }
  .match-card { flex-wrap: wrap; }
  .login-box { padding: 28px 20px; }
}
