/* ===========================================================================
   02-CALENDAR · Rejilla, Días, Métricas, NADA
   =========================================================================== */
.calendar-shell { overflow: visible; padding: 2px; }
.calendar { min-width: 980px; display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 11px; }

.weekday {
  z-index: auto;
  margin: 0;
  min-height: 48px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #eafbe6;
  background:
    radial-gradient(circle at 18% 20%, rgba(126,224,138,.18), transparent 34%),
    radial-gradient(circle at 82% 85%, rgba(64,196,122,.13), transparent 38%),
    linear-gradient(145deg, #173b28 0%, #10291c 48%, #0b1d14 100%);
  border: 1px solid rgba(63,163,74,.72);
  border-radius: 10px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.07),
    inset 0 -8px 18px rgba(0,0,0,.18),
    0 4px 12px rgba(0,0,0,.22);
  transition: border-color .2s ease, box-shadow .2s ease, filter .2s ease;
}
.weekday::before {
  content: '';
  position: absolute;
  inset: 1px;
  z-index: -1;
  border-radius: 9px;
  background:
    radial-gradient(circle at 12% 72%, rgba(126,224,138,.14) 0 2px, transparent 2.5px),
    radial-gradient(circle at 88% 28%, rgba(126,224,138,.10) 0 1.5px, transparent 2px),
    linear-gradient(115deg, transparent 18%, rgba(255,255,255,.035) 50%, transparent 82%);
  background-size: auto, auto, 180% 100%;
  pointer-events: none;
}
.weekday:hover {
  border-color: rgba(126,224,138,.92);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.09),
    inset 0 -8px 18px rgba(0,0,0,.16),
    0 6px 16px rgba(34,197,94,.14);
  filter: brightness(1.05);
}


.day { position: relative; min-height: 311px; display: flex; flex-direction: column; overflow: hidden; background: linear-gradient(152deg, var(--panel), color-mix(in srgb, var(--panel) 88%, var(--bg))); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s, border-color .25s; }
.day:not(.empty):not(.ghost):hover { transform: translateY(-4px); box-shadow: 0 18px 38px rgba(0,0,0,.45); z-index: 50; }
.day.empty { visibility: hidden; }
.day.ghost { opacity: .40; filter: saturate(.62) brightness(.92); cursor: default; }
.day.ghost.has-data { opacity: 0.62; filter: saturate(0.75) brightness(0.92); }

