/* Reset y Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Outfit', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root {
  --bg-app: #090d16;
  --bg-card: rgba(22, 30, 49, 0.65);
  --bg-card-hover: rgba(28, 38, 62, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-active: rgba(99, 102, 241, 0.4);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #090d16;
  
  --primary: #6366f1;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --primary-glow: rgba(99, 102, 241, 0.35);
  
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.25);
  
  /* Colores para las semanas */
  --sem-1: #f43f5e; /* Autoconocimiento - Rosa/Rojo */
  --sem-2: #0ea5e9; /* Presión Social - Celeste */
  --sem-3: #f59e0b; /* Gestión Estrés - Ámbar */
  --sem-4: #10b981; /* Bienestar Digital - Menta */
  --sem-5: #a855f7; /* Cierre del Reto - Púrpura */
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  max-width: 100vw;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Contenedor Principal */
.app-container {
  width: 100%;
  max-width: 1200px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  width: 100%;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-emoji {
  font-size: 2.2rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.app-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Progreso Global */
.progress-container-global {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 400px;
}

.progress-bar-background {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 5px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.progress-legend {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
  font-weight: 500;
}

/* Banner de Estadísticas */
.stats-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  width: 100%;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-icon {
  font-size: 1.8rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px;
  border-radius: var(--radius-sm);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Layout Principal */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

.section-title-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-title-wrapper h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.badge-preventiva {
  background: var(--primary-glow);
  color: #a5b4fc;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Leyenda de Semanas */
.weeks-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.legend-item {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.sem-1 { background-color: var(--sem-1); }
.legend-dot.sem-2 { background-color: var(--sem-2); }
.legend-dot.sem-3 { background-color: var(--sem-3); }
.legend-dot.sem-4 { background-color: var(--sem-4); }
.legend-dot.sem-5 { background-color: var(--sem-5); }

/* Rejilla de Días */
.days-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 6px;
}

@media (max-width: 768px) {
  .app-container {
    padding: 10px;
    gap: 12px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .logo-area {
    gap: 8px;
  }

  .logo-emoji {
    font-size: 1.8rem;
    padding: 6px;
  }

  .app-header h1 {
    font-size: 1.5rem;
  }

  .progress-container-global {
    max-width: 100%;
  }

  .stats-banner {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .stat-card {
    padding: 8px 4px;
    flex-direction: column;
    gap: 4px;
    text-align: center;
    justify-content: center;
    border-radius: var(--radius-sm);
  }

  .stat-icon {
    font-size: 1.2rem;
    padding: 4px;
    margin: 0 auto;
  }

  .stat-value {
    font-size: 1rem;
  }

  .stat-label {
    font-size: 0.55rem;
    letter-spacing: 0;
  }

  .main-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .days-selector-section {
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .days-grid {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 4px;
    max-height: none;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  
  .day-card {
    flex: 0 0 68px;
    height: 68px;
    aspect-ratio: 1 / 1;
    scroll-snap-align: start;
    padding: 6px;
  }
  
  .day-number {
    font-size: 0.8rem;
  }
  
  .day-semana-label {
    font-size: 0.55rem;
  }

  .weeks-legend {
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 12px;
    padding: 8px;
    margin-bottom: 8px;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .legend-item {
    flex: 0 0 auto;
    font-size: 0.7rem;
  }

  .glass-card {
    padding: 16px;
    gap: 16px;
    min-height: auto;
  }

  .day-title {
    font-size: 1.25rem;
  }

  .pilar-tabs-navigation {
    padding: 2px;
  }

  .pilar-tab {
    padding: 8px 4px;
    font-size: 0.7rem;
    gap: 4px;
  }

  .activity-description {
    padding: 10px;
    font-size: 0.85rem;
  }

  textarea {
    min-height: 80px;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }
}

/* Scrollbar Personalizado para la Rejilla */
.days-grid::-webkit-scrollbar {
  width: 6px;
}
.days-grid::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}
.days-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.days-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Tarjeta del Día (Botón) */
.day-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.day-card:hover {
  background: var(--bg-card-hover);
  transform: scale(1.05);
  box-shadow: var(--shadow-sm);
  border-color: rgba(255, 255, 255, 0.2);
}

.day-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
  transform: scale(1.03);
}

.day-number {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.day-semana-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Indicadores de Semana en Tarjetas */
.day-card.semana-1 { border-left: 3px solid var(--sem-1); }
.day-card.semana-2 { border-left: 3px solid var(--sem-2); }
.day-card.semana-3 { border-left: 3px solid var(--sem-3); }
.day-card.semana-4 { border-left: 3px solid var(--sem-4); }
.day-card.semana-5 { border-left: 3px solid var(--sem-5); }

/* Indicadores de Completado */
.day-card.completed {
  background: rgba(16, 185, 129, 0.05);
  border-color: rgba(16, 185, 129, 0.3);
}

.day-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.3);
  border-left-color: rgba(255, 255, 255, 0.15) !important;
}

.day-card.locked:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border-color);
}

.day-lock-indicator {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
}

.day-dots-indicator {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.pilar-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: all 0.3s ease;
}

.pilar-dot.checked {
  background-color: var(--accent);
  box-shadow: 0 0 4px var(--accent);
}

/* Sección de Detalle del Día */
.day-detail-section {
  display: flex;
  flex-direction: column;
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: var(--shadow-lg);
  min-height: 480px;
  width: 100%;
  box-sizing: border-box;
}

.day-detail-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
}

.semana-indicator {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 8px;
}

.day-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

/* Pestañas de Pilares */
.pilar-tabs-navigation {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.pilar-tab {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.pilar-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.02);
}

.pilar-tab.active {
  background: var(--primary);
  color: var(--text-main);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Contenido de la Actividad */
.pilar-content-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.activity-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.duration-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.activity-description {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.15);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.extra-activity-box {
  background: rgba(99, 102, 241, 0.08);
  border: 1px dashed rgba(99, 102, 241, 0.3);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.extra-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: #a5b4fc;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#extra-activity-text {
  font-size: 0.85rem;
  color: #e2e8f0;
  line-height: 1.4;
}

/* Cuadro de Reflexiones (Diario) */
.reflection-journal-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.reflection-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

textarea {
  width: 100%;
  min-height: 110px;
  max-height: 180px;
  resize: vertical;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.5;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.25);
}

/* Botones y Acciones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--text-main);
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
  filter: brightness(1.1);
}

.btn-primary.completed {
  background: var(--accent);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary.completed:hover {
  filter: brightness(1.1);
}

.btn-danger-text {
  background: transparent;
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.2);
  width: auto;
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-danger-text:hover {
  background: rgba(244, 63, 94, 0.08);
}

/* Footer preventivo */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-alert-footer {
  background: rgba(99, 102, 241, 0.05);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.info-alert-footer p {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.footer-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

/* Modal de Celebración */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 13, 22, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.3s ease forwards;
}

.modal-card {
  background: #111827;
  border: 1px solid var(--border-color-active);
  border-radius: var(--radius-lg);
  padding: 30px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal-badge {
  font-size: 3.5rem;
}

.modal-card h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.modal-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-close-btn {
  background: var(--primary-gradient);
  color: var(--text-main);
  border: none;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.modal-close-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

/* Confeti Animación */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

.confetti-particle {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 16px;
  opacity: 0.8;
  animation: fall linear forwards;
}

/* Keyframes */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes fall {
  0% {
    transform: translateY(0) rotate(0deg);
    top: -20px;
    opacity: 1;
  }
  100% {
    transform: translateY(105vh) rotate(720deg);
    opacity: 0;
  }
}
