#chatbot-panel {
    position: fixed;
    z-index: 10001;
    right: 140px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    width: min(390px, calc(100vw - 280px));
    max-height: min(680px, calc(100vh - 48px));
    min-height: 340px;
    height: min(78dvh, 820px);
    overflow: hidden;
    color: #173c36;
    background: #fff;
    border: 1px solid rgba(24, 153, 132, 0.24);
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(18, 54, 48, 0.24);
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

#chatbot-panel[hidden] {
    display: none;
}

.chatbot-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    color: #fff;
    background: var(--primary-action);
}

.chatbot-header h2 {
    margin: 0;
    font-size: 16px;
}

.chatbot-header p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-header-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.chatbot-header button {
    box-sizing: border-box;
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    color: inherit;
    background: rgba(255, 255, 255, 0.16);
    cursor: pointer;
    font: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.chatbot-composer button {
    min-width: 40px;
    min-height: 40px;
    touch-action: manipulation;
}

.chatbot-content {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex: 1 1 0;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
}

#chatbot-messages {
    display: flex;
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 8px;
}

.chatbot-exchange {
    display: flex;
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 8px;
}

.chatbot-message {
    width: fit-content;
    max-width: 90%;
    padding: 9px 12px;
    border-radius: 13px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.chatbot-message-assistant {
    align-self: flex-start;
    background: #eff7f5;
}

.chatbot-message-user {
    align-self: flex-end;
    color: #fff;
    background: var(--primary-action);
}

.chatbot-message-error {
    align-self: flex-start;
    color: #842b24;
    background: #fff0ed;
}

.chatbot-source {
    align-self: flex-start;
    max-width: 90%;
    color: #176f61;
    overflow-wrap: anywhere;
}

.chatbot-source:hover {
    color: #0e4d43;
}

#chatbot-faqs:not([hidden]) {
    display: flex;
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 10px;
    padding-top: 10px;
}

.chatbot-faq-heading {
    margin: 0;
    color: #42645e;
    font-size: 13px;
    font-weight: 700;
}

.chatbot-faq-categories {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.chatbot-faq-category-button,
.chatbot-faq-back {
    box-sizing: border-box;
    min-width: 0;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid #b9ddd5;
    border-radius: 10px;
    color: #176f61;
    background: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    text-align: left;
    overflow-wrap: anywhere;
    word-break: normal;
    transition: background-color 140ms ease, border-color 140ms ease;
}

.chatbot-faq-category-button {
    display: flex;
    width: 100%;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-start;
    white-space: normal;
}

.chatbot-faq-category-button:hover,
.chatbot-faq-back:hover {
    border-color: #75b9aa;
    background: #f2faf8;
}

.chatbot-faq-category-button:active,
.chatbot-faq-back:active {
    background: #e7f5f1;
}

.chatbot-faq-category-button:focus-visible,
.chatbot-faq-back:focus-visible {
    border-color: var(--color-institucional-naranja-oscuro);
}

.chatbot-faq-category {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-direction: column;
    gap: 8px;
}

.chatbot-faq-back {
    display: inline-flex;
    box-sizing: border-box;
    width: auto;
    min-width: 112px;
    align-self: flex-start;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    min-height: 36px;
    padding: 7px 10px;
    text-align: center;
}

.chatbot-faq-category h3 {
    margin: 0;
    color: #42645e;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
}

.chatbot-faq-questions {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-direction: column;
    gap: 8px;
}

.chatbot-faq-question,
.chatbot-suggestion {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 44px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #b9ddd5;
    border-radius: 10px;
    color: #176f61;
    background: #fff;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    transition: background-color 140ms ease, border-color 140ms ease;
}

.chatbot-faq-question:hover,
.chatbot-suggestion:hover {
    transform: none;
    border-color: #75b9aa;
    background: #f2faf8;
    box-shadow: none;
}

.chatbot-faq-question:active,
.chatbot-suggestion:active {
    transform: none;
    background: #e7f5f1;
    box-shadow: none;
}

#chatbot-suggestions {
    display: flex;
    min-width: 0;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
}

.chatbot-composer {
    display: flex;
    min-width: 0;
    flex-shrink: 0;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e6efed;
}

.chatbot-composer input {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid #cbdcd8;
    border-radius: 12px;
    color: #173c36;
    font: inherit;
}

.chatbot-composer button {
    color: #fff;
    background: var(--primary-action);
}

.chatbot-composer button:disabled {
    cursor: wait;
    opacity: 0.6;
}

.chatbot-event-card {
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border: 1px solid #d5e7e2;
    border-radius: 12px;
    background: #fff;
}

.chatbot-event-image {
    display: block;
    width: 100%;
    max-height: 150px;
    object-fit: cover;
}

.chatbot-event-title {
    margin: 12px 12px 6px;
    color: #173c36;
    font-size: 14px;
    line-height: 1.35;
}

.chatbot-event-meta,
.chatbot-event-description {
    margin: 5px 12px;
    color: #42645e;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.chatbot-event-description {
    color: #52635f;
}

.chatbot-event-location {
    min-height: 38px;
    margin: 7px 12px 12px;
    padding: 8px 10px;
    border: 1px solid #b9ddd5;
    border-radius: 9px;
    color: #176f61;
    background: #f7fbfa;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
}

.chatbot-event-location:hover {
    background: #eaf6f3;
}

#chatbot-status {
    flex: 0 0 auto;
    min-height: 18px;
    padding: 0 12px 6px;
    color: #54736c;
    font-size: 12px;
}

#chatbot-status.chatbot-status-error {
    color: #a33228;
}

#chatbot-panel button:focus-visible,
#chatbot-panel input:focus-visible {
    outline: 3px solid var(--color-institucional-naranja-oscuro);
    outline-offset: 2px;
}

