/* ========================================
   🐝 Bee Principal — Identidad oficial (rediseño)
   Paleta derivada del logo: miel + hoja + tinta sobre crema.
   Marcellus (títulos) + Figtree (interfaz).
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Marcellus&family=Figtree:wght@400;600;700&display=swap');

:root {
    /* === MARCA === */
    --miel: #FDBB2D;
    --miel-oscura: #D89A12;
    --miel-tinte: #FFF6DF;
    --hoja: #6FAF3E;
    --hoja-oscura: #4E7A28;
    --hoja-texto: #3B5C1E;
    --hoja-tinte: #E4F0D5;
    --tinta: #221A12;
    --arena: #F3E9D4;
    --crema: #FFFBF2;
    --miel-texto: #4A3708;
    --etiqueta: #7A5E1C;
    --borde: rgba(34, 26, 18, .16);
    --divisor: rgba(34, 26, 18, .10);
    --sombra-tarjeta: 0 10px 30px rgba(34, 26, 18, .14);

    /* === UTILIDAD (el sistema los sigue necesitando; no vienen del handoff) === */
    --superficie: #FFFFFF;
    --texto: var(--tinta);
    --texto-secundario: rgba(34, 26, 18, .6);
    --texto-suave: rgba(34, 26, 18, .45);
    --error: #C0392B;
    --error-claro: #FBE8E5;

    /* === RADIOS === */
    --radio-pildora: 999px;
    --radio-tarjeta: 22px;
    --radio-pantalla: 26px;
    --radio: 20px;
    --radio-peq: 14px;
}

/* ========== RESET Y BASE ========== */
* {
    box-sizing: border-box;
    margin: 0;
}

body {
    font-family: 'Figtree', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--crema);
    color: var(--texto);
    margin: 0;
    padding: 22px;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.5;
}

/* ========== TIPOGRAFÍA ========== */
h1 {
    font-family: 'Marcellus', serif;
    font-weight: 400;
    font-size: 27px;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0 0 0.25rem;
    color: var(--texto);
}

h2 {
    font-family: 'Figtree', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: var(--etiqueta);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
}

/* ========== FORMULARIOS ========== */
label {
    display: block;
    margin-top: 1.25rem;
    font-size: 11px;
    font-weight: 700;
    color: var(--etiqueta);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

input,
select,
textarea {
    width: 100%;
    padding: 13px 18px;
    margin-top: 6px;
    border: 2px solid var(--borde);
    border-radius: var(--radio-pildora);
    font-size: 16px;
    font-family: inherit;
    font-weight: 600;
    color: var(--texto);
    background: var(--crema);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
}

textarea {
    border-radius: 16px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--miel-oscura);
    box-shadow: 0 0 0 4px rgba(253, 187, 45, 0.18);
}

input:disabled {
    background: var(--arena);
    cursor: not-allowed;
}

/* ========== BOTONES ========== */
button {
    font-family: inherit;
    border: none;
    border-radius: var(--radio-pildora);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 13px 20px;
    font-size: 15px;
}

button:active {
    transform: scale(0.97);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* Botón primario (miel) */
.btn-primario,
button[type="submit"] {
    background: var(--miel);
    color: var(--tinta);
    box-shadow: 0 4px 0 var(--miel-oscura);
}

.btn-primario:hover:not(:disabled),
button[type="submit"]:hover:not(:disabled) {
    filter: brightness(1.04);
}

/* Foco de teclado visible en todo lo accionable */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--miel-oscura);
    outline-offset: 2px;
}

/* ========== TARJETAS ========== */
.caja {
    background: var(--crema);
    padding: 2rem 1.5rem;
    border-radius: var(--radio-tarjeta);
    box-shadow: var(--sombra-tarjeta);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border: 1px solid var(--borde);
}

/* ========== VOLVER ========== */
a.volver {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 1rem;
    color: var(--texto);
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    padding: 9px 16px 9px 13px;
    border-radius: var(--radio-pildora);
    background: var(--arena);
    transition: filter 0.15s ease;
}

a.volver:hover {
    filter: brightness(0.97);
}

/* ========== SESIÓN ========== */
.sesion-actual {
    background: var(--hoja-tinte);
    color: var(--hoja-texto);
    border-radius: var(--radio-peq);
    padding: 10px 16px;
    font-size: 13.5px;
    font-weight: 600;
    margin: 0.5rem 0 1rem;
}

.saludo {
    color: var(--texto-secundario);
    font-size: 13px;
    font-weight: 700;
    margin: -0.25rem 0 1rem;
    text-align: center;
}

/* ========== ERROR Y CONFIRMACIÓN ========== */
.error {
    color: var(--error);
    background: var(--error-claro);
    padding: 10px 14px;
    border-radius: var(--radio-peq);
    text-align: center;
    margin-bottom: 1rem;
    font-size: 14px;
    font-weight: 600;
}

.confirmacion {
    background: var(--hoja-tinte);
    color: var(--hoja-texto);
    padding: 10px 14px;
    border-radius: var(--radio-peq);
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    margin: 1rem 0;
}

/* ========== BUSCADOR ========== */
.buscador-wrap {
    position: relative;
}

.resultados-producto {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--crema);
    border: 2px solid var(--borde);
    border-radius: 16px;
    box-shadow: var(--sombra-tarjeta);
    max-height: 260px;
    overflow-y: auto;
    z-index: 30;
}

.resultado-item {
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    border-bottom: 1px solid var(--divisor);
    cursor: pointer;
    transition: background 0.1s ease;
}