.day.green { background: linear-gradient(152deg, #1c3a2c, #163524); border-top: 5px solid #22c55e; }
.day.blue { background: linear-gradient(152deg, #16314a, #122a40); border-top: 5px solid #3b82f6; }
.day.yellow { background: linear-gradient(152deg, #3a3413, #332d10); border-top: 5px solid #eab308; }
.day.red { background: linear-gradient(152deg, #3a1c1c, #321818); border-top: 5px solid #ef4444; }
.day.phase-root { border-top: 5px solid var(--phase-root) !important; }
.day.phase-grow { border-top: 5px solid var(--phase-grow) !important; }
.day.phase-bloom { border-top: 5px solid var(--phase-bloom) !important; }
.day.phase-dry { border-top: 5px solid var(--phase-dry) !important; }

.day-head { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 8px 9px 8px 14px; border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
.day-head strong { font-size: 30px; line-height: 1; letter-spacing: -.05em; font-family: var(--font-display); }
.day-head strong.today { color: var(--primary); font-size: 33px !important; }
.day-num-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; }
.week-badge { font-family: var(--font-display); font-size: .6rem; font-weight: 800; color: color-mix(in srgb, var(--wb, var(--muted)) 72%, #fff); padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, var(--wb, var(--muted)) 16%, transparent); border: 1px solid color-mix(in srgb, var(--wb, var(--muted)) 34%, transparent); pointer-events: none; user-select: none; white-space: nowrap; }
.actions { display: flex; gap: 5px; }
.day-action { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: color-mix(in srgb, var(--panel) 80%, transparent); color: var(--text); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; transition: border-color .15s; }
.day-action:hover { border-color: var(--primary); }
.day-action:disabled { cursor: not-allowed; opacity: .5; }
.day .lock-btn { pointer-events: auto !important; opacity: 1 !important; cursor: pointer !important; }

/* --- NOTAS --- */
.note-area { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: linear-gradient(to bottom, transparent 0%, color-mix(in srgb, var(--text) 2.2%, transparent) 100%); }
.note-mirror { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow-y: auto; padding: 8px 13px; font-size: 10px; line-height: 1.5; color: rgba(255,255,255,.85); white-space: pre-wrap; word-wrap: break-word; scrollbar-width: thin; scrollbar-color: var(--primary) transparent; }
.note-mirror::-webkit-scrollbar { width: 6px; } .note-mirror::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }
.note-mirror-scroll > div.ml-dead { color: #ef4444 !important; font-weight: 700; }
.note-mirror-scroll > div.ml-problem { color: #eab308 !important; font-weight: 700; }
textarea { position: relative; z-index: 1; flex: 1; width: 100%; min-height: 64px; padding: 8px 13px; border: 0; resize: none; background: transparent; color: transparent; caret-color: var(--primary); font-size: 10px; line-height: 1.5; scrollbar-width: none; }
textarea::-webkit-scrollbar { display: none; }
textarea::placeholder { color: transparent; }
textarea:focus { outline: none; background: color-mix(in srgb, var(--primary) 6%, transparent); box-shadow: inset 0 -2px 0 0 color-mix(in srgb, var(--primary) 60%, transparent); }
textarea:disabled { cursor: not-allowed; opacity: .24; }

/* --- MÉTRICAS --- */
.metrics { position: relative; display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "temp hum" "ph ec" "nada nada"; gap: 6px; padding: 7px 11px 8px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 58%, transparent); }
/* GP-TUYA-SENSOR-BTN-V1: lee Temp/Hum del sensor SmartLife/Tuya del día actual. */
.sensor-read-btn { position: absolute; top: -14px; right: 8px; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); color: var(--primary-glow); font-size: .9rem; display: grid; place-items: center; box-shadow: 0 3px 8px rgba(0,0,0,.35); z-index: 2; }
.sensor-read-btn:hover { border-color: var(--primary); }
.sensor-read-btn:disabled { opacity: .6; cursor: not-allowed; }
/* El "display: grid" de arriba gana siempre al atributo hidden (una regla
   de display en tu propio CSS pisa el estilo por defecto del navegador
   para [hidden], por poco específica que sea) — así que aunque JS ponga
   btn.hidden=true, el botón seguía viéndose. Con el selector [hidden] de
   más especificidad esta sí gana. */
.sensor-read-btn[hidden] { display: none !important; }
.metric { display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-width: 0; color: var(--muted); font-size: .73rem; font-weight: 800; text-transform: uppercase; }
.metric[data-metric="temp"] { grid-area: temp; } .metric[data-metric="hum"] { grid-area: hum; }
.metric[data-metric="ph"] { grid-area: ph; display: none; } .metric[data-metric="ec"] { grid-area: ec; display: none; }
.metrics.has-ph-ec .metric[data-metric="ph"], .metrics.has-ph-ec .metric[data-metric="ec"] { display: flex; animation: metricIn .26s ease both; }
@keyframes metricIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.metric-field { position: relative; display: flex; align-items: center; width: 100%; height: 29px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); transition: border-color .2s; }
.metric-field:focus-within:not(.out-of-range) { border-color: var(--primary); }
.metric-field.out-of-range { border-color: var(--danger); background: #1b0d0d; box-shadow: 0 0 8px rgba(239,68,68,.3); }
.metric-field input { flex: 1; width: 100%; height: 100%; padding: 3px 8px; border: 0; background: transparent; color: var(--text); text-align: center; font-size: .8rem; font-weight: 700; }
.metric-field input.out-of-range { color: var(--danger-bright); }
.metric-tooltip { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 9999; background: #1c1917; color: #fca5a5; border: 1px solid rgba(239,68,68,.5); border-radius: 8px; padding: 8px 12px; font-size: .78rem; font-weight: 600; max-width: 260px; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.5); text-align: center; white-space: normal; }
.metric-tooltip[hidden] { display: none; }
.metric-tooltip::before { content: ''; position: absolute; top: -6px; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-bottom-color: rgba(239,68,68,.5); }

.nothing { height: 29px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--muted); font-size: .7rem; font-weight: 800; align-self: center; display: flex; align-items: center; justify-content: center; transition: transform .15s; grid-area: nada; }
.nothing:hover { transform: translateY(-1px); border-color: var(--primary); color: var(--primary); }

/* --- NADA OVERLAY --- */
.nothing-overlay { position: absolute; z-index: 3; inset: 0; display: none; place-items: center; pointer-events: auto; cursor: pointer; font-family: Arial, sans-serif; font-size: 120px; line-height: 1; font-weight: 800; text-align: center; }
.day.nothing-active .nothing-overlay { display: grid; animation: nadaPop .22s ease-out; }
@keyframes nadaPop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
.nothing-overlay span { color: #60a5fa; }
.nothing-overlay.phase-root span { color: var(--phase-root); } .nothing-overlay.phase-grow span { color: var(--phase-grow); } .nothing-overlay.phase-bloom span { color: var(--phase-bloom); } .nothing-overlay.phase-dry span { color: var(--phase-dry); }

.nada-halo { position: absolute; width: 220px; height: 220px; border-radius: 50%; pointer-events: none; filter: blur(16px); animation: haloPulse 2.6s ease-in-out infinite; }
@keyframes haloPulse { 0%, 100% { transform: scale(.88); opacity: .22; } 50% { transform: scale(1.1); opacity: .42; } }
.nada-x { width: 132px; height: 132px; overflow: visible; position: relative; animation: nadaTilt .6s cubic-bezier(.2,.85,.25,1) both; filter: drop-shadow(0 4px 10px rgba(0,0,0,.6)); }
@keyframes nadaTilt { from { transform: scale(.4) rotate(-14deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.nada-x .nada-glow line { stroke-linecap: round; stroke-width: 22; fill: none; filter: blur(9px); animation: glowPulse 2.2s ease-in-out infinite; }
@keyframes glowPulse { 0%, 100% { opacity: .17; } 50% { opacity: .40; } }
.nada-x .nada-main line { stroke-linecap: round; stroke-width: 15; fill: none; stroke-dasharray: 84; stroke-dashoffset: 84; }
.nada-x .nada-main .s1 { animation: nadaDraw .45s .10s cubic-bezier(.3,.8,.3,1) forwards; }
.nada-x .nada-main .s2 { animation: nadaDraw .45s .28s cubic-bezier(.3,.8,.3,1) forwards; }
@keyframes nadaDraw { to { stroke-dashoffset: 0; } }
.nada-x .nada-spark { opacity: 0; animation: sparkTw 1.8s ease-in-out infinite; }
.nada-x .sp2 { animation-delay: .9s; }
@keyframes sparkTw { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }

/* --- MEDALLAS --- */
.perfect-star { display: inline-block; font-size: 1.5rem; line-height: 1; vertical-align: middle; margin-left: 3px; }
.perfect-star.star-gold { filter: drop-shadow(0 0 4px rgba(234,179,8,.5)); }
.perfect-star.star-silver { filter: drop-shadow(0 0 4px rgba(192,192,192,.5)) grayscale(.3); }
.perfect-star.star-bronze { filter: drop-shadow(0 0 4px rgba(205,127,50,.5)); color: #cd7f32; }

/* --- DÍA HOY --- */
.day.today { border-color: color-mix(in srgb, var(--primary-glow) 70%, var(--line)); box-shadow: var(--shadow); }
/* El fondo verde de "HOY" solo se aplica si el día no tiene ya un color
   de riego/fertilización/problema/muerte propio -si no, "HOY" siempre
   pintaba por encima con la misma especificidad que .day.blue/.green/
   etc. pero apareciendo más abajo en este archivo, así que ganaba
   siempre sin importar lo que el día tuviera marcado de verdad-. */
.day.today:not(.blue):not(.green):not(.yellow):not(.red) { background: linear-gradient(152deg, color-mix(in srgb, var(--primary) 16%, var(--panel)), var(--panel)); }
.day.today::before { content: "HOY"; position: absolute; top: -11px; left: 50%; transform: translateX(-50%); z-index: 6; padding: 3px 12px; border-radius: 999px; background: linear-gradient(135deg, var(--primary-glow), var(--primary)); color: #06130a; font-family: var(--font-display); font-size: .62rem; font-weight: 800; letter-spacing: .14em; box-shadow: 0 4px 12px rgba(126,224,138,.5); }
.day.today:not(.ghost):hover { transform: translateY(-4px); box-shadow: 0 18px 38px rgba(0,0,0,.45); }

/* --- MENÚ CONTEXTUAL --- */
.menu { position: fixed; z-index: 1000; display: none; width: 184px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 38px #00000066; }
.menu.open { display: block; }
.color-option { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; }
.color-option:hover { background: var(--bg); }

/* --- RESPONSIVE CALENDARIO --- */
@media (max-width: 1040px) { .calendar-shell { overflow-x: auto; } }
/* En móvil, se muestra un solo día a pantalla completa; los demás se
   ven deslizando el dedo horizontalmente, con "snap" para que cada
   uno encaje entero en la pantalla en vez de quedar a medias.
   #calendar es una rejilla de 7 columnas (una fila = una semana): si
   solo se ensancha cada columna, cada "semana" se vuelve enorme y se
   apilan verticalmente. Por eso aquí se cambia a una fila continua
   (flex) con los 42 días uno detrás de otro, en vez de conservar la
   semana como unidad. Las 7 etiquetas de "Lunes"..."Domingo" (una
   sola vez, no por día) ya no encajan en este esquema y se ocultan;
   cada día ya indica por sí solo si es "HOY". */
@media (max-width: 640px) {
  .calendar { display: flex !important; flex-wrap: nowrap; min-width: 0; gap: 8px; height: 100%; }
  .calendar-shell { scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
  .day { flex: 0 0 calc(100vw - 28px); scroll-snap-align: start; }
  .weekday { display: none; }
  /* Solo un margen para que la etiqueta "HOY" (que sobresale por encima de
     la tarjeta) no quede pegada a la barra de arriba. No se toca body/.app
     aquí a propósito: hacerlo la última vez desplazó el banner superior.
     La altura real de la tarjeta la fija fillMobileCalendarHeight() en
     mobile-today-scroll.js, midiendo el hueco disponible de verdad. */
  .calendar-area { margin-top: 10px; }
  /* El ajuste de la etiqueta "HOY" en móvil vive en 09-visual-polish.css
     (tiene que ir después de la regla que la centra, que está ahí). */
}
/* ===========================================================================
FIX 02-CALENDAR · selectores de métricas y dirección restaurados (V11-CLEAN)
=========================================================================== */
.metric { display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-width: 0; color: var(--muted); font-size: .73rem; font-weight: 800; text-transform: uppercase; }
.metric[data-metric="temp"] { grid-area: temp; }
.metric[data-metric="hum"] { grid-area: hum; }
.metric[data-metric="ph"] { grid-area: ph; }
.metric[data-metric="ec"] { grid-area: ec; }
.metrics.has-ph-ec .metric[data-metric="ph"],
.metrics.has-ph-ec .metric[data-metric="ec"] { animation: metricIn .26s ease both; }
@keyframes metricIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.metric-field:focus-within:not(.out-of-range) { border-color: var(--primary); }
/* ===========================================================================
FIX 02-CALENDAR · selectores y valores rotos restaurados
=========================================================================== */
.day.today::before {
content: 'HOY';
position: absolute;
top: 6px;
left: 6px;
background: var(--primary);
color: #000;
font-size: .55rem;
font-weight: 800;
padding: 2px 6px;
border-radius: 4px;
}
.metric {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 3px;
min-width: 0;
color: var(--muted);
font-size: .73rem;
font-weight: 800;
text-transform: uppercase;
}
.metric[data-metric="temp"] { grid-area: temp; }
.metric[data-metric="hum"] { grid-area: hum; }
.metric[data-metric="ph"] { grid-area: ph; }
.metric[data-metric="ec"] { grid-area: ec; }
.metrics.has-ph-ec .metric[data-metric="ph"],
.metrics.has-ph-ec .metric[data-metric="ec"] {
display: flex;
animation: metricIn .26s ease both;
}
@keyframes metricIn {
from { opacity: 0; transform: translateY(-4px); }
to { opacity: 1; transform: none; }
}
/* Secado: acciones diarias desactivadas sin alterar el aspecto general */
.day-menu .color-option.is-disabled,.day-menu .color-option:disabled{opacity:.38;filter:grayscale(.65);cursor:not-allowed;pointer-events:none;}


.day > * { position: relative; z-index: 3; }


/* =========================================================
   CORRECCIÓN ETIQUETA "HOY"
   ========================================================= */

.day {
  overflow: visible;
}

/* Selectores habituales para la etiqueta del día actual. */
.day .today-badge,
.day .day-today,
.day .today-label,
.day .is-today-label,
.day .badge-today,
.day .today {
  position: relative;
  z-index: 5;
  overflow: visible;
  transform: none;
}

/* Si "HOY" se genera con un pseudo-elemento, evita que su
   propio contenedor lo corte. */
.day.is-today,
.day.today,
.day.current-day {
  overflow: visible;
}



/* GP-WEEKDAY-FIX-V3: original headers remain in document flow; fixed overlay handles viewport pinning. */
.calendar > .weekday {
  position:relative !important;
  width:80% !important;
  justify-self:center !important;
  min-width:0 !important;
}
