/* ---- Reset & basics ---- */
*, *::before, *::after { box-sizing: border-box; margin:0; padding:0; }
html { font-size: 100%; }
body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: #f5fbff;
    color: #222;
    line-height: 1.5;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

/* ---- Layout ---- */
header { text-align: center; margin-bottom: 2rem; max-width: 520px; }
header h1 { font-size: 2rem; margin-bottom: .5rem; }
header p { color: #555; font-size: .95rem; }
main { width: 100%; max-width: 520px; display: grid; gap: 1.5rem; }
.card {
    background: #fff;
    border-radius: .75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    padding: 1.5rem;
}
.card h2 { font-size: 1.15rem; margin-bottom: 1rem; color: #333; }

/* ---- Botón principal ---- */
.big-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    width: 100%;
    padding: 1.5rem 1rem;
    background: linear-gradient(135deg, #0066ff 0%, #0052cc 100%);
    color: #fff;
    border-radius: .75rem;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 102, 255, .35);
    transition: transform .15s ease, box-shadow .15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.big-btn:hover  { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 102, 255, .45); }
.big-btn:active { transform: translateY(1px); box-shadow: 0 2px 8px rgba(0, 102, 255, .35); }
.big-btn--busy  { background: #888; cursor: wait; pointer-events: none; opacity: .8; }
.big-btn__icon  { font-size: 1.75rem; line-height: 1; }
.big-btn__text  { letter-spacing: .3px; }

/* ---- Botón secundario (subir desde galería) ---- */
.alt-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    width: 100%;
    margin-top: .75rem;
    padding: .85rem 1rem;
    background: #fff;
    color: #0066ff;
    border: 2px solid #0066ff;
    border-radius: .75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.alt-btn:hover  { background: #eef3ff; }
.alt-btn:active { background: #d8e3ff; transform: translateY(1px); }
.alt-btn--busy  { opacity: .55; pointer-events: none; cursor: wait; }

/* ---- Botón Compartir por WhatsApp ---- */
.share-wrap {
    text-align: center;
    margin-top: 1.25rem;
}
.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    width: auto;                              /* anula el width:100% del button base */
    padding: .65rem 1.35rem;
    background: #25D366;                      /* verde WhatsApp oficial */
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(37, 211, 102, .35);
    transition: background .2s ease, transform .12s ease, box-shadow .2s ease;
    -webkit-tap-highlight-color: transparent;
}
.share-btn:hover  { background: #1da955; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(37, 211, 102, .45); }
.share-btn:active { transform: translateY(1px); }
.share-btn svg   { flex-shrink: 0; }

/* ---- Botón Instalar PWA ---- */
.install-btn {
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem 1.1rem;
    background: #fff;
    color: #0066ff;
    border: 1.5px dashed #0066ff;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s ease;
}
.install-btn[hidden] { display: none; }
.install-btn:hover { background: #eef3ff; }

/* ---- Overlay de carga con animación de crecimiento ---- */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(245, 251, 255, .94);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlayIn .25s ease-out;
}
.loading-overlay[hidden] { display: none; }
.loading-overlay__panel {
    text-align: center;
    padding: 2rem 1.5rem;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 102, 255, .15);
    min-width: 240px;
}
.loading-overlay__title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #0a7a2f;
    margin-top: .75rem;
}
.loading-overlay__sub {
    font-size: .82rem;
    color: #666;
    margin-top: .25rem;
    min-height: 1.2em;            /* evita salto al cambiar mensaje */
    transition: opacity .3s;
}
.growth-svg {
    width: 130px;
    height: 170px;
    display: block;
    margin: 0 auto;
}
.growth-svg .g-stage { opacity: 0; }
.growth-svg .g-1 { animation: growthStage1 4s ease-in-out infinite; }
.growth-svg .g-2 { animation: growthStage2 4s ease-in-out infinite; }
.growth-svg .g-3 { animation: growthStage3 4s ease-in-out infinite; }
.growth-svg .g-4 { animation: growthStage4 4s ease-in-out infinite; }
.growth-svg .g-5 { animation: growthStage5 4s ease-in-out infinite; }

@keyframes overlayIn      { from { opacity: 0; } to { opacity: 1; } }
@keyframes growthStage1   { 0%, 14% { opacity: 1 } 20%, 100% { opacity: 0 } }
@keyframes growthStage2   { 0%, 18% { opacity: 0 } 24%, 34% { opacity: 1 } 40%, 100% { opacity: 0 } }
@keyframes growthStage3   { 0%, 38% { opacity: 0 } 44%, 54% { opacity: 1 } 60%, 100% { opacity: 0 } }
@keyframes growthStage4   { 0%, 58% { opacity: 0 } 64%, 74% { opacity: 1 } 80%, 100% { opacity: 0 } }
@keyframes growthStage5   { 0%, 78% { opacity: 0 } 84%, 100% { opacity: 1 } }

.hint { margin-top: .85rem; font-size: .85rem; color: #666; text-align: center; }

/* ---- Botones secundarios ---- */
button {
    background: #0066ff;
    color: #fff;
    border: none;
    border-radius: .5rem;
    padding: .75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .2s;
    width: 100%;
}
button:hover { background: #0052cc; }
button:active { transform: translateY(1px); }
button:disabled { background: #888; cursor: wait; }

/* ---- Resultado ---- */
.preview-img {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    border-radius: .5rem;
    margin-bottom: 1.5rem;
}

.result-block {
    padding: 1rem 0;
    border-top: 1px solid #eef2f7;
}
.result-block:first-of-type { border-top: 0; padding-top: 0; }
.result-block__title {
    font-weight: 600;
    color: #2a4fad;
    font-size: .9rem;
    margin-bottom: .35rem;
    letter-spacing: .3px;
}
.result-block__main {
    font-size: 1.05rem;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: .35rem;
}
.result-block__detail {
    color: #555;
    font-size: .9rem;
    margin-top: .25rem;
}

.tag {
    display: inline-block;
    background: #e6f0ff;
    color: #2a4fad;
    font-size: .75rem;
    font-weight: 500;
    padding: .15rem .55rem;
    border-radius: 999px;
    margin-left: .35rem;
    vertical-align: middle;
    text-transform: capitalize;
}
.tag--weed {
    background: #fde6cc;
    color: #a04d00;
    font-weight: 600;
}
.tag--weed::before { content: "⚠ "; }

.severity {
    display: inline-block;
    font-size: .8rem;
    padding: .2rem .55rem;
    border-radius: .35rem;
    margin-left: .5rem;
    vertical-align: middle;
    font-weight: 600;
}
.severity[data-level="1"] { background: #e6f7ec; color: #0a7a2f; }
.severity[data-level="2"] { background: #f0f7e6; color: #4d7a0a; }
.severity[data-level="3"] { background: #fff7e0; color: #946700; }
.severity[data-level="4"] { background: #fde6cc; color: #a04d00; }
.severity[data-level="5"] { background: #fde0e0; color: #b40000; }

.bullet-list {
    margin: .5rem 0 0 1.2rem;
    color: #444;
    font-size: .9rem;
}
.bullet-list li { margin-bottom: .25rem; }

.treatment-box {
    background: #f5fbff;
    border-left: 3px solid #0066ff;
    padding: .75rem 1rem;
    border-radius: .35rem;
    margin: .75rem 0;
    font-size: .9rem;
}
.treatment-box p { margin: .25rem 0; }

#new-photo-btn { margin-top: 1.5rem; }

/* ---- Footer ---- */
footer {
    margin-top: 2rem;
    font-size: .875rem;
    color: #555;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
}
footer .copy {
    font-size: .8rem;
    color: #888;
    letter-spacing: .5px;
}

/* ---- AI status badge ---- */
.ai-status {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    padding: .45rem .9rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}
.ai-status__dot { width: 10px; height: 10px; border-radius: 50%; background: #999; flex-shrink: 0; }
.ai-status__link { color: inherit; text-decoration: underline; font-weight: 600; margin-left: .25rem; }
.ai-status__link[hidden] { display: none; }

.ai-status--checking { background: #eef3ff; color: #2a4fad; border-color: #c8d6ff; }
.ai-status--checking .ai-status__dot { background: #5b7bd6; animation: aiPulse 1.4s ease-in-out infinite; }
.ai-status--ok       { background: #e6f7ec; color: #0a7a2f; border-color: #b6e5c5; }
.ai-status--ok       .ai-status__dot { background: #22c55e; animation: aiGlow 2.5s ease-in-out infinite; }
.ai-status--fail     { background: #fff0f0; color: #b40000; border-color: #f5b5b5; cursor: pointer; }
.ai-status--fail     .ai-status__dot { background: #ef4444; animation: aiBlink 1.2s steps(2, start) infinite; }
.ai-status--fail:hover { background: #ffe5e5; }

@keyframes aiPulse { 0%,100% {opacity:1; transform:scale(1);} 50% {opacity:.4; transform:scale(.85);} }
@keyframes aiGlow  { 0%,100% {box-shadow:0 0 0 0 rgba(34,197,94,.6);} 70% {box-shadow:0 0 0 8px rgba(34,197,94,0);} }
@keyframes aiBlink { 50% { opacity: .35; } }

/* =========================================================
   v2 — Botánico local: contexto, variedad, cuidados, offline
   ========================================================= */

/* ---- Selector de contexto (chips) ---- */
.context {
    border: 1px solid #e3e9f2;
    border-radius: .6rem;
    padding: .9rem 1rem 1rem;
    margin-top: 1.1rem;
}
.context legend {
    font-size: .85rem;
    font-weight: 600;
    color: #333;
    padding: 0 .35rem;
}
.context legend small { color: #888; font-weight: 400; }
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .35rem;
}
.chip {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}
.chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.chip span {
    display: inline-block;
    padding: .4rem .75rem;
    border-radius: 999px;
    background: #f1f5fb;
    color: #33415c;
    border: 1.5px solid transparent;
    font-size: .85rem;
    font-weight: 500;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.chip:hover span { background: #e6eefb; }
.chip input:checked + span {
    background: #e6f0ff;
    color: #0052cc;
    border-color: #0066ff;
    font-weight: 600;
}
.chip input:focus-visible + span { outline: 2px solid #0066ff; outline-offset: 2px; }

.context__hint-label {
    display: block;
    margin-top: .85rem;
    font-size: .85rem;
    font-weight: 600;
    color: #333;
}
.context__hint {
    width: 100%;
    margin-top: .4rem;
    padding: .65rem .8rem;
    border: 1.5px solid #d5deeb;
    border-radius: .5rem;
    font-size: .9rem;
    background: #fbfdff;
    color: #222;
}
.context__hint:focus { outline: none; border-color: #0066ff; background: #fff; }

/* ---- Variedad: nombre científico + explicación ---- */
.result-block__sci {
    font-size: .82rem;
    color: #667;
    font-style: italic;
    margin-bottom: .35rem;
}
.explanation-box {
    background: #f3faf4;
    border-left: 3px solid #22c55e;
    border-radius: .35rem;
    padding: .7rem .9rem;
    margin: .6rem 0;
    font-size: .88rem;
    color: #274b31;
}
.explanation-box__text { margin: 0 0 .4rem; }
.explanation-box__conf { margin: 0; font-size: .8rem; color: #4c6b52; }

/* ---- Alternativas ---- */
.alternatives { margin-top: .5rem; }
.alternatives__title { font-size: .8rem; color: #667; margin-bottom: .3rem; }
.alternatives__list li { font-size: .88rem; }
.alt-conf { color: #889; font-size: .8rem; }

/* ---- Dos columnas (causas / actúa ya) ---- */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: .75rem;
}
@media (max-width: 420px) {
    .two-col { grid-template-columns: 1fr; }
}
.mini-title {
    font-size: .8rem;
    font-weight: 600;
    color: #2a4fad;
    margin-bottom: .3rem;
}

/* ---- Cuidados de la variedad ---- */
.care-grid {
    display: grid;
    gap: .6rem;
    margin: .5rem 0 .75rem;
}
.care-item {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    background: #fbfdff;
    border: 1px solid #e3e9f2;
    border-radius: .5rem;
    padding: .6rem .75rem;
}
.care-item__icon { font-size: 1.2rem; line-height: 1.2; }
.care-item strong { font-size: .8rem; color: #2a4fad; display: block; }
.care-item p { margin: .15rem 0 0; font-size: .85rem; color: #333; }

/* ---- Badge de motor (encabezado del resultado) ---- */
.engine-badge {
    display: inline-block;
    vertical-align: middle;
    font-size: .68rem;
    font-weight: 600;
    color: #2a4fad;
    background: #e6f0ff;
    padding: .15rem .5rem;
    border-radius: 999px;
    margin-left: .4rem;
    letter-spacing: .2px;
}

/* ---- Banner offline / cola pendiente ---- */
.offline-banner {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: #fff8e0;
    border: 1px solid #f2d98c;
    color: #7a5c00;
    border-radius: .6rem;
    padding: .7rem .9rem;
    font-size: .88rem;
}
.offline-banner[hidden] { display: none; }
.offline-banner__icon { font-size: 1.15rem; }
.offline-banner__text { flex: 1; }
.offline-banner--offline { background: #fde6cc; border-color: #f0b884; color: #7a4a00; }
.offline-banner__retry {
    width: auto;
    padding: .4rem .9rem;
    font-size: .8rem;
    font-weight: 600;
    background: #0066ff;
    border-radius: 999px;
    flex-shrink: 0;
}
.offline-banner__retry:hover { background: #0052cc; }
.offline-banner__retry:disabled { background: #b9c6dd; cursor: not-allowed; }

/* ---- Nota: .result-block__detail ya existe; añadimos límite de ancho ---- */
.result-block__detail { overflow-wrap: anywhere; }