.resultado-item:last-child {
    border-bottom: none;
}

.resultado-item:hover {
    background: var(--hoja-tinte);
}

.resultado-item:active {
    background: var(--arena);
}

.resultado-vacio {
    padding: 14px;
    font-size: 14px;
    color: var(--texto-suave);
    text-align: center;
}

.producto-elegido {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--hoja-texto);
    font-weight: 700;
    display: none;
    background: var(--hoja-tinte);
    padding: 5px 12px;
    border-radius: var(--radio-pildora);
}

/* ========== AVISO COSTEO ========== */
.aviso-costeo {
    background: var(--error);
    color: white;
    border-radius: var(--radio-tarjeta);
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    margin: 1rem auto 0;
    max-width: 360px;
    text-align: center;
    box-shadow: var(--sombra-tarjeta);
}

/* ========== FORM-NUEVO (mini-formularios inline, si se usan) ========== */
.form-nuevo {
    background: var(--miel-tinte);
    border: 1.5px solid var(--miel);
    border-radius: var(--radio-tarjeta);
    padding: 16px;
    margin-top: 10px;
}

.form-nuevo label {
    margin-top: 0.75rem;
}
.form-nuevo label:first-child {
    margin-top: 0;
}

.form-nuevo-error {
    color: var(--error);
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
    min-height: 16px;
}

.form-nuevo-botones {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.form-nuevo-botones button {
    flex: 1;
    padding: 12px;
    font-size: 14.5px;
}

.btn-guardar-nuevo {
    background: var(--miel);
    color: var(--tinta);
}

.btn-cancelar-nuevo {
    background: var(--crema);
    border: 2px solid var(--borde);
    color: var(--texto);
    box-shadow: none;
}

/* ========== CHIPS GENÉRICOS ========== */
.chip {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    border-radius: var(--radio-pildora);
    padding: 3px 9px;
}

.chip-hoja {
    background: var(--hoja-tinte);
    color: var(--hoja-texto);
}

.chip-sku {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    font-weight: 600;
    background: var(--hoja-tinte);
    color: var(--hoja-texto);
    border-radius: 8px;
    padding: 2px 7px;
}

/* ========== TARJETA DE FORMULARIO ==========
   Envoltura estándar para los campos de un formulario sencillo (altas de
   catálogo, movimientos, gastos) — mismo lenguaje visual que las tarjetas
   de "Registrar venta" (fondo arena, radio de tarjeta), para que todos los
   formularios del sistema se vean consistentes entre sí. */
.tarjeta-formulario {
    background: var(--arena);
    border-radius: var(--radio-tarjeta);
    padding: 16px 18px;
    margin-top: 18px;
}
.tarjeta-formulario label:first-child { margin-top: 0; }

/* ========== MODAL DE CONFIRMACIÓN (resumen antes de guardar) ==========
   Compartido entre formularios sencillos (nuevo_movimiento.php, gasto.php,
   ...) que piden confirmar con un resumen legible antes de enviar. No usa
   los nombres .modal-overlay/.modal-panel/.modal-cabecera a propósito —
   esos ya los usa venta.php para su propio modal de cobro, con otro
   contenido (grid de forma de pago) — nombres distintos evitan cualquier
   confusión entre los dos. */
.resumen-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(34,26,18,.55);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.resumen-modal-panel {
    background: var(--crema);
    border-radius: var(--radio-tarjeta);
    padding: 24px 22px;
    width: 100%;
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--sombra-tarjeta);
}
.resumen-modal-cabecera { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.resumen-modal-cabecera span { font-family: 'Marcellus', serif; font-size: 20px; }
.resumen-modal-cabecera button {
    background: var(--arena); border: none; box-shadow: none; padding: 0;
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; line-height: 1; color: var(--tinta); cursor: pointer;
}
.resumen-modal-cabecera button:hover { background: var(--divisor); }

.resumen-modal-acciones { display: flex; gap: 10px; margin-top: 20px; }
.resumen-modal-acciones .btn-resumen-confirmar { margin-top: 0; flex: 1; }
.btn-resumen-cancelar {
    flex: 1;
    padding: 14px;
    background: var(--crema);
    border: 2px solid var(--borde);
    color: var(--texto);
    box-shadow: none;
    font-size: 16px;
}
.resumen-monto { font-family: 'Marcellus', serif; font-size: 36px; text-align: center; margin-bottom: 4px; color: var(--miel-oscura); }
.resumen-monto.entrada { color: var(--hoja-oscura); }
.resumen-monto.salida { color: var(--error); }
.resumen-tipo-chip {
    display: block;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--texto-suave);
    margin-bottom: 18px;
}
.resumen-detalle { background: var(--arena); border-radius: var(--radio-peq); padding: 0 16px; margin-top: 10px; }
.resumen-detalle:first-of-type { margin-top: 0; }
.resumen-linea { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--divisor); font-size: 14px; }
.resumen-linea:last-child { border-bottom: none; }
.resumen-linea .etiqueta { color: var(--texto-secundario); font-weight: 600; flex-shrink: 0; }
.resumen-linea .valor { font-weight: 700; text-align: right; }
.btn-resumen-confirmar { width: 100%; margin-top: 20px; padding: 14px; background: var(--miel); color: var(--tinta); font-size: 16px; box-shadow: var(--sombra-tarjeta); }

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
    body {
        padding: 18px;
    }

    h1 {
        font-size: 24px;
    }

    .caja {
        padding: 1.5rem 1rem;
    }
}
