/* estilos.css - Urbanopolis PWA */

* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    -webkit-text-size-adjust: 100%;
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    line-height: 1.5;
    background-color: #f5f5f5;
    color: #333;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overscroll-behavior-y: none;
}

section {
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    padding: 8px 5px;
    width: 100%;
    max-width: 600px;
    margin: 4px auto;
}

.flex {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    gap: 10px;
}

#frmEnvio > section.flex {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: stretch;
    gap: 8px 12px;
    padding: 10px 12px;
    background-color: #ffffff;
    border: 1px solid #d7dde3;
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    margin: 6px auto;
    width: calc(100% - 16px);
    max-width: 560px;
}

#frmEnvio > section.flex:has(#detalle) {
    align-items: stretch;
}

#frmEnvio > section.flex:has(#detalle) .lat_lon {
    width: 100%;
    max-width: 100%;
}

#frmEnvio textarea {
    width: 100%;
    max-width: 100%;
    min-width: 100%;
}

article {
    justify-content: center;
}

form,
.botones {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.lat_lon {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    flex: 1 1 auto;
    min-width: 0;
    padding: 2px 0;
    margin: 0;
    gap: 3px;
}

.lat_lon label {
    font-size: 12px;
    font-weight: 600;
    color: #1e3a5f;
    text-align: left;
    padding-left: 2px;
    margin: 0;
    line-height: 1.2;
}

.boton_foto {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    border-radius: 20px;
    min-width: 140px;
    min-height: 44px;
    padding: 10px 14px;
    border: none;
    background-color: #4CAF50;
    color: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.boton_foto:active {
    transform: scale(0.97);
}

.flex-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f3f5f7;
    color: rgb(14, 14, 14);
    padding: 10px 6px;
    border: 2px solid #619db3;
    border-radius: 15px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 108px;
    min-height: 92px;
    font-size: 14px;
    font-weight: 600;
    gap: 6px;
}

.flex-button:hover,
.flex-button:focus {
    background-color: #d4ccf4;
    outline: none;
}

.flex-button:active {
    transform: scale(0.97);
}

.active {
    background-color: #d9e4ef;
    border: 2px solid #5c5f60;
}

textarea {
    padding: 10px;
    width: 100%;
    max-width: 280px;
    min-width: 240px;
    min-height: 80px;
    border: 1px solid #20165b;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    resize: vertical;
}

header {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #d5dbdb;
    padding: 4px 6px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    top: env(safe-area-inset-top);
    z-index: 100;
    min-height: 40px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: #1e3a5f;
    margin: 2px 0;
    line-height: 1.15;
    letter-spacing: 0.3px;
    transition: font-size 0.2s ease, margin 0.2s ease, opacity 0.2s ease;
    will-change: font-size;
    text-align: center;
}

.logo {
    width: min(260px, 80%);
    max-width: 260px;
    height: auto;
    margin: 2px auto;
    display: block;
}

.margen {
    margin: 6px;
}

.formulario {
    margin: 6px;
}

.inputRead {
    background-color: #f7f9fb;
    border: 1px solid #b9c3cd;
    padding: 7px 9px;
    font-size: 14px;
    border-radius: 8px;
    width: 100%;
    max-width: none;
    text-align: left;
    min-height: 34px;
    line-height: 1.3;
}

input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    margin: 0;
    display: inline-block;
    border: 1px solid #b9c3cd;
    border-radius: 8px;
    box-sizing: border-box;
    background-color: #fff;
    font-size: 14px;
    min-height: 34px;
    line-height: 1.3;
}

.ver-mapa {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 120px;
    min-height: 60px;
    border: 2px solid #2c7d2f;
    border-radius: 25px;
    text-decoration: none;
    padding: 10px 8px;
    color: inherit;
    background-color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin: 4px;
}

.ver-mapa:active {
    background-color: #e8f5e9;
}

footer {
    width: 100%;
    color: #ccc;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    background-color: rgb(34, 69, 69);
    padding: 14px 10px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    margin-top: 20px;
    gap: 10px;
}

