:root {
    --verde: #005c48;
    --verde-claro: #009675;
    --verde-oscuro: #00382c;
    --verde-pale: #E6F4EE;
    --dorado: #F0B429;
    --dorado-pale: #FEF3D7;
    --bg: #F0F5F2;
    --texto: #1A2E23;
    --texto-suave: #5A7A68;
    --blanco: #FFFFFF;
    --borde: #C8DFCF;
    --sombra: 0 8px 32px rgba(0, 107, 60, 0.12);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'DM Sans', sans-serif;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 10% 10%, rgba(0, 178, 101, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 50% 60% at 90% 90%, rgba(0, 107, 60, 0.07) 0%, transparent 60%);
    pointer-events: none;
}


.chat-wrapper {
    width: 100%;
    max-width: 680px;
    height: 92vh;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    box-shadow: var(--sombra), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
    overflow: hidden;
    position: relative;
}

/* HEADER */
.chat-header {
    background: linear-gradient(135deg, var(--verde) 40%, var(--verde-claro) 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.logo-wrap {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--blanco);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid var(--dorado);
    overflow: hidden;
}

.logo-wrap img {
    width: 36px;
    object-fit: contain;
}

.hd-text {
    flex: 1;
}

.hd-text h1 {
    font-family: 'Sora', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--blanco);
    line-height: 1.2;
}

.hd-text p {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.75);
    margin-top: 2px;
}

.badge-online {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 4px 10px;
    backdrop-filter: blur(6px);
}

.badge-online span {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.dot-pulse {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--dorado);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(240, 180, 41, 0.6);
    }

    50% {
        box-shadow: 0 0 0 5px rgba(240, 180, 41, 0);
    }
}

/* SUGERENCIAS */
.sugerencias {
    background: var(--blanco);
    padding: 10px 14px;
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--borde);
}

.sug-chip {
    font-size: 0.7rem;
    color: var(--verde);
    background: var(--verde-pale);
    border: 1px solid var(--borde);
    border-radius: 20px;
    padding: 5px 11px;
    cursor: pointer;
    transition: all 0.18s;
    font-weight: 500;
    white-space: nowrap;
}

.sug-chip:hover {
    background: var(--verde);
    color: var(--blanco);
    border-color: var(--verde);
    transform: translateY(-1px);
}

/* MENSAJES */
#messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    background: var(--blanco);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#messages::-webkit-scrollbar {
    width: 4px;
}

#messages::-webkit-scrollbar-thumb {
    background: var(--borde);
    border-radius: 8px;
}

.msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: slideUp 0.28s ease;
}

.msg.user {
    flex-direction: row-reverse;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.av {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    align-self: flex-end;
}

.av.user {
    background: var(--dorado-pale);
    color: var(--verde);
    font-weight: 700;
}

.bubble {
    max-width: 74%;
    padding: 10px 14px;
    font-size: 0.86rem;
    line-height: 1.65;
    border-radius: 16px;
    word-break: break-word;
    overflow-wrap: break-word;
}



.msg.bot .bubble {
    background: var(--verde-pale);
    color: var(--texto);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--borde);
}

.msg.user .bubble {
    background: var(--verde);
    color: var(--blanco);
    border-bottom-right-radius: 4px;
}

/* Typing */
.typing-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.typing-dots {
    background: var(--verde-pale);
    border: 1px solid var(--borde);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--verde);
    animation: bounce 1.1s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.18s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.36s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    40% {
        transform: translateY(-7px);
        opacity: 1;
    }
}

/* INPUT */
.chat-input-area {
    background: var(--blanco);
    border-top: 1px solid var(--borde);
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    border: 1.5px solid var(--borde);
    border-radius: 14px;
    padding: 10px 14px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.86rem;
    resize: none;
    min-height: 42px;
    max-height: 100px;
    outline: none;
    color: var(--texto);
    transition: border-color 0.2s;
    background: var(--bg);
}

#userInput:focus {
    border-color: var(--verde);
    background: var(--blanco);
}

#userInput::placeholder {
    color: var(--texto-suave);
}

#sendBtn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: var(--verde);
    color: var(--blanco);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s, transform 0.1s;
    flex-shrink: 0;
}

#sendBtn:hover {
    background: var(--verde-oscuro);
}

#sendBtn:active {
    transform: scale(0.94);
}

#sendBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#sendBtn svg {
    width: 17px;
    height: 17px;
    fill: var(--blanco);
}

.chat-footer {
    background: var(--blanco);
    text-align: center;
    font-size: 0.62rem;
    color: var(--texto-suave);
    padding: 5px;
    border-top: 1px solid var(--borde);
}

.chat-footer a {
    color: var(--texto-suave);
    text-decoration: none;
}

.chat-footer a:hover {
    color: var(--verde);
}

/* ── GRID DE OPCIONES ── */
.opciones-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-top: 10px;
}

.opcion-btn {
    background: var(--blanco);
    border: 1.5px solid var(--borde);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 0.78rem;
    color: var(--verde);
    cursor: pointer;
    text-align: left;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    transition: all 0.18s;
}

.opcion-btn:hover {
    background: var(--verde);
    color: var(--blanco);
    border-color: var(--verde);
    transform: translateY(-1px);
}

.bubble a {
    color: var(--verde);
    font-weight: 500;
    word-break: break-all;
    overflow-wrap: break-word;
}

.bubble.user a {
    color: var(--blanco);
}

.bubble a[href^="tel"] {
    color: var(--verde-oscuro);
    font-weight: 600;
    text-decoration: underline;
}

.msg.user .bubble a[href^="tel"] {
    color: var(--blanco);
    text-decoration: underline;
}

.bubble a[href^="mailto"] {
    color: var(--verde-oscuro);
    font-weight: 600;
    text-decoration: underline;
}

.msg.user .bubble a[href^="mailto"] {
    color: var(--blanco);
    text-decoration: underline;
}

.bubble-mapa {
    max-width: 90% !important;
    width: 90%;
}

.hint-input {
    text-align: center;
    font-size: 0.65rem;
    color: var(--texto-suave);
    padding: 4px 14px;
    background: var(--blanco);
}



@media (max-width: 820px) {
    body {
        padding: 0;
    }

    .chat-wrapper {
        height: 100dvh;
        border-radius: 0;
    }

    #messages {
        flex: 1;
        min-height: 0;
        /* importante para que no se desborde */
    }

    .chat-input-area {
        padding-bottom: env(safe-area-inset-bottom, 12px);
        /* fix iPhone */
    }
}