@media (max-width: 700px) {
    #chatbot-panel {
        right: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
        max-height: calc(100dvh - 20px);
        min-height: min(240px, calc(100dvh - 20px));
        height: min(44dvh, 400px);
        border-radius: 16px;
    }

    .chatbot-content {
        padding: 10px;
    }
}

@media (max-width: 700px) and (max-height: 500px) {
    #chatbot-panel {
        right: 10px;
        bottom: 10px;
        max-height: calc(100dvh - 20px);
        min-height: 0;
        height: calc(100dvh - 20px);
    }
}

@media (max-width: 480px) {
    .chatbot-faq-categories {
        grid-template-columns: minmax(0, 1fr);
    }
}

body.chatbot-open #chatbot-panel {
    right: 140px;
    bottom: max(16px, env(safe-area-inset-bottom));
    width: min(400px, 40vw);
    height: min(78dvh, 860px);
    max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: min(420px, calc(100dvh - 32px));
}

body.chatbot-open .floating-details-card {
    position: fixed;
    z-index: 10000;
    right: calc(140px + min(400px, 40vw) + 18px);
    bottom: max(16px, env(safe-area-inset-bottom));
    display: flex;
    width: min(360px, calc(100vw - min(400px, 40vw) - 78px));
    max-width: none;
    max-height: min(78dvh, calc(100dvh - 32px));
    flex-direction: column;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transform: scale(0.96);
}

body.chatbot-open .floating-details-card.visible {
    right: calc(140px + min(400px, 40vw) + 18px);
    transform: scale(1);
}

body.chatbot-open .floating-details-card .card-content-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

body.chatbot-open .floating-details-card:not(.visible) {
    pointer-events: none;
}

@media (min-width: 900px) and (min-height: 620px) {
    body.chatbot-open #chatbot-panel {
        min-height: min(420px, calc(100dvh - 32px));
    }
}

@media (min-width: 601px) and (max-width: 899px) {
    body.chatbot-open #chatbot-panel {
        right: calc(20px + 110px + 12px + env(safe-area-inset-right));
        bottom: max(8px, env(safe-area-inset-bottom));
        left: auto;
        width: min(440px, calc(100vw - 24px - 110px - 12px - env(safe-area-inset-right)));
        height: 48vh;
        height: min(48dvh, 500px);
        max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        min-height: min(240px, 48dvh, calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    }

    body.chatbot-open .floating-details-card {
        right: auto;
        bottom: calc(max(8px, env(safe-area-inset-bottom)) + min(48dvh, 500px) + 12px);
        left: 50%;
        width: min(620px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
        max-height: min(32dvh, calc(100dvh - min(48dvh, 500px) - 36px));
        margin: 0;
        padding: 0;
        z-index: 10002;
        overflow: hidden;
        transform: translate(-50%, calc(100% + 20px));
        border-radius: 18px;
        box-shadow: 0 12px 32px rgba(18, 54, 48, 0.28);
    }

    body.chatbot-open .floating-details-card.visible {
        right: auto;
        transform: translate(-50%, 0);
    }

    body.chatbot-open .floating-details-card .card-content-body {
        min-height: 0;
        flex: 1 1 auto;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (min-width: 601px) and (max-width: 899px) and (orientation: landscape) and (max-height: 620px) {
    body.chatbot-open #chatbot-panel {
        height: 50vh;
        height: min(50dvh, 360px);
        min-height: min(180px, 50dvh, calc(100dvh - 16px));
    }

    body.chatbot-open .floating-details-card {
        top: max(8px, env(safe-area-inset-top));
        bottom: auto;
        max-height: calc(50dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        transform: translate(-50%, calc(-100% - 20px));
    }

    body.chatbot-open .floating-details-card.visible {
        transform: translate(-50%, 0);
    }
}

@media (max-width: 600px) {
    body.chatbot-open #chatbot-panel {
        z-index: 10001;
        right: max(10px, env(safe-area-inset-right));
        bottom: max(8px, env(safe-area-inset-bottom));
        left: max(10px, env(safe-area-inset-left));
        width: auto;
        height: 50vh;
        height: 50dvh;
        max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        min-height: min(220px, 50dvh);
    }

    body.chatbot-open .floating-details-card {
        top: max(8px, env(safe-area-inset-top));
        right: auto;
        bottom: auto;
        left: 50%;
        width: min(620px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
        max-height: calc(50dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        z-index: 10002;
        transform: translate(-50%, calc(100% + 20px));
        border-radius: 18px;
        box-shadow: 0 12px 32px rgba(18, 54, 48, 0.28);
    }

    body.chatbot-open .floating-details-card.visible {
        right: auto;
        transform: translate(-50%, 0);
    }

    body.chatbot-open .floating-details-card .card-content-body {
        min-height: 0;
        flex: 1 1 auto;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (max-height: 500px) {
    body.chatbot-open .chatbot-header {
        padding: 8px 12px;
    }

    body.chatbot-open .chatbot-header p {
        display: none;
    }

    body.chatbot-open .chatbot-composer button {
        min-width: 36px;
        min-height: 36px;
        height: 36px;
    }

    body.chatbot-open .chatbot-content {
        padding: 4px 8px;
    }

    body.chatbot-open #chatbot-status {
        min-height: 12px;
        padding: 0 8px 2px;
        line-height: 1;
    }

    body.chatbot-open .chatbot-composer {
        padding: 4px 8px;
    }

    body.chatbot-open .chatbot-composer input {
        min-height: 36px;
        padding: 6px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #chatbot-panel *,
    #chatbot-panel *::before,
    #chatbot-panel *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
    }
}
