/* ═══════════════════════════════════════════════
   PROGRESS & STREAK SYSTEM (Agente B)
   Standalone CSS for app/index.html
   ═══════════════════════════════════════════════ */

/* --- Streak Dashboard --- */
.streak-dashboard {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.streak-dashboard-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.875rem 24px;
}

.streak-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.streak-counter {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.streak-fire {
  font-size: 1.25rem;
  line-height: 1;
}

.streak-fire.streak-risk {
  filter: grayscale(1);
  opacity: 0.5;
}

.streak-number {
  font-family: var(--font-headline);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.streak-label {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  line-height: 1;
}

.streak-best {
  font-size: 0.6875rem;
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

.streak-right {
  flex: 1;
  min-width: 0;
  max-width: 300px;
}

.progress-bar-global {
  position: relative;
  height: 6px;
  background: var(--color-border-light);
  border-radius: 3px;
  overflow: visible;
}

.progress-fill-global {
  height: 100%;
  background: var(--color-accent);
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-block-marker {
  position: absolute;
  top: -2px;
  width: 1px;
  height: 10px;
  background: var(--color-text-tertiary);
  opacity: 0.3;
}

.progress-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
}

.progress-label-global {
  font-size: 0.6875rem;
  color: var(--color-text-tertiary);
  font-variant-numeric: tabular-nums;
}

.streak-calendar-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--color-accent);
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.streak-calendar-btn .material-symbols-sharp {
  font-size: 16px;
}

/* Streak bounce animation */
@keyframes streakBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.streak-bounce {
  animation: streakBounce 0.4s ease;
}

/* --- Desc + Button wrapper --- */
.progress-bottom-wrap {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: auto;
  min-height: 0;
  flex-shrink: 1;
  overflow: hidden;
}

/* --- Complete Exercise Button --- */
.progress-complete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 0.675rem 1.75rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  color: #FFFFFF;
  background: var(--color-accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.progress-complete-btn.completed {
  background: white;
  color: #e24d19;
  gap: 12px;
  font-weight: bold;
}

/* Light theme cards */
.progress-btn-light {
  color: white;
  border-color: rgba(21, 21, 21, 0.15);
  gap: 12px;
  font-weight: bold;
}

.progress-btn-light.completed {
  background: #06a206;
  color: #FFFFFF;
}

.progress-complete-icon {
  font-size: 0.875rem;
  line-height: 1;
}

/* --- Card completed state --- */
.card-completed {
  --card-accent: #08a208 !important;
}

.card-completed .card-icon {
  filter: drop-shadow(0 0 20px rgba(8, 162, 8, 0.5)) drop-shadow(0 0 40px rgba(8, 162, 8, 0.3)) !important;
}

.card-completed .card-block {
  color: #08a208;
}

/* --- Calendar Modal --- */
.progress-calendar-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.progress-calendar-modal.active {
  opacity: 1;
  visibility: visible;
}

.progress-calendar-content {
  background: var(--color-bg);
  border-radius: 12px;
  width: 90%;
  max-width: 380px;
  padding: 1.25rem;
  position: relative;
}

.progress-calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  position: relative;
}

.progress-calendar-title {
  font-family: var(--font-headline);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  min-width: 150px;
  text-align: center;
}

.progress-calendar-nav {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.progress-calendar-nav:hover {
  background: var(--color-bg-alt);
}

.progress-calendar-nav .material-symbols-sharp {
  font-size: 20px;
}

.progress-calendar-close {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
}

.progress-calendar-close:hover {
  color: var(--color-text);
}

.progress-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.progress-calendar-weekdays span {
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-tertiary);
  padding: 4px 0;
}

.progress-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.progress-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  position: relative;
  cursor: default;
}

.progress-cal-empty {
  background: transparent;
}

.progress-cal-daynum {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Calendar intensity levels */
.progress-cal-level-0 {
  background: #f8f8f8;
}

.progress-cal-level-1 {
  background: rgba(6, 162, 6, 0.15);
}

.progress-cal-level-1 .progress-cal-daynum {
  color: #06a206;
  font-weight: 600;
}

.progress-cal-level-2 {
  background: rgba(6, 162, 6, 0.35);
}

.progress-cal-level-2 .progress-cal-daynum {
  color: #058005;
  font-weight: 600;
}

.progress-cal-level-3 {
  background: rgba(6, 162, 6, 0.6);
}

.progress-cal-level-3 .progress-cal-daynum {
  color: #fff;
  font-weight: 700;
}

.progress-cal-streak-break {
  background: rgba(255, 59, 48, 0.15);
}

.progress-cal-streak-break .progress-cal-daynum {
  color: #FF3B30;
  font-weight: 600;
}

.progress-cal-today {
  outline: 2px solid #06a206;
  outline-offset: -1px;
}

/* Calendar legend */
.progress-calendar-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e8e8e8;
}

.progress-cal-legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.625rem;
  color: var(--color-text-tertiary);
}

