/* ============================================================
   Desafio do Porquinho — App styles
   ============================================================ */
@import url('colors_and_type.css');

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--cream-100); }
body { font-family: var(--font-body); color: var(--fg-1); min-height: 100vh; }

.app { max-width: 1280px; margin: 0 auto; padding: 24px 28px 60px; }

/* ============================================================
   HEADER
   ============================================================ */
.hdr { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 0 28px; flex-wrap: wrap; }
.hdr-left { display: flex; align-items: center; gap: 14px; }
.hdr-logo img { width: 56px; height: 56px; display: block; }
.hdr-left > div:last-child { min-width: 0; }
.hdr-title { font-family: var(--font-display); font-weight: 800; font-size: 24px; letter-spacing: -0.03em; color: var(--ink-900); line-height: 1.15; white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; }
.sync-pill { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-body); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 9px 3px 7px; border-radius: 999px; border: 1.5px solid; }
.sync-pill.on { background: var(--success-50); color: var(--success-700); border-color: var(--success-500); }
.sync-pill.off { background: var(--cream-200); color: var(--ink-500); border-color: var(--ink-300); }
.sync-dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.sync-pill.on .sync-dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.hdr-sub { font-family: var(--font-body); font-size: 13px; color: var(--fg-3); margin-top: 2px; font-weight: 500; }

.hdr-right { display: flex; align-items: center; gap: 14px; flex-wrap: nowrap; }
.hdr-total { background: var(--ink-900); color: var(--cream-100); padding: 8px 16px; border-radius: 999px; }
.hdr-total-lbl { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.6; }
.hdr-total-num { font-family: var(--font-numeric); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; color: var(--gold-400); letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap; }

.hdr-days { background: var(--piggy-500); color: white; padding: 6px 12px; border-radius: 14px; border: 2px solid var(--ink-900); box-shadow: 3px 3px 0 0 var(--ink-900); text-align: center; flex-shrink: 0; }
.hdr-days-num { font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1; }
.hdr-days-lbl { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }

/* ============================================================
   BUTTONS (global)
   ============================================================ */
.btn-primary {
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  background: var(--piggy-500); color: white; padding: 12px 22px; border-radius: 999px;
  border: 2.5px solid var(--ink-900); box-shadow: 4px 4px 0 0 var(--ink-900);
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.btn-primary:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 0 var(--ink-900); }
.btn-primary:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 0 var(--ink-900); }
.btn-primary i { width: 18px; height: 18px; }

.btn-ghost {
  background: transparent; color: var(--ink-900); padding: 10px 16px; border-radius: 999px;
  border: 1.5px solid var(--border-2); font-family: var(--font-display); font-weight: 700; font-size: 14px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--dur-fast);
}
.btn-ghost:hover { background: var(--ink-50); }
.btn-ghost i { width: 16px; height: 16px; }

