/* ── Variables y Tema Streaks ───────────────────────── */
:root {
  --bg-app: #e96a46; /* Naranja característico tipo Streaks */
  --bg-app-dark: #d45b3a;
  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);

  --circulo-size: 115px; /* Círculos grandes */
  --radio: 20px; /* Bordes muy redondeados para modales */
  --blanco: #ffffff;
  --texto-oscuro: #2d2d2d;
}

/* ── Reset y tipografía nativa ──────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  /* Usamos SF Pro Rounded en Apple para darle ese toque de app moderna */
  font-family:
    ui-rounded,
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Rounded",
    "Segoe UI",
    Roboto,
    sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Contenedor principal ───────────────────────────── */
.streaks-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* ── Títulos (centrados estilo iOS) ─────────────────── */
h1 {
  font-size: 2.2rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
}

.subtitulo {
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 2.5rem;
  font-size: 1.05rem;
  font-weight: 500;
}

/* ── Navegación de fecha ────────────────────────────── */
.nav-fecha {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 3rem;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.fecha-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 220px;
}

.fecha-texto {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.subtitulo-fecha {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.flecha {
  font-size: 1.2rem;
  color: var(--text-main);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.15);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.flecha:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.flecha-disabled {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.2);
  cursor: default;
}
.flecha-disabled:hover {
  transform: none;
  background: rgba(255, 255, 255, 0.05);
}

/* ── Grid de hábitos ────────────────────────────────── */
.grid-habitos {
  display: grid;
  /* Grid de 2 o 3 columnas como en la app original */
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 3rem 1.5rem;
  justify-items: center;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
}

/* ── Tarjeta de hábito (Invisibles) ─────────────────── */
.tarjeta-habito {
  background: transparent;
  border-radius: 0;
  padding: 0;
  text-align: center;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tarjeta-habito:hover {
  transform: none;
  box-shadow: none;
}

/* ── Botón circular gigante (El núcleo del rediseño) ── */
.btn-habito {
  width: var(--circulo-size);
  height: var(--circulo-size);
  border-radius: 50%;
  /* Estado incompleto: fondo transparente, borde oscuro semitransparente */
  background: transparent !important;
  border: 6px solid rgba(0, 0, 0, 0.12) !important;
  font-size: 3.5rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  -webkit-tap-highlight-color: transparent;
}

.btn-habito:hover {
  transform: scale(1.08);
  border-color: rgba(0, 0, 0, 0.2) !important;
}
.btn-habito:active {
  transform: scale(0.95);
}

/* Estado completado: círculo blanco sólido */
.tarjeta-habito.completado .btn-habito {
  background: var(--blanco) !important;
  border-color: var(--blanco) !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  transform: scale(1.05);
}
.tarjeta-habito.completado .btn-habito:hover {
  transform: scale(1.1);
}
.tarjeta-habito.completado .btn-habito:active {
  transform: scale(0.95);
}

/* Texto del hábito */
.nombre-habito {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

/* Acciones editar/borrar */
.acciones-habito {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.tarjeta-habito:hover .acciones-habito {
  opacity: 1;
}
.acciones-habito a {
  font-size: 0.75rem;
  color: var(--blanco);
  text-decoration: none;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.acciones-habito a:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* ── Formularios (Modales blancos) ──────────────────── */
.formulario {
  background: var(--blanco);
  color: var(--texto-oscuro);
  border-radius: var(--radio);
  padding: 2.5rem;
  max-width: 450px;
  margin: 0 auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.formulario label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: #555;
}

.formulario input,
.formulario select {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
  transition: border-color 0.2s;
  font-family: inherit;
}

/* ── Selector de Emojis ─────────────────────────────── */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem;
  background: #f9f9f9;
  border-radius: 12px;
  border: 2px solid #e0e0e0;
}

.emoji-option {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  height: 45px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  user-select: none;
}

.emoji-option:hover {
  background: #ebebeb;
  transform: scale(1.1);
}

.emoji-option.selected {
  background: rgba(233, 106, 70, 0.1);
  border-color: var(--bg-app);
}

/* Ocultar el input de texto real del icono */
.input-icono-oculto {
  display: none !important;
}

.formulario input:focus,
.formulario select:focus {
  outline: none;
  border-color: var(--bg-app);
}

.btn-primario {
  background: var(--bg-app);
  color: var(--blanco);
  border: none;
  padding: 0.9rem 1.5rem;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.2s,
    background 0.2s;
  width: 100%;
  display: block;
  text-align: center;
}
.btn-primario:hover {
  background: var(--bg-app-dark);
  transform: translateY(-2px);
}
.btn-primario:active {
  transform: translateY(0);
}

.btn-cancelar {
  display: block;
  text-align: center;
  margin-top: 1.25rem;
  margin-left: 0;
  color: #888;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
}
.btn-cancelar:hover {
  color: var(--texto-oscuro);
}

.errores {
  background: rgba(255, 255, 255, 0.9);
  border-left: 5px solid #e74c3c;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 0 auto 1.5rem auto;
  max-width: 450px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}
.errores p {
  color: #c0392b;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}
.errores p:last-child {
  margin-bottom: 0;
}

/* ── Estadísticas (Heatmap) ─────────────────────────── */
.heatmap-contenedor {
  background: var(--blanco);
  border-radius: var(--radio);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  color: var(--texto-oscuro);
}

.heatmap-fila {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid #f5f5f5;
  flex-wrap: wrap; /* Permite que el nombre y las celdas se apilen si no hay espacio */
}
.heatmap-fila:last-child {
  border-bottom: none;
}

.heatmap-nombre {
  min-width: 150px;
  flex: 1 0 150px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--texto-oscuro);
}

.heatmap-icono {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-app);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  color: white;
}

.heatmap-celdas {
  display: flex;
  gap: 4px;
  flex-wrap: wrap; /* CLAVE: Los cuadraditos saltan de línea como un calendario */
  max-width: 380px; /* Ancho máximo para que queden agrupados en bloque */
  justify-content: flex-start;
  flex-grow: 1;
}

.celda {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #f0f0f0;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.celda.hecha {
  background: var(--bg-app) !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.celda:hover {
  transform: scale(1.3);
}

.celda-mes {
  width: 100%;
  font-size: 0.7rem;
  color: #999;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.heatmap-resumen {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 70px;
  flex-shrink: 0;
}

.heatmap-pct {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  color: var(--bg-app);
}

.heatmap-racha {
  font-size: 0.7rem;
  color: var(--bg-app);
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ── Iconos inferiores (Engranaje / Estrella) ───────── */
.streaks-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none; /* Deja hacer clic en cosas detrás si no es justo en el icono */
}

.streaks-icon-bottom {
  font-size: 1.5rem;
  color: var(--text-main);
  text-decoration: none;
  opacity: 0.8;
  transition:
    opacity 0.2s,
    transform 0.2s;
  pointer-events: auto; /* Reactiva los clics en los enlaces */
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.streaks-icon-bottom:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* ── Estadísticas: Tabla resumen ─────────────────────────── */
.tabla-resumen {
  display: flex;
  flex-direction: column;
}

.fila-resumen {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.fila-resumen:last-child {
  border-bottom: none;
}

.resumen-habito {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  color: var(--texto-oscuro);
}

.resumen-racha {
  font-weight: 700;
  color: var(--bg-app);
  font-size: 0.95rem;
}
