/* ═══════════════════════════════════════════════════════
   YACHAY LAB — STREAK CSS
   Widget flotante + Panel + Notificaciones + Confeti
═══════════════════════════════════════════════════════ */

/* ── WIDGET FLOTANTE ─────────────────────────────────── */
.streak-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  background: #0a0e1a;
  border: 1.5px solid rgba(90, 95, 224, 0.35);
  border-radius: 16px;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(90, 95, 224, 0.15);
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s,
    width 0.4s ease;
  min-width: 180px;
  user-select: none;
}
.streak-widget:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(90, 95, 224, 0.6);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(90, 95, 224, 0.2);
}
.sw-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}
.sw-shrink {
  min-width: 0;
  width: 54px;
  padding: 10px;
  border-radius: 50%;
  overflow: hidden;
}
.sw-shrink .sw-info,
.sw-shrink .sw-xp,
.sw-shrink .sw-bar-wrap {
  display: none;
}
.sw-shrink .sw-flame {
  font-size: 22px;
  text-align: center;
}

/* Pop animation al ganar */
.sw-pop {
  animation: swPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes swPop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.14);
  }
  70% {
    transform: scale(0.97);
  }
  100% {
    transform: scale(1);
  }
}

.sw-main {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.sw-flame {
  font-size: 26px;
  line-height: 1;
  animation: flameDance 1.8s ease-in-out infinite alternate;
  flex-shrink: 0;
}
@keyframes flameDance {
  0% {
    transform: rotate(-4deg) scale(1);
  }
  100% {
    transform: rotate(4deg) scale(1.1);
  }
}
.sw-info {
  flex: 1;
}
.sw-num {
  font-size: 22px;
  font-weight: 900;
  color: #f59e0b;
  line-height: 1;
  font-family: "Plus Jakarta Sans", sans-serif;
}
.sw-lbl {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 1px;
}
.sw-xp {
  font-size: 12px;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 20px;
  padding: 3px 9px;
  white-space: nowrap;
  animation: xpPop 0.5s ease;
}
@keyframes xpPop {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.sw-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sw-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}
.sw-fill {
  height: 100%;
  background: linear-gradient(90deg, #5a5fe0, #f59e0b);
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.sw-next {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
}

/* ── NOTIFICACIÓN HITO ────────────────────────────────── */
.streak-milestone {
  position: fixed;
  top: 72px;
  right: 20px;
  z-index: 5000;
  background: #0a0e1a;
  border: 2px solid var(--mc, #f59e0b);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 24px rgba(245, 158, 11, 0.2);
  animation: milestoneIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 320px;
}
@keyframes milestoneIn {
  0% {
    transform: translateX(120%) scale(0.8);
    opacity: 0;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}
.sm-out {
  animation: milestoneOut 0.4s ease forwards;
}
@keyframes milestoneOut {
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}
.sm-icon {
  font-size: 36px;
  animation: flameDance 1.5s ease-in-out infinite alternate;
}
.sm-title {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}
.sm-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 3px;
}

/* ── CONFETI ──────────────────────────────────────────── */
.streak-confetti {
  position: fixed;
  top: -10px;
  z-index: 9000;
  animation: confettiFall 2s ease-out forwards;
  pointer-events: none;
}
@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ── PANEL COMPLETO ───────────────────────────────────── */
.streak-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 20px;
  animation: panelBgIn 0.25s ease;
}
@keyframes panelBgIn {
  from {
    opacity: 0;
  }
}
.sp-out {
  animation: panelBgOut 0.3s ease forwards;
}
@keyframes panelBgOut {
  to {
    opacity: 0;
  }
}

.streak-panel-box {
  background: #0a0e1a;
  border: 1.5px solid rgba(90, 95, 224, 0.3);
  border-radius: 24px;
  width: 360px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: panelIn 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}
@keyframes panelIn {
  0% {
    transform: translateY(30px) scale(0.95);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}
.sp-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sp-fire {
  font-size: 28px;
}
.fire-pulse {
  animation: firePulse 1.5s ease-in-out infinite alternate;
}
@keyframes firePulse {
  0% {
    transform: scale(1) rotate(-3deg);
  }
  100% {
    transform: scale(1.15) rotate(3deg);
  }
}
.sp-title {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}
.sp-sub {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 2px;
}
.sp-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.15s;
}
.sp-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* Hero racha */
.sp-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
}
.sp-hero-info {
  flex: 1;
}
.sp-current-num {
  font-size: 3.5rem;
  font-weight: 900;
  color: #f59e0b;
  line-height: 1;
  font-family: "Plus Jakarta Sans", sans-serif;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sp-current-lbl {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
}
.sp-best {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 8px;
}

/* Stats */
.sp-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: rgba(255, 255, 255, 0.06);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sp-stat {
  padding: 14px 8px;
  text-align: center;
  background: #0a0e1a;
}
.sps-num {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  font-family: "JetBrains Mono", monospace;
}
.sps-lbl {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Milestone progress */
.sp-milestone-progress {
  margin: 16px;
  background: rgba(90, 95, 224, 0.1);
  border: 1px solid rgba(90, 95, 224, 0.2);
  border-radius: 12px;
  padding: 14px;
}
.sp-max {
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  text-align: center;
}
.smp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 10px;
}
.smp-count {
  font-size: 12px;
  font-weight: 700;
  color: #a5b4ff;
  font-family: "JetBrains Mono", monospace;
}
.smp-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 6px;
}
.smp-fill {
  height: 100%;
  background: linear-gradient(90deg, #5a5fe0, #f59e0b);
  border-radius: 8px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}
.smp-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

/* Hitos row */
.sp-milestones-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px 16px;
}
.spm-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
  opacity: 0.35;
  transition: 0.2s;
  cursor: default;
  min-width: 44px;
}
.spm-item.earned {
  opacity: 1;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.1);
}
.spm-icon {
  font-size: 18px;
}
.spm-at {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  font-family: "JetBrains Mono", monospace;
}
.spm-item.earned .spm-at {
  color: #f59e0b;
}

/* Historial */
.sp-history-label {
  padding: 0 16px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.3);
}
.sp-history {
  padding: 0 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sp-hist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: 0.15s;
}
.sp-hist-item:hover {
  background: rgba(255, 255, 255, 0.07);
}
.shi-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.shi-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.shi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}
.shi-time {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.3);
  font-family: "JetBrains Mono", monospace;
}
.shi-xp {
  font-size: 12px;
  font-weight: 700;
  color: #10b981;
  white-space: nowrap;
}
.sp-empty {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  padding: 16px;
}

/* CTA */
.sp-cta {
  margin: 8px 16px 20px;
  width: calc(100% - 32px);
  padding: 13px;
  background: linear-gradient(135deg, #5a5fe0, #8056d6);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 4px 20px rgba(90, 95, 224, 0.4);
}
.sp-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 26px rgba(90, 95, 224, 0.55);
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 480px) {
  .streak-widget {
    bottom: 14px;
    right: 14px;
  }
  .streak-panel-backdrop {
    padding: 0;
    align-items: flex-end;
    justify-content: center;
  }
  .streak-panel-box {
    width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
  }
}