.btn-close {
  width: 40px; height: 40px; border-radius: 999px; background: var(--cream-200);
  border: 2px solid var(--ink-900); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.btn-close:hover { background: var(--piggy-100); }

/* ============================================================
   PIGGIES ROW
   ============================================================ */
.piggies { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.piggy-wrap { position: relative; }

.piggy-card {
  background: white; border: 2.5px solid var(--ink-900); border-radius: 28px; padding: 20px;
  box-shadow: 6px 6px 0 0 var(--ink-900); cursor: pointer;
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.piggy-card:hover { transform: translate(-3px, -3px); box-shadow: 9px 9px 0 0 var(--ink-900); }

.pc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pc-head h3 { font-family: var(--font-display); font-weight: 800; font-size: 26px; letter-spacing: -0.025em; margin: 0; line-height: 1.1; }
.pc-vend { font-size: 12px; color: var(--fg-3); margin-top: 2px; display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.pc-vend i { stroke: var(--fg-3); }
.pc-streak {
  background: var(--ink-900); color: var(--gold-400); padding: 4px 10px 4px 8px;
  border-radius: 999px; font-family: var(--font-display); font-weight: 800; font-size: 14px;
  display: inline-flex; align-items: center; gap: 4px;
}
.pc-streak b { color: var(--gold-400); }

.pc-piggy-wrap { display: flex; justify-content: center; margin: 6px 0 0; padding: 4px 0; }

.pc-amount { display: flex; align-items: baseline; gap: 6px; margin-top: 8px; }
.pc-rs { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--piggy-600); }
.pc-num { font-family: var(--font-display); font-weight: 800; font-size: 48px; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; color: var(--ink-900); }
.pc-sub { font-size: 13px; color: var(--fg-2); margin-top: 4px; }
.pc-sub b { color: var(--ink-900); font-weight: 600; }

.pc-progress {
  height: 14px; background: var(--cream-200); border: 2px solid var(--ink-900);
  border-radius: 999px; overflow: hidden; margin-top: 14px;
}
.pc-progress-bar {
  height: 100%; background: var(--piggy-500);
  transition: width 600ms var(--ease-bounce);
}

.pc-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1.5px dashed var(--border-2); }
.pc-stat { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.pc-stat-num { font-family: var(--font-numeric); font-weight: 800; font-size: 22px; line-height: 1; }
.pc-stat-lbl { font-size: 10px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.pc-stat-meta { font-size: 10px; font-weight: 700; margin-top: 2px; padding: 1px 6px; border-radius: 999px; }
.pc-stat-meta.ok { color: var(--success-700); background: var(--success-50); }
.pc-stat-meta.no { color: var(--danger-700); background: var(--danger-50); }
.pc-stat-status { font-family: var(--font-display); font-weight: 700; font-size: 15px; padding: 5px 10px; border-radius: 999px; }
.pc-stat-status.ok { background: var(--success-500); color: white; }
.pc-stat-status.no { background: var(--danger-500); color: white; }
.pc-stat-status.pending { background: var(--cream-200); color: var(--ink-700); border: 1.5px dashed var(--ink-400); }

/* ============================================================
   COIN SHOWER ANIMATION
   ============================================================ */
.coin-shower { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 5; }
.coin-shower span {
  position: absolute; top: -20px;
  font-family: var(--font-display); font-weight: 800; font-size: 18px;
  color: var(--ink-900); background: var(--gold-400);
  width: 32px; height: 32px; border-radius: 999px; border: 2.5px solid var(--ink-900);
  display: flex; align-items: center; justify-content: center;
  animation: fall 1.4s var(--ease-out) forwards;
}
@keyframes fall {
  0%   { top: -40px; opacity: 0; transform: rotate(0deg); }
  20%  { opacity: 1; }
  100% { top: 70%; opacity: 0; transform: rotate(360deg); }
}

/* ============================================================
   ROW 2: LEADERBOARD + STREAKS
   ============================================================ */
.row-2 { display: grid; grid-template-columns: 380px 1fr; gap: 22px; margin-top: 28px; align-items: flex-start; }

.lb-card { background: white; border: 2.5px solid var(--ink-900); border-radius: 24px; padding: 18px 20px; box-shadow: 5px 5px 0 0 var(--ink-900); }
.lb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.lb-head h3 { font-family: var(--font-display); font-weight: 800; font-size: 22px; margin: 0; letter-spacing: -0.02em; }
.lb-toggle { display: inline-flex; background: var(--ink-50); border-radius: 999px; padding: 3px; gap: 2px; }
.lb-toggle button { background: transparent; border: none; padding: 6px 10px; border-radius: 999px; font-family: var(--font-body); font-weight: 600; font-size: 11px; cursor: pointer; color: var(--fg-2); }
.lb-toggle button.on { background: var(--ink-900); color: white; }

.lb-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 8px; }
.lb-item { display: grid; grid-template-columns: 28px 28px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 18px; background: var(--cream-50); border: 1.5px solid var(--border-1); }
.lb-item.rank-1 { background: linear-gradient(135deg, var(--gold-100), var(--gold-50)); border-color: var(--gold-500); }
.lb-rank { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--ink-700); }
.lb-medal { font-size: 22px; line-height: 1; }
.lb-name { display: flex; flex-direction: column; line-height: 1.15; }
.lb-loja { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.lb-vend { font-size: 11px; color: var(--fg-3); }
.lb-amount { font-family: var(--font-numeric); font-weight: 800; font-size: 18px; text-align: right; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lb-amount-sub { display: block; font-size: 10px; color: var(--fg-3); font-weight: 500; font-family: var(--font-body); margin-top: 2px; }

/* ============================================================
   STREAKS
   ============================================================ */
.streaks-col { display: flex; flex-direction: column; gap: 14px; }
.streak { background: white; border: 2px solid var(--ink-900); border-radius: 20px; padding: 14px 16px; box-shadow: 4px 4px 0 0 var(--ink-900); }
.streak-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.streak-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: -0.015em; }
.streak-legend { display: flex; gap: 12px; font-size: 11px; color: var(--fg-2); }
.streak-legend .lg { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.streak-legend .dot { width: 12px; height: 12px; border-radius: 4px; border: 1.5px solid var(--ink-900); }
.streak-legend .dot.ok { background: var(--success-500); }
.streak-legend .dot.no { background: var(--danger-500); }
.streak-legend .dot.pending { background: var(--cream-50); border-style: dashed; }

.streak-grid { display: grid; grid-template-columns: repeat(13, 1fr); gap: 6px; }
.streak-grid .day {
  aspect-ratio: 1; min-height: 32px; border-radius: 10px; border: 1.5px solid var(--ink-900);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-size: 11px; font-weight: 700; color: var(--ink-900);
  background: var(--cream-200);
}
.streak-grid .day.ok-full { background: var(--success-500); color: white; }
.streak-grid .day.ok-half { background: var(--warn-500); color: white; }
.streak-grid .day.no { background: var(--danger-500); color: white; }
.streak-grid .day.pending { background: var(--cream-50); border-style: dashed; color: var(--ink-400); }
.streak-grid .day.today { box-shadow: 0 0 0 3px var(--piggy-500); transform: scale(1.05); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(31, 20, 36, 0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
  animation: fadeIn var(--dur-base) var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--cream-50); border: 3px solid var(--ink-900); border-radius: 28px;
  box-shadow: 8px 8px 0 0 var(--ink-900);
  width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto;
  animation: popIn 300ms var(--ease-bounce);
}
.modal-detail { max-width: 880px; }
@keyframes popIn { 0% { transform: scale(0.92); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 24px 12px; }
.modal-head h2 { font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: -0.025em; }
.modal-body { padding: 6px 24px 12px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; border-top: 1.5px dashed var(--border-2); margin-top: 8px; }

.date-picker { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.lbl-f { font-family: var(--font-body); font-weight: 600; font-size: 13px; color: var(--ink-800); }
.input {
  font-family: var(--font-body); font-size: 16px; padding: 12px 16px;
  background: white; border: 2px solid var(--ink-900); border-radius: 14px;
  box-shadow: 3px 3px 0 0 var(--ink-900); outline: none; width: 100%;
}
.input:focus { border-color: var(--piggy-500); box-shadow: 3px 3px 0 0 var(--piggy-500); }

.logger-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center;
  background: white; border: 2px solid var(--ink-900); border-radius: 18px; padding: 12px 16px;
  box-shadow: 3px 3px 0 0 var(--ink-900);
}
.logger-nome { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.logger-meta { font-size: 11px; color: var(--fg-3); font-weight: 500; }
.logger-fields { display: flex; gap: 14px; }
.logger-field { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.logger-flbl { font-size: 11px; font-weight: 600; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.06em; }
.logger-tick { font-family: var(--font-display); font-weight: 800; font-size: 14px; padding: 1px 8px; border-radius: 999px; }
.logger-tick.ok { background: var(--success-500); color: white; }
.logger-tick.no { background: var(--danger-100); color: var(--danger-700); }
.logger-gain { text-align: right; }
.gain-pill {
  background: var(--cream-200); color: var(--ink-700); padding: 6px 14px; border-radius: 999px;
  font-family: var(--font-numeric); font-weight: 800; font-size: 16px; border: 1.5px solid var(--border-2);
  white-space: nowrap;
}
.gain-pill.won { background: var(--gold-400); color: var(--ink-900); border-color: var(--ink-900); }

.stepper {
  display: inline-flex; align-items: center; gap: 0;
  border: 2px solid var(--ink-900); border-radius: 999px; padding: 3px;
  background: white; box-shadow: 2px 2px 0 0 var(--ink-900);
}
.stepper button {
  background: var(--cream-200); border: none; width: 30px; height: 30px;
  border-radius: 999px; font-size: 16px; font-weight: 800; cursor: pointer;
  font-family: var(--font-display); color: var(--ink-900);
}
.stepper button:hover { background: var(--piggy-200); }
.stepper input {
  font-family: var(--font-numeric); font-weight: 800; font-size: 18px;
  padding: 0 8px; width: 44px; text-align: center; border: none; outline: none;
  font-variant-numeric: tabular-nums; background: transparent; color: var(--ink-900);
}
.stepper input::-webkit-inner-spin-button { display: none; }

/* ============================================================
   LOJA DETAIL
   ============================================================ */
.detail-hero {
  display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: center;
  padding: 16px 24px; background: linear-gradient(135deg, var(--cream-100), var(--cream-200));
  border-top: 2px dashed var(--border-2); border-bottom: 2px dashed var(--border-2);
  margin: 8px 24px;
  border-radius: 20px;
}
.detail-amount-num {
  font-family: var(--font-display); font-weight: 800; font-size: 64px;
  line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 8px;
}
.detail-amount-num span { font-size: 28px; color: var(--piggy-600); font-weight: 700; }
.detail-amount-sub { font-size: 13px; color: var(--fg-2); margin-top: 4px; }
.detail-perpessoa { display: inline-flex; align-items: center; gap: 8px; background: var(--ink-900); color: var(--gold-400); padding: 8px 14px; border-radius: 999px; margin-top: 10px; font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.detail-perpessoa i { width: 16px; height: 16px; stroke: var(--gold-400); }
.detail-perpessoa small { font-family: var(--font-body); font-weight: 500; font-size: 12px; opacity: 0.7; margin-left: 2px; }

.detail-stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 0 24px; margin-top: 14px; }
.detail-stat { background: white; border: 2px solid var(--ink-900); border-radius: 16px; padding: 12px; text-align: center; box-shadow: 3px 3px 0 0 var(--ink-900); }
.detail-stat-num { font-family: var(--font-numeric); font-weight: 800; font-size: 26px; line-height: 1; }
.detail-stat-num small { font-size: 14px; color: var(--fg-3); font-weight: 600; }
.detail-stat-lbl { font-size: 11px; color: var(--fg-3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; line-height: 1.3; }

.detail-section { padding: 18px 24px 24px; }
.detail-section h3 { font-family: var(--font-display); font-weight: 800; font-size: 18px; margin: 0 0 10px; }
.detail-table { background: white; border: 2px solid var(--ink-900); border-radius: 16px; overflow: hidden; }
.dt-head, .dt-row { display: grid; grid-template-columns: 80px 70px 80px 1fr 110px; align-items: center; padding: 10px 14px; gap: 10px; font-size: 13px; }
.dt-head { background: var(--ink-900); color: var(--cream-100); font-family: var(--font-body); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.dt-row { border-top: 1px solid var(--border-1); }
.dt-row:first-of-type { border-top: none; }
.dt-date { font-family: var(--font-numeric); font-weight: 700; font-variant-numeric: tabular-nums; }
.dt-val { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; color: var(--ink-700); font-weight: 600; }
.dt-status { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; display: inline-block; width: fit-content; }
.dt-status.ok-full { background: var(--success-50); color: var(--success-700); border: 1.5px solid var(--success-500); }
.dt-status.ok-half { background: #FFF1E2; color: #8C4500; border: 1.5px solid var(--warn-500); }
.dt-status.no { background: var(--danger-50); color: var(--danger-700); border: 1.5px solid var(--danger-500); }
.dt-status.pending { background: var(--cream-200); color: var(--ink-500); border: 1.5px dashed var(--ink-400); }
.dt-gain { font-family: var(--font-numeric); font-weight: 800; text-align: right; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.dt-gain.won { color: var(--success-600); }

/* ============================================================
   AUTH MODAL
   ============================================================ */
.modal-auth {
  max-width: 360px;
  padding: 32px 28px 24px;
  text-align: center;
}
.auth-icon {
  font-size: 42px;
  margin-bottom: 8px;
}
.auth-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.02em;
  margin: 0;
}
.auth-sub {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--fg-2);
  margin: 4px 0 18px;
}
.auth-input {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.06em;
}
.auth-input.err {
  border-color: var(--danger-500);
  box-shadow: 3px 3px 0 0 var(--danger-500);
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.auth-error {
  color: var(--danger-600);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
}
.auth-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

/* ============================================================
   RESET / MISC
   ============================================================ */
.reset-row { margin-top: 28px; display: flex; justify-content: center; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 880px) {
  .piggies { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .hdr { gap: 14px; }
  .hdr-right { width: 100%; justify-content: space-between; }
  .detail-stats-row { grid-template-columns: repeat(2, 1fr); }
  .detail-hero { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .dt-head, .dt-row { grid-template-columns: 70px 60px 70px 1fr 90px; font-size: 12px; }
}
@media (min-width: 881px) and (max-width: 1100px) {
  .pc-num { font-size: 38px; }
  .pc-amount { gap: 4px; }
  .pc-rs { font-size: 18px; }
  .pc-head h3 { font-size: 22px; }
  .pc-stats { gap: 4px; }
  .pc-stat-num { font-size: 18px; }
  .piggies { gap: 14px; }
  .piggy-card { padding: 16px; }
}
@media (max-width: 640px) {
  .app { padding: 16px 14px 40px; }
  .hdr-title { font-size: 20px; }
  .hdr-total-num { font-size: 18px; }
  .pc-num { font-size: 38px; }
  .streak-grid { grid-template-columns: repeat(7, 1fr); }
  .logger-row { grid-template-columns: 1fr; }
  .logger-fields { justify-content: space-around; }
  .detail-stats-row { grid-template-columns: 1fr 1fr; }
}