.sugerencias {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 7px;
    color: #ccc;
    gap: 4px;
}

.tomarFoto {
    display: flex;
    justify-content: center;
}

.btn-volver {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    color: white;
    background-color: #007BFF;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s ease;
    min-height: 44px;
}

.btn-volver:hover {
    background-color: #0056b3;
}

.btn-volver svg {
    margin-right: 8px;
    width: 20px;
    height: 20px;
    fill: white;
}

.icon path {
    animation: colorTransition 4s infinite;
}

@keyframes colorTransition {
    0% {
        stroke: #f0f7a6;
    }
    25% {
        stroke: #a6f7d3;
    }
    50% {
        stroke: #a6b1f7;
    }
    75% {
        stroke: #dea6f7;
    }
    100% {
        stroke: #f7a6c7;
    }
}

.lm_contenedor {
    width: 95%;
    max-width: 420px;
    margin: 16px auto;
    font-family: Arial, sans-serif;
    background-color: #fff;
    padding: 14px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.lm_texto {
    overflow: hidden;
    max-height: 60px;
    transition: max-height 0.5s ease;
    text-align: justify;
}

.lm_texto.lm_expandido {
    max-height: 800px;
}

.lm_boton {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 14px;
    background-color: #ccc;
    color: black;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    min-height: 36px;
}

.lm_boton:hover {
    background-color: #aaa;
}

#fileName {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

#fileName img {
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    max-width: 90% !important;
}

h3 {
    color: #1e3a5f;
    text-align: center;
    margin: 10px 0 4px 0;
}

p {
    text-align: center;
    max-width: 500px;
    margin: 6px auto;
    padding: 0 6px;
}

@media (min-width: 600px) {
    body {
        font-size: 16px;
    }
}

/* ============================
   Optimizaciones UI v2
   ============================ */

/* Botones de problemáticas: 2 columnas */
.botones {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 10px 14px;
    justify-items: stretch;
    align-items: stretch;
}

.botones .flex-button {
    width: 100%;
}

/* Header sticky + shrink animado */
.app-header {
    transition: padding 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, min-height 0.2s ease;
    will-change: padding, min-height;
}

.app-header.shrink {
    padding: 1px 4px;
    background-color: #c8d1d5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    min-height: 30px;
}

.app-header .logo {
    transition: width 0.2s ease, max-width 0.2s ease, height 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    will-change: width;
}

.app-header .logo.shrink {
    width: min(150px, 50%);
    max-width: 150px;
    transform-origin: center;
    opacity: 0.92;
}

.app-header .logo-text.shrink {
    font-size: 14px;
    margin: 0;
    opacity: 0.9;
}

/* Spinner inline en botón Enviar */
.spinner-btn {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spinner-btn-anim 0.75s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes spinner-btn-anim {
    to { transform: rotate(360deg); }
}

/* Estados disabled */
#submitBtn:disabled,
.boton_foto[aria-disabled="true"] {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.4);
}

#submitBtn[aria-busy="true"] {
    background-color: #2e7d32;
}

/* Contenedor foto modo flex alineado */
#photoClearContainer {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Prevenir flashes clickeables durante carga */
.boton_foto,
.flex-button,
.ver-mapa {
    -webkit-user-select: none;
    user-select: none;
}

/* ============================
   AI Descripción de foto
   ============================ */

#detalle.ai-loading {
    opacity: 0.65;
    background-color: #eef3fb;
    border-color: #619db3 !important;
    cursor: wait;
    filter: saturate(0.9);
}

.ai-desc-status {
    width: 100%;
    min-height: 0;
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.35;
    text-align: left;
    padding-left: 2px;
    color: #1e3a5f;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-desc-status.ai-loading {
    color: #2c5282;
    font-weight: 600;
}

.ai-desc-status.ai-done {
    color: #2f7d32;
    font-weight: 500;
}

.ai-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(44, 82, 130, 0.25);
    border-top-color: #2c5282;
    border-radius: 50%;
    animation: ai-spin 0.85s linear infinite;
    flex-shrink: 0;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

.ai-msg {
    display: inline-block;
}
