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

:root {
    --color-bg: #f3f2f2;
    --color-surface: #fff;
    --color-text: #201e1d;
    --color-accent: #153e8f;
    --color-accent-hover: #123a82;
    --color-divider: rgba(32, 30, 29, 0.35);
    --font: 'Archivo', system-ui, sans-serif;
}

[hidden] {
    display: none !important;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 1rem;
    font-family: var(--font);
    background-color: var(--color-bg);
    color: var(--color-text);
}

/* Formulario */
#formulario-relevamiento {
    display: block;
}

/* Secciones */
.seccion {
    background-color: var(--color-surface);
    border-radius: 0;
    box-shadow: none;
    border: 1px solid var(--color-divider);
    padding: 1.25rem 1rem;
    margin-bottom: 1.25rem;
}

.seccion h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--color-accent);
    border-bottom: 2px solid var(--color-divider);
    padding-bottom: 0.6rem;
}

.seccion h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

/* Campos */
.campo {
    position: relative;
    margin-bottom: 1.25rem;
}

.campo:last-child {
    margin-bottom: 0;
}

.campo label,
.campo legend {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: color-mix(in srgb, var(--color-text) 75%, transparent);
}

.campo input[type="text"],
.campo input[type="tel"],
.campo input[type="email"],
.campo input[type="number"],
.campo input[type="file"],
.campo select,
.campo textarea {
    width: 100%;
    padding: 0.65rem 0.6rem;
    font-size: 16px;
    font-family: inherit;
    border: 1px solid var(--color-divider);
    border-radius: 0;
    background-color: var(--color-bg);
    color: var(--color-text);
}

.campo input:focus,
.campo select:focus,
.campo textarea:focus {
    border-color: var(--color-accent);
}

.campo textarea {
    min-height: 5rem;
    resize: vertical;
}

fieldset.campo {
    border: none;
    margin: 0;
    padding: 0;
    min-width: 0;
}

/* Opciones (radio / checkbox) */
.opcion {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 44px;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.4rem;
    border: 1px solid var(--color-divider);
    border-radius: 0;
    background-color: var(--color-bg);
    font-weight: normal;
    cursor: pointer;
}

.opcion:last-child {
    margin-bottom: 0;
}

.opcion input[type="radio"],
.opcion input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    accent-color: var(--color-accent);
}

/* Checklists (Seguridad e Higiene / Infraestructura) */
.opciones-fila {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.opciones-fila .opcion {
    flex: 1 1 6rem;
    margin-bottom: 0;
}

.capitulo-checklist + .capitulo-checklist {
    margin-top: 1.75rem;
}

.grupo-checklist {
    border: 1px solid var(--color-divider);
    background-color: var(--color-bg);
    padding: 1rem 0.85rem;
    margin-bottom: 1rem;
}

.grupo-checklist:last-child {
    margin-bottom: 0;
}

.grupo-checklist h4 {
    margin: 0 0 0.85rem;
    font-size: 0.95rem;
    font-weight: 700;
}

.grupo-checklist .opcion,
.grupo-checklist .campo input[type="text"],
.grupo-checklist .campo textarea {
    background-color: var(--color-surface);
}

.grupo-checklist .campo textarea {
    min-height: 3.5rem;
}

/* Ayuda */
.ayuda {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    color: color-mix(in srgb, var(--color-text) 55%, transparent);
}

/* Autocompletes */
.resultados-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    margin: 0.25rem 0 0;
    padding: 0;
    list-style: none;
    background-color: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    max-height: 220px;
    overflow-y: auto;
}

.resultados-autocomplete li {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--color-divider);
    cursor: pointer;
    font-size: 0.9rem;
}

.resultados-autocomplete li:last-child {
    border-bottom: none;
}

.resultados-autocomplete li:hover,
.resultados-autocomplete li:focus {
    background-color: color-mix(in srgb, var(--color-accent) 8%, #fff);
}

/* Descripción encontrada */
.descripcion-encontrada {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.65rem;
    background-color: color-mix(in srgb, var(--color-accent) 8%, #fff);
    border-left: 2px solid var(--color-accent);
    border-radius: 0;
    font-size: 0.9rem;
    color: var(--color-accent-hover);
}

/* Bienes */
#bienes-contenedor {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.bien {
    border: 1px solid var(--color-divider);
    background-color: var(--color-bg);
    border-radius: 0;
    padding: 1rem 0.85rem;
}

.fotos-bien {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fotos-bien label {
    margin-bottom: 0.15rem;
}

.fotos-bien input[type="file"] {
    margin-bottom: 0;
}

/* Botones */
button {
    font-family: inherit;
}

.quitar-bien {
    margin-top: 1rem;
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 700;
    background-color: transparent;
    color: var(--color-accent-hover);
    border: 1px solid var(--color-divider);
    border-radius: 0;
    cursor: pointer;
}

.quitar-bien:hover {
    background-color: color-mix(in srgb, var(--color-text) 5%, transparent);
}

#agregar-bien {
    display: block;
    width: 100%;
    margin-top: 1rem;
    margin-bottom: 0.25rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 700;
    background-color: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: 0;
    cursor: pointer;
}

#agregar-bien:hover {
    background-color: color-mix(in srgb, var(--color-accent) 8%, #fff);
}

/* Necesidades */
#necesidades-contenedor {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1rem;
}

