/* public/style.css */

/* --------------------------------------------
   Reset básico y prevención de scroll horizontal
   -------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html, body {
  overflow-x: hidden; /* nada de scroll horizontal */
}

/* --------------------------------------------
   Tipografía y fondo
   -------------------------------------------- */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.4;
}

/* --------------------------------------------
   Header sticky
   -------------------------------------------- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 {
  font-size: 1.5rem;
}
header button {
  background: #6200ee;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

/* --------------------------------------------
   Filtros
   -------------------------------------------- */
#filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}
#filters input,
#filters select,
#filters button {
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 0.4rem;
  font-size: 0.9rem;
}
#filters button {
  background: #6200ee;
  color: #fff;
  border: none;
  cursor: pointer;
}

/* --------------------------------------------
   Registros y tarjetas
   -------------------------------------------- */
#records {
  padding: 0.8rem;
}
.record {
  background: #fff;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.record .actions {
  display: flex;
  gap: 0.5rem;
}
.record .actions button {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
}

/* --------------------------------------------
   Agrupación por tiempo
   -------------------------------------------- */
.group-title {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.25rem;
  color: #444;
  border-bottom: 2px solid #ddd;
  padding-bottom: 0.25rem;
}

/* ============================================
   MODAL OVERLAY (sin scroll horizontal)
   ============================================ */
#modal.hidden {
  display: none;
}
#modal {
  position: fixed;
  inset: 0;                     /* top:0; right:0; bottom:0; left:0 */
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;      /* centrar horizontal */
  align-items: flex-start;      /* iniciar arriba */
  padding: 1rem;
  z-index: 1000;
  overflow: hidden;             /* sin scroll en overlay */
}

/* ============================================
   CONTENIDO DEL MODAL
   ============================================ */
.modal-content {
  background: #fff;
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 2rem);   /* deja espacio para el padding */
  border-radius: 0.6rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;                 /* ÚNICO scroll interno */
  -webkit-overflow-scrolling: touch;/* suaviza scroll en iOS */
}

/* Sticky header dentro del modal */
.modal-content h2 {
  margin: 0;
  padding: 1rem;
  background: #6200ee;
  color: #fff;
  font-size: 1.2rem;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ============================================
   CUERPO DEL FORMULARIO (sin scroll propio)
   ============================================ */
.modal-content form {
  flex: 1 1 auto;                  /* ocupa espacio restante */
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

/* Inputs y selects al 100% ancho */
.modal-content form input[type="text"],
.modal-content form input[type="time"],
.modal-content form input[type="number"],
.modal-content form input[type="date"],
.modal-content form textarea,
.modal-content form select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 0.4rem;
  font-size: 0.9rem;
}

/* Ajuste para checkbox */
.modal-content form input[type="checkbox"] {
  transform: scale(1.1);
  margin-right: 0.5rem;
}

/* ============================================
   FOOTER STICKY CON BOTONES
   ============================================ */
.modal-content .buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fff;
  position: sticky;
  bottom: 0;
  z-index: 1;
  border-top: 1px solid #e0e0e0;
}

/* Botones consistentes */
.modal-content .buttons button {
  flex: none;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.modal-content .buttons #saveBtn {
  background: #6200ee;
  color: #fff;
}
.modal-content .buttons #closeBtn {
  background: #ccc;
  color: #333;
}

/* ============================================
   OPTIMIZACIONES PARA TECLADO EN MÓVIL
   ============================================ */
/* Cuando el teclado aparece, reasignamos la altura del modal-content */
@supports (height: 100dvh) {
  .modal-content {
    max-height: calc(100dvh - 2rem);
  }
}

/* ============================================
   MEDIA QUERY PANTALLAS PEQUEÑAS
   ============================================ */
@media (max-width: 360px) {
  .modal-content {
    max-width: 100%;
    margin: 0;
    max-height: calc(100vh - 1rem);
  }
  .modal-content .buttons {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ============================================
   MEDIA QUERY PANTALLAS MÁS ANCHAS
   ============================================ */
@media (min-width: 600px) {
  header h1 {
    font-size: 1.75rem;
  }
  .record {
    padding: 1rem 1.25rem;
  }
}

/* Subtítulo/fecha en los registros */
.subtext {
  font-size: 0.9rem;
  margin-top: 2px;
  line-height: 1.3;
}
.subtext.muted {
  color: #6b7280; /* gris suave */
}

/* Asegura alineación vertical en la tarjeta */
.record .record-main {
  display: flex;
  flex-direction: column;
}

/* ======= HABIT CARDS ======= */
.habit-card{
  background: #fff;
    border-radius: 10px;
    padding: 10px 10px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
    margin-bottom: 10px;
}
.habit-main{ flex:1 1 auto; min-width:0; }
.habit-title{
  display:flex; align-items:center; gap:8px; flex-wrap:wrap;
}
.habit-title .emoji{ font-size:20px; }
.habit-title strong{ font-size:1.1rem; }
.habit-title .reg-link{
  color:#111; text-decoration:underline; opacity:.85; font-size:0.8rem;
}
.habit-meta{
  margin-top: 6px;
    color: #6b7280;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.8rem;
}
.habit-meta .icon{ margin-right:1px; }
.habit-chips{ margin-top:10px; display:flex; gap:8px; flex-wrap:wrap; }
.chip{
  color: #fff;
    background: #4CAF50;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: bold;
    font-size: .7rem;
    letter-spacing: .03rem;
}
.chip-alt{
  background:#5cb85c; /* verde alterno */
}
.habit-actions{ display:flex; align-items:center; gap:10px; }
.habit-actions button{
  background:transparent; border:none; font-size:22px; cursor:pointer; line-height:1;
  padding:4px;
}
