/* =========================================================
   TROS DE FESTUC — styles.css
   ---------------------------------------------------------
   Estilo minimalista, colores neutros y verde pistacho solo en
   detalles. Pensado primero para el móvil ("mobile first"): una
   sola columna de máximo 520 px, centrada también en el ordenador.

   Para cambiar colores, toca solo las variables de :root.
   Tipografía: Nunito Sans (Google Fonts, cargada en index.html),
   la misma del logo (TrosdeFestuc/marca/tipografia/).

   ÍNDICE
     Variables · Base · Cabeceras · Botones · Listas · Pendientes
     Formularios · Selector de tarea · Chips · Productos · Diario y
     gastos · Calendario · Contactos · Avisos · Inicio · Riego
   ========================================================= */

/* ---------- Variables (colores y medidas) ---------- */

:root {
    --bg: #f7f7f5;            /* fondo de la página (blanco roto) */
    --surface: #ffffff;       /* fondo de tarjetas y campos */
    --text: #1d1d1b;          /* texto y botones principales (casi negro) */
    --muted: #8b8b86;         /* texto secundario (gris) */
    --line: #e9e9e5;          /* bordes y separadores */
    --accent: #7a9a5a;        /* verde pistacho apagado, solo para detalles */
    --accent-soft: #eef2e8;   /* fondo suave verde (etiqueta "Este mes") */
    --danger: #b4432f;        /* rojo: borrar, errores, condicionales */
    --radius: 14px;           /* redondeo de las esquinas */
}

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg); color: var(--text);
    font-size: 15px; line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
/* Cualquier elemento con el atributo hidden queda oculto */
[hidden] { display: none !important; }

/* Contenedor de la app: columna centrada. env(safe-area-inset…) deja
   espacio para la muesca y la barra del iPhone. */
.app {
    max-width: 520px; margin: 0 auto; min-height: 100dvh;
    padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(env(safe-area-inset-bottom, 0px) + 40px);
}

/* ---------- Cabeceras ----------
   .top  = cabecera del inicio y del login (logo + nombre)
   .head = cabecera de las demás pantallas (botón ‹ + título)
   .label = títulos pequeños en mayúsculas grises ("MENÚ", "ZONAS"…) */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.logo { width: 52px; height: 52px; flex-shrink: 0; margin-left: -4px; }
.top h1 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; line-height: 1.1; }
.top small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }

.head { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.back {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface);
    font-size: 20px; line-height: 1;
}
.head h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }

.label {
    font-size: 12px; font-weight: 500; color: var(--muted);
    text-transform: uppercase; letter-spacing: .06em; margin: 26px 2px 10px;
}
.label:first-child { margin-top: 0; }

/* ---------- Botones ----------
   .primary = negro, ancho completo (Anotar, Guardar)
   .secondary = blanco con borde · .danger = texto rojo (Borrar) */
.primary {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
    padding: 17px; border-radius: var(--radius);
    background: var(--text); color: #fff; font-size: 16px; font-weight: 600;
}
.primary:active { transform: scale(.99); }
.primary:disabled { opacity: .5; }
.secondary {
    display: flex; align-items: center; justify-content: center; width: 100%;
    padding: 14px; border-radius: var(--radius); border: 1px solid var(--line);
    background: var(--surface); font-weight: 500;
}
.danger { color: var(--danger); font-size: 14px; font-weight: 500; padding: 8px 0; }