.necesidad {
    border: 1px solid var(--color-divider);
    background-color: var(--color-bg);
    padding: 1rem 0.85rem;
}

.necesidad .campo select,
.necesidad .campo input[type="text"],
.necesidad .campo textarea {
    background-color: var(--color-surface);
}

.necesidad .campo textarea {
    min-height: 7rem;
}

.contador-caracteres {
    text-align: right;
}

.quitar-necesidad {
    margin-top: 1rem;
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 700;
    background-color: transparent;
    color: #b00020;
    border: 1px solid var(--color-divider);
    border-radius: 0;
    cursor: pointer;
}

.quitar-necesidad:hover {
    background-color: color-mix(in srgb, #b00020 8%, #fff);
}

#agregar-necesidad {
    display: block;
    width: 100%;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-weight: 700;
    background-color: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: 0;
    cursor: pointer;
}

#agregar-necesidad:hover {
    background-color: color-mix(in srgb, var(--color-accent) 8%, #fff);
}

#boton-guardar-borrador {
    display: block;
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 800;
    color: var(--color-text);
    background-color: transparent;
    border: 1px solid var(--color-text);
    border-radius: 0;
    cursor: pointer;
    margin-bottom: 0.75rem;
}

#boton-guardar-borrador:hover {
    background-color: color-mix(in srgb, var(--color-text) 6%, transparent);
}

#boton-enviar {
    display: block;
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    background-color: var(--color-accent);
    border: none;
    border-radius: 0;
    cursor: pointer;
}

#boton-enviar:hover {
    background-color: var(--color-accent-hover);
}

#boton-enviar:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Mensaje de resultado */
#mensaje-resultado {
    padding: 1rem;
    border-radius: 0;
    margin-top: 1.25rem;
    border-left: 3px solid transparent;
}

#mensaje-resultado.exito {
    background-color: color-mix(in srgb, #1b7a3d 8%, #fff);
    border-left-color: #1b7a3d;
    color: #144d29;
}

#mensaje-resultado.error {
    background-color: color-mix(in srgb, #b00020 8%, #fff);
    border-left-color: #b00020;
    color: #4a1210;
}

#boton-guardar-borrador:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Nota de borrador */
#nota-borrador {
    max-width: 480px;
    margin: 0 auto 1.25rem;
    padding: 0.85rem 1rem;
    background-color: color-mix(in srgb, var(--color-accent) 8%, #fff);
    border-left: 3px solid var(--color-accent);
    font-size: 0.9rem;
    color: var(--color-accent-hover);
}

/* Barra de acciones */
.acciones-formulario {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Fotos existentes (borrador) */
.fotos-existentes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.foto-existente {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    width: 96px;
}

.foto-existente img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border: 1px solid var(--color-divider);
    border-radius: 0;
}

.eliminar-foto {
    width: 100%;
    padding: 0.35rem 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    background-color: transparent;
    color: #b00020;
    border: 1px solid var(--color-divider);
    border-radius: 0;
    cursor: pointer;
}

.eliminar-foto:hover {
    background-color: color-mix(in srgb, #b00020 8%, #fff);
}

/* Link de borrador guardado */
#borrador-link {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    background-color: color-mix(in srgb, #1b7a3d 8%, #fff);
    border-left: 3px solid #1b7a3d;
    font-size: 0.9rem;
    color: #144d29;
    word-break: break-all;
}

#borrador-link p {
    margin: 0 0 0.4rem;
}

#borrador-link p:last-child {
    margin-bottom: 0;
}

#borrador-link a {
    color: var(--color-accent);
    font-weight: 700;
}

/* Foco visible */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
.opcion:focus-within {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Escritorio / tablet */
@media (min-width: 720px) {
    body {
        padding: 2rem 1rem;
    }

    #formulario-relevamiento {
        max-width: 480px;
        margin: 0 auto;
    }

    .seccion {
        padding: 1.75rem 2rem;
    }

    .fotos-bien {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(2, auto);
        grid-auto-flow: column;
        gap: 0.5rem 1rem;
    }

    #agregar-bien,
    .quitar-bien,
    #agregar-necesidad {
        width: auto;
    }

    #boton-enviar {
        width: auto;
        padding: 1rem 2.5rem;
    }
}

/* Escritorio ancho */
@media (min-width: 1024px) {
    #formulario-relevamiento {
        max-width: 720px;
    }

    .seccion {
        padding: 2rem 2.5rem;
    }

    #bienes-contenedor {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        align-items: start;
    }
}

@media (min-width: 1440px) {
    #formulario-relevamiento {
        max-width: 960px;
    }

    #bienes-contenedor {
        grid-template-columns: repeat(3, 1fr);
    }
}