.progress-cal-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.progress-cal-swatch-0 {
  background: var(--color-bg-alt);
}

.progress-cal-swatch-1 {
  background: rgba(6, 162, 6, 0.2);
}

.progress-cal-swatch-3 {
  background: rgba(6, 162, 6, 0.6);
}

.progress-cal-swatch-break {
  background: rgba(255, 59, 48, 0.3);
}

/* --- Mobile Responsive --- */
@media (max-width: 480px) {
  .streak-dashboard-inner {
    padding: 0.875rem 0.75rem;
  }

  .streak-number {
    font-size: 1.1rem;
  }

  .streak-fire {
    font-size: 1.1rem;
  }

  .streak-best {
    display: none;
  }

  .streak-right {
    max-width: 200px;
  }

  .progress-complete-btn {
    padding: 0.8rem 0.5rem;
    font-size: 0.9rem;
  }

  .progress-calendar-content {
    width: 95%;
    padding: 1rem;
  }
}

/* Calendar loading spinner */
.cal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6rem 0;
  grid-column: 1 / -1;
}

.cal-loading-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(226, 77, 25, 0.2);
  border-top-color: #e24d19;
  border-radius: 50%;
  animation: calSpin 0.6s linear infinite;
}

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

@media (max-width: 767px) {
  .streak-right {
    max-width: 240px;
  }
}

/* ═══════════════════════════════════════════════
   NOTIFICATION PREFERENCES MODAL
   ═══════════════════════════════════════════════ */

.notif-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.notif-modal.active {
  opacity: 1;
  visibility: visible;
}

.notif-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.notif-modal-content {
  position: relative;
  background: var(--color-bg, #fff);
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  transform: translateY(16px);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.notif-modal.active .notif-modal-content {
  transform: translateY(0);
}

.notif-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.notif-modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text, #111);
}

.notif-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-text-tertiary, #888);
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
}

.notif-modal-close:hover {
  color: var(--color-text, #111);
}

.notif-modal-body {
  padding: 16px 20px 24px;
}

.notif-desc {
  margin: 0 0 20px;
  font-size: 0.875rem;
  color: var(--color-text-secondary, #555);
  line-height: 1.5;
}

.notif-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0 0 16px;
}

.notif-toggle-text {
  font-size: 0.9375rem;
  color: var(--color-text, #111);
  font-weight: 500;
}

/* iOS-style toggle switch */
.notif-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.notif-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.notif-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ccc;
  border-radius: 28px;
  transition: background 0.25s ease;
}

.notif-switch-slider::before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.notif-switch input:checked + .notif-switch-slider {
  background: var(--color-accent, #FF5006);
}

.notif-switch input:checked + .notif-switch-slider::before {
  transform: translateX(20px);
}

.notif-hour-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid var(--color-border-light, #e0e0e0);
  transition: opacity 0.25s ease;
}

.notif-hour-label {
  font-size: 0.875rem;
  color: var(--color-text, #111);
}

.notif-hour-select {
  padding: 6px 12px;
  border: 1px solid var(--color-border, #d0d0d0);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--color-bg, #fff);
  color: var(--color-text, #111);
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.notif-hour-select:focus {
  border-color: var(--color-accent, #FF5006);
}

.notif-status {
  margin-top: 12px;
  font-size: 0.8125rem;
  min-height: 1.2em;
  transition: opacity 0.3s ease;
}

.notif-status:empty {
  opacity: 0;
}

.notif-status-saving {
  color: var(--color-text-tertiary, #888);
}

.notif-status-success {
  color: #4CAF50;
}

.notif-status-error {
  color: #e53935;
}

@media (max-width: 480px) {
  .notif-modal-content {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
  }

  .notif-modal.active .notif-modal-content {
    transform: translateY(0);
  }

  .notif-modal {
    align-items: flex-end;
    padding: 0;
  }
}