/* ---------- Listas ----------
   .box = tarjeta blanca con borde · .row = cada línea dentro de ella
   .grow = parte que ocupa el espacio sobrante · .end = texto a la derecha
   .chev = flecha › · .empty = mensaje de lista vacía */
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.box + .box { margin-top: 10px; }
.row {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--line); min-height: 54px;
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row small, .sub { display: block; color: var(--muted); font-size: 13px; }
.row .end { color: var(--muted); font-size: 14px; text-align: right; white-space: nowrap; }
.row .chev { color: #c4c4be; font-size: 20px; }
a.row:active { background: var(--bg); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Pendientes ----------
   Casillas redondas; al marcar se pone verde y el texto se tacha.
   .x = botón × de borrar · .inline = campo + botón en la misma línea */
.todo input[type="checkbox"], .check input {
    appearance: none; -webkit-appearance: none; flex-shrink: 0;
    width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid #cfcfca;
    display: grid; place-items: center; cursor: pointer; background: #fff;
}
.todo input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.todo input[type="checkbox"]:checked::after {
    content: ""; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}
.todo.done span { text-decoration: line-through; color: var(--muted); }
.x { color: #c4c4be; font-size: 18px; padding: 2px 4px; }

.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
.inline button {
    width: 48px; border-radius: 12px; background: var(--text); color: #fff; font-size: 22px; flex-shrink: 0;
}

/* ---------- Formularios ----------
   font-size 16px en los campos evita que el iPhone haga zoom al escribir.
   El select lleva una flecha dibujada con degradados.
   .field = etiqueta + campo · .grid2 = dos columnas */
input, select, textarea {
    font: inherit; font-size: 16px; color: var(--text); width: 100%; min-width: 0;
    padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
    -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, #999 50%), linear-gradient(135deg, #999 50%, transparent 50%);
    background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Selector de tarea (Anotar) ----------
   Cuadrícula de 3 columnas; .on = elegida (negra); .new = "＋ Nueva" */
.tasks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.task {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    padding: 14px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
    font-size: 13px; font-weight: 500; text-align: center; min-height: 78px;
}
.task .e { font-size: 22px; line-height: 1; }
.task.on { border-color: var(--text); background: var(--text); color: #fff; }
.task.new { color: var(--muted); border-style: dashed; }

/* ---------- Chips (zonas, filtros del diario, años del riego) ----------
   .scroll = fila que se desliza en horizontal si no cabe */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
.chip {
    padding: 8px 13px; border-radius: 99px; font-size: 14px; white-space: nowrap;
    border: 1px solid var(--line); background: var(--surface);
}
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }
.chip small { color: inherit; opacity: .6; }

/* ---------- Productos de un trabajo (Anotar) ----------
   .addline = fila para añadir: producto · cantidad · unidad · ＋
   .check = casilla cuadrada con texto (formulario de tarea nueva)
   .sheet = tarjeta con relleno para formularios */
.lines .row { padding: 11px 16px; min-height: 0; }
.addline { display: grid; grid-template-columns: 1fr 76px 64px 44px; gap: 6px; margin-top: 8px; }
.addline input, .addline select { padding: 11px 10px; }
.addline button { border-radius: 12px; background: var(--text); color: #fff; font-size: 20px; }
.link { color: var(--muted); font-size: 13px; text-decoration: underline; display: inline-block; margin-top: 8px; }

.check { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 12px; cursor: pointer; }
.check input { border-radius: 6px; }
.check input:checked { background: var(--text); border-color: var(--text); }
.check input:checked::after { content: ""; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }

.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 10px; }

/* ---------- Diario y gastos ----------
   .date = cuadradito con día y mes · details.row = línea que se abre
   al tocarla (.more = lo que aparece: notas y Borrar) */
.date { width: 40px; flex-shrink: 0; text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; line-height: 1.15; }
.date b { display: block; font-size: 19px; color: var(--text); font-weight: 600; }
details.row { display: block; }
details.row > summary { list-style: none; display: flex; align-items: center; gap: 12px; cursor: pointer; }
details.row > summary::-webkit-details-marker { display: none; }
details.row .more { padding: 10px 0 0 52px; }
.tag { display: inline-block; font-size: 12px; color: var(--muted); }
.line-prod { font-size: 13px; color: var(--text); margin-top: 2px; }

/* Resumen de gastos: total grande y barras por categoría */
.total { font-size: 34px; font-weight: 600; letter-spacing: -.02em; }
.bar { height: 4px; background: var(--line); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

/* ---------- Calendario (y programa de riego) ----------
   details.month = mes que se abre y cierra · .now = mes actual
   .treat = un tratamiento · td small.if = condicional en rojo */
details.month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
details.month > summary {
    list-style: none; padding: 15px 16px; display: flex; justify-content: space-between; align-items: center;
    font-weight: 600; cursor: pointer;
}
details.month > summary::-webkit-details-marker { display: none; }
details.month > summary small { font-weight: 400; color: var(--muted); font-size: 13px; }
details.month[open] > summary { border-bottom: 1px solid var(--line); }
details.month.now > summary::after { content: "Este mes"; font-size: 11px; font-weight: 500; color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 99px; }
.treat { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.treat:last-child { border-bottom: 0; }
.treat h3 { font-size: 15px; font-weight: 600; }
.treat .when { font-size: 13px; color: var(--muted); }
.treat .cond { font-size: 13px; margin-top: 6px; }
.treat table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.treat td { padding: 6px 0; border-top: 1px solid var(--line); vertical-align: top; }
.treat td:nth-child(2) { text-align: right; white-space: nowrap; padding-left: 10px; }
.treat td small { display: block; color: var(--muted); }
.treat td small.if { color: var(--danger); }
.note { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---------- Contactos: botón redondo de llamar ---------- */
.call {
    flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center; border: 1px solid var(--line); font-size: 16px;
}

/* ---------- Avisos ----------
   .toast = mensaje flotante abajo · .error = texto de error */
.toast {
    position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); transform: translateX(-50%);
    background: var(--text); color: #fff; padding: 11px 18px; border-radius: 99px; font-size: 14px; z-index: 50;
    white-space: nowrap;
}
.error { color: var(--danger); font-size: 14px; margin-bottom: 12px; }

/* Espacio entre los botones de tarea y el formulario de Anotar */
#fTrabajo > .label:first-child { margin-top: 26px; }

/* ---------- Inicio y calendario (añadidos v2.2) ----------
   .foot = pie con "Cerrar sesión" (izq.) y "Contactos" (der.)
   .treat.mine = acción propia del calendario (punto verde)
   .addcal = formulario para añadir acción a un mes */
.foot { display: flex; align-items: center; justify-content: space-between; margin-top: 28px; }
.foot .link { margin-top: 0; }
.logo { color: var(--text); }
.treat.mine h3::before { content: "● "; color: var(--accent); font-size: 10px; vertical-align: 2px; }
.addcal { display: grid; gap: 8px; background: var(--bg); }
.addcal input { padding: 10px 12px; font-size: 15px; }
.addcal .secondary { padding: 10px; }
.treat td:nth-child(3) { text-align: right; white-space: nowrap; padding-left: 10px; }

/* ---------- Calculadora de riego ----------
   .rz = una zona · .rz-in = 3 campos (caudal, horas, m³)
   .rz-out = resultado: .ok verde (±5 % del objetivo), .bajo/.alto rojo
   .need = horas necesarias para llegar al objetivo */
.rz { border-top: 1px solid var(--line); padding: 12px 0; }
.rz-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.rz-top small { color: var(--muted); font-size: 12px; }
.rz-in { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rz-in label span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.rz-in input { padding: 10px; font-size: 16px; }
.rz-out { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 8px; font-size: 14px; }
.rz-out > span { color: var(--muted); font-size: 13px; }
.rz-out.ok > b { color: var(--accent); }
.rz-out.bajo > b, .rz-out.alto > b { color: var(--danger); }
.rz-out .need { width: 100%; }
.rz-out .need b { color: var(--text); }

/* ---------- Marca (v2.3) ----------
   Nombre "tros de festuc" en la cabecera, igual que el logo, y color
   del símbolo (negro de la marca #141414) */
.top h1.brand { font-size: 21px; font-weight: 700; letter-spacing: 0; }
.logo { color: #141414; }
