/* ============================================================
   FIELD PICKERS — date + time picker reutilizable (.fpick-*)
   ------------------------------------------------------------
   Reemplaza el calendario / reloj NATIVO (que no se puede estilizar)
   por uno propio, coherente con la identidad del sistema. El <input>
   real queda oculto como fuente de verdad (se lee su .value y se emite
   `change`). Solo se activa en ESCRITORIO — en táctil se conserva el
   picker nativo del sistema operativo (mejor UX).

   TEMEABLE: color de acento vía `--fpick-accent` (default teal del
   sistema). El consumidor puede setearlo en :root/body para que el
   picker combine con su módulo.

   Tuned para inputs estándar (height 38px, radius 9px, tokens del
   sistema). Los popups se montan en <body> (position:fixed).
   ============================================================ */

:root { --fpick-accent: #199c82; }

.fpick { position: relative; }
/* El input nativo se oculta pero NO con display:none — así sigue siendo
   "focusable" para la validación HTML5. Si un campo es `required` y queda
   vacío, el navegador puede enfocarlo y mostrar el globo "completa este
   campo" en vez de bloquear el submit en silencio (con display:none tiraría
   "not focusable" y el formulario nunca se enviaría). Queda clip a 1px, sin
   eventos y fuera del orden de tabulación (tabindex=-1 vía JS). */
.fpick > .fpick__native {
    position: absolute; left: 0; top: 0;
    width: 1px; height: 1px;
    padding: 0; margin: 0; border: 0;
    opacity: 0; pointer-events: none;
    clip: rect(0 0 0 0); clip-path: inset(50%);
    overflow: hidden; white-space: nowrap;
}

.fpick__trigger {
    width: 100%;
    box-sizing: border-box;
    /* Alto por defecto (fallback). Los campos VISIBLES al inicializar heredan
       su alto real vía estilo inline (JS), así que este valor solo aplica a
       campos dentro de modales ocultos al cargar (rect 0 al medir): 40px es un
       punto medio touch-friendly cercano a la mayoría de inputs de la app. */
    height: 40px;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 0 .75rem;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 9px;
    background: var(--bg-input, #fff);
    color: var(--text-primary, #0f172a);
    font-family: var(--font-family, inherit);
    font-size: .82rem;
    cursor: pointer; text-align: left;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.fpick__trigger:hover:not(:focus) { border-color: var(--text-muted, #94a3b8); }
.fpick.is-open .fpick__trigger,
.fpick__trigger:focus-visible {
    outline: none;
    border-color: var(--fpick-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fpick-accent) 16%, transparent);
}
.fpick__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fpick__value.is-placeholder { color: var(--text-muted, #94a3b8); }
.fpick__icon { flex: 0 0 auto; color: var(--text-muted, #64748b); transition: color .16s ease; }
.fpick.is-open .fpick__icon { color: var(--fpick-accent); }

/* ── Popup base (compartido date + time) ──────────────────── */
.fpick__pop {
    position: fixed;
    /* Por encima de CUALQUIER overlay de la app: modales cal2 (1100),
       tour de demo (99993) y SweetAlert (.swal2-container = 100000 !important,
       el mas alto del sistema). El picker es una interaccion transitoria que
       siempre debe quedar sobre el modal que lo contiene. */
    z-index: 100010;
    background: #fff;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 14px;
    box-shadow: 0 16px 42px rgba(15,23,42,.18);
    animation: fpickIn .14s ease;
}
@keyframes fpickIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}

/* ── Date picker ──────────────────────────────────────────── */
.fpick-cal { width: min(304px, calc(100vw - 24px)); padding: 14px; }
.fpick-cal__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 10px;
}
/* Título = botón que abre el salto rápido de año/mes (días ⇄ años). */
.fpick-cal__title {
    display: inline-flex; align-items: center; gap: 6px;
    border: none; background: none;
    padding: 4px 9px; border-radius: 8px;
    font-family: var(--font-family, inherit);
    font-size: .84rem; font-weight: 800;
    color: var(--text-primary, #0f172a);
    text-transform: capitalize;
    cursor: pointer;
    transition: background .14s ease, color .14s ease;
}
.fpick-cal__title::after {
    content: ''; width: 0; height: 0; flex: 0 0 auto;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: .5; margin-top: 2px;
}
.fpick-cal__title:hover {
    background: color-mix(in srgb, var(--fpick-accent) 12%, transparent);
    color: var(--fpick-accent);
}
.fpick-cal__title:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fpick-accent) 22%, transparent);
}

/* Grillas de meses (3×4) y años (4×4) — salto rápido */
.fpick-cal__mgrid,
.fpick-cal__ygrid {
    display: grid; gap: 6px;
    padding: 6px 2px 2px;
}
.fpick-cal__mgrid { grid-template-columns: repeat(3, 1fr); }
.fpick-cal__ygrid { grid-template-columns: repeat(4, 1fr); }
.fpick-cal__cell {
    height: 42px;
    border: none; background: none;
    border-radius: 9px;
    font-size: .8rem; font-weight: 600;
    color: var(--text-primary, #334155);
    font-family: var(--font-family, inherit);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.fpick-cal__cell:hover { background: var(--bg-hover, #f1f5f9); }
.fpick-cal__cell.is-today {
    box-shadow: inset 0 0 0 1.5px var(--fpick-accent);
    color: var(--fpick-accent); font-weight: 800;
}
.fpick-cal__cell.is-selected {
    background: var(--fpick-accent);
    color: #fff; font-weight: 800; box-shadow: none;
}
.fpick-cal__nav {
    width: 32px; height: 32px; flex: 0 0 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 9px;
    background: var(--bg-hover, #f1f5f9);
    color: var(--text-muted, #64748b);
    cursor: pointer;
    transition: background .14s ease, color .14s ease;
}
.fpick-cal__nav:hover {
    background: color-mix(in srgb, var(--fpick-accent) 12%, transparent);
    color: var(--fpick-accent);
}
.fpick-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.fpick-cal__dow {
    text-align: center;
    font-size: .62rem; font-weight: 800; letter-spacing: .04em;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    padding: 4px 0 6px;
}
.fpick-cal__day {
    height: 36px;
    border: none; background: none;
    border-radius: 9px;
    font-size: .8rem; font-weight: 600;
    color: var(--text-primary, #334155);
    font-family: var(--font-family, inherit);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.fpick-cal__day:hover { background: var(--bg-hover, #f1f5f9); }
.fpick-cal__day.is-other { color: var(--text-muted, #cbd5e1); font-weight: 500; }
.fpick-cal__day.is-active { background: color-mix(in srgb, var(--fpick-accent) 14%, transparent); }
.fpick-cal__day.is-today {
    box-shadow: inset 0 0 0 1.5px var(--fpick-accent);
    color: var(--fpick-accent); font-weight: 800;
}
.fpick-cal__day.is-selected {
    background: var(--fpick-accent);
    color: #fff; font-weight: 800;
    box-shadow: none;
}

/* ── Time picker (dos columnas: hora | minuto) ─────────────── */
.fpick-time { width: 208px; padding: 12px; }
.fpick-time__cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.fpick-time__colwrap { display: flex; flex-direction: column; min-width: 0; }
.fpick-time__collabel {
    text-align: center;
    font-size: .62rem; font-weight: 800; letter-spacing: .04em;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    padding-bottom: 6px;
}
.fpick-time__col {
    max-height: 184px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: flex; flex-direction: column; gap: 2px;
    padding-right: 2px;
}
.fpick-time__opt {
    flex: 0 0 auto;
    padding: 8px 0;
    border: none; background: none;
    border-radius: 8px;
    font-size: .82rem; font-weight: 600;
    color: var(--text-primary, #334155);
    font-family: var(--font-family, inherit);
    cursor: pointer;
    text-align: center;
    transition: background .12s ease, color .12s ease;
}
.fpick-time__opt:hover { background: var(--bg-hover, #f1f5f9); }
.fpick-time__opt.is-selected {
    background: var(--fpick-accent);
    color: #fff; font-weight: 800;
}

/* ── Footer compartido (Hoy / Borrar / Limpiar) ───────────── */
.fpick__foot {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--border, #e9eef3);
}
.fpick__foot--end { justify-content: flex-end; }
.fpick__foot-btn {
    border: none; background: none;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: .72rem; font-weight: 700;
    color: var(--fpick-accent);
    font-family: var(--font-family, inherit);
    cursor: pointer;
    transition: background .12s ease;
}
.fpick__foot-btn:hover { background: color-mix(in srgb, var(--fpick-accent) 8%, transparent); }

/* Scrollbars discretas en las columnas de tiempo */
.fpick-time__col::-webkit-scrollbar { width: 6px; }
.fpick-time__col::-webkit-scrollbar-thumb {
    background: var(--border, #e2e8f0);
    border-radius: 999px;
}

@media (prefers-reduced-motion: reduce) {
    .fpick__pop { animation: none; }
    .fpick__icon, .fpick__trigger { transition: border-color .18s ease, box-shadow .18s ease; }
}
