.flora-chat-widget {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1200;
    font-family: "Montserrat", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    --flora-chat-font-size: 11px;
    --flora-chat-meta-size: 9px;
    --flora-chat-label-size: 11px;
    --flora-chat-input-size: 12px;
}

.flora-chat-widget,
.flora-chat-widget * {
    box-sizing: border-box;
}

/* Defensive reset against global template rules like `section { padding: ... }`. */
.flora-chat-widget section,
.flora-chat-widget div,
.flora-chat-widget header,
.flora-chat-widget p,
.flora-chat-widget h2,
.flora-chat-widget form {
    margin: 0;
}

.flora-chat-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    background: #214f35;
    color: #fff;
    font-size: 14px;
    line-height: 1;
    font-weight: 600;
    box-shadow: 0 10px 24px rgba(21, 40, 27, 0.22);
    cursor: pointer;
}

.flora-chat-launcher-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.flora-chat-launcher-icon svg {
    width: 16px;
    height: 16px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.flora-chat-launcher-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #d72828;
    color: #ffffff;
    border: 2px solid #ffffff;
    font-size: 10px;
    line-height: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 6px rgba(16, 20, 17, 0.24);
}

.flora-chat-widget.is-open .flora-chat-launcher,
.flora-chat-widget.is-open .flora-chat-cta {
    display: none !important;
}

.flora-chat-cta {
    border: 1px solid #c8d9ca;
    border-radius: 12px;
    background: #ffffff;
    color: #244734;
    position: relative;
    padding: 10px 38px 10px 12px;
    width: min(290px, calc(100vw - 24px));
    text-align: left;
    box-shadow: 0 12px 28px rgba(21, 40, 27, 0.18);
    animation: flora-chat-cta-pulse 2.4s ease-in-out infinite;
}

.flora-chat-cta-main {
    display: block;
    width: 100%;
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.flora-chat-cta-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #557465;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.flora-chat-cta-close:hover {
    background: #edf4ef;
    color: #284837;
}

.flora-chat-cta-kicker {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #2d7a4e;
}

.flora-chat-cta-title {
    display: block;
    margin-top: 2px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.flora-chat-cta-text {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: #4b6655;
}

@keyframes flora-chat-cta-pulse {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-1px);
    }
    100% {
        transform: translateY(0);
    }
}

.flora-chat-panel {
    width: min(360px, calc(100vw - 24px));
    max-height: min(78vh, 620px);
    margin-top: 10px;
    padding: 0 !important;
    background: #fff;
    border: 1px solid #d7e2d5;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(28, 45, 33, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.flora-chat-header {
    background: #f4f8f4;
    border-bottom: 1px solid #d7e2d5;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
}

.flora-chat-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.flora-chat-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.2;
    color: #173824;
}

.flora-chat-status {
    margin: 4px 0 0;
    font-size: 12px;
    color: #4b6655;
}

.flora-chat-close {
    border: none;
    background: transparent;
    color: #32503f;
    font-size: 24px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.flora-chat-font-control {
    position: relative;
}

.flora-chat-font-toggle {
    border: 1px solid #c8d8cb;
    border-radius: 999px;
    background: #ffffff;
    color: #264536;
    min-width: 40px;
    height: 28px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    font-weight: 700;
}

.flora-chat-font-toggle-small {
    font-size: 11px;
}

.flora-chat-font-toggle-large {
    font-size: 15px;
}

.flora-chat-font-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #ffffff;
    border: 1px solid #c8d8cb;
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(21, 40, 27, 0.16);
    padding: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    z-index: 5;
}

.flora-chat-font-option {
    border: 1px solid #d5e1d7;
    background: #f8fbf8;
    color: #274838;
    border-radius: 6px;
    width: 30px;
    height: 30px;
    font-weight: 700;
    cursor: pointer;
}

.flora-chat-font-option[data-chat-font-step="-1"] {
    font-size: 12px;
}

.flora-chat-font-option[data-chat-font-step="1"] {
    font-size: 18px;
}

.flora-chat-font-option:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.flora-chat-font-current {
    min-width: 38px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #36594a;
}

.flora-chat-body {
    padding: 10px !important;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.flora-chat-view {
    padding: 0 !important;
    margin: 0 !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.flora-chat-view[hidden] {
    display: none !important;
}

.flora-chat-view[data-chat-view="chat"] {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.flora-chat-view[data-chat-view="topic"] {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flora-chat-consent-text,
.flora-chat-hint,
.flora-chat-feedback {
    font-size: var(--flora-chat-font-size);
    color: #3d5648;
}

.flora-chat-consent-text {
    line-height: 1.55;
}

.flora-chat-lead-intro {
    font-size: var(--flora-chat-label-size);
    color: #446051;
    margin-bottom: 10px !important;
    line-height: 1.5;
}

.flora-chat-prechat-intro-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 2px;
}

.flora-chat-prechat-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 999px;
    border: 1px solid #c4d6c8;
    background: #ffffff;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.flora-chat-prechat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.flora-chat-prechat-bubble {
    max-width: min(82%, 260px);
    border: 1px solid #d3e1d6;
    border-radius: 11px;
    border-top-left-radius: 4px;
    background: #ffffff;
    box-shadow: 0 2px 3px rgba(16, 30, 20, 0.06);
    padding: 8px 10px;
}

.flora-chat-prechat-intro {
    margin: 0 !important;
    font-size: var(--flora-chat-font-size);
    line-height: 1.45;
    color: #2b4637;
}

.flora-chat-topic-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.flora-chat-topic-button {
    justify-content: center;
    text-align: center;
    min-height: 34px;
    font-size: var(--flora-chat-font-size);
    color: #2a4b3a;
    border-color: #c8d9cc;
    background: #f7fbf8;
}

.flora-chat-topic-button:hover {
    background: #edf5ef;
    border-color: #9bb8a5;
    color: #223c2f;
}

.flora-chat-topic-button.is-active,
.flora-chat-topic-button[aria-pressed="true"] {
    background: #214f35;
    border-color: #214f35;
    color: #ffffff;
}

.flora-chat-topic-summary {
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid #d4e2d7;
    border-radius: 10px;
    background: #f7fbf8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: var(--flora-chat-font-size);
    color: #345a46;
}

.flora-chat-topic-change {
    font-size: var(--flora-chat-font-size);
    color: #22563a;
    text-decoration: none;
}

.flora-chat-topic-change:hover {
    color: #1b4630;
    text-decoration: underline;
}

.flora-chat-body .form-label {
    font-size: var(--flora-chat-label-size);
}

.flora-chat-body .form-control {
    font-size: var(--flora-chat-input-size);
}

.flora-chat-consent-actions,
.flora-chat-message-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 10px;
}

.flora-chat-message-list {
    border: 1px solid #d7e2d5;
    border-radius: 10px;
    background: linear-gradient(180deg, #eef6ef 0%, #e7f0e8 100%);
    position: relative;
    width: 100%;
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.flora-chat-message-list.is-loading {
    overflow: hidden;
}

.flora-chat-message-list.is-loading .flora-chat-message-row {
    display: none;
}

.flora-chat-message-loader {
    width: 100%;
    display: none;
    flex-direction: column;
    gap: 12px;
}

.flora-chat-message-list.is-loading .flora-chat-message-loader {
    display: flex;
}

.flora-chat-message-loader-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.flora-chat-message-loader-row.is-right {
    justify-content: flex-end;
}

.flora-chat-message-loader-avatar,
.flora-chat-message-loader-line {
    background: linear-gradient(90deg, #dfe8e0 25%, #f3f7f3 50%, #dfe8e0 75%);
    background-size: 220% 100%;
    animation: flora-chat-skeleton-shimmer 1.3s ease-in-out infinite;
}

.flora-chat-message-loader-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 999px;
}

.flora-chat-message-loader-bubble {
    width: min(72%, 230px);
    border-radius: 12px;
    background: #edf3ee;
    border: 1px solid #d9e4db;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.flora-chat-message-loader-line {
    height: 10px;
    border-radius: 999px;
    display: block;
}

.flora-chat-message-loader-line.is-wide {
    width: 88%;
}

.flora-chat-message-loader-line.is-mid {
    width: 62%;
}

.flora-chat-message-loader-line.is-short {
    width: 42%;
}

@keyframes flora-chat-skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.flora-chat-message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0;
}

.flora-chat-message-row-visitor {
    justify-content: flex-end;
}

.flora-chat-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 999px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.flora-chat-avatar-agent {
    border: 1px solid #c4d6c8;
    background: #ffffff;
}

.flora-chat-avatar-agent img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flora-chat-avatar-visitor {
    background: #244d35;
    color: #ffffff;
}

.flora-chat-avatar-system {
    background: #8a8f97;
    color: #ffffff;
}

.flora-chat-bubble-wrap {
    max-width: min(78%, 254px);
    display: flex;
    flex-direction: column;
}

.flora-chat-message-name {
    display: block;
    margin-bottom: 3px;
    font-size: 11px;
    line-height: 1.3;
    color: #456252;
}

.flora-chat-message-row-visitor .flora-chat-message-name {
    display: none;
}

.flora-chat-bubble-wrap-visitor .flora-chat-message-name {
    text-align: right !important;
}

.flora-chat-bubble {
    position: relative;
    border-radius: 11px;
    padding: 7px 9px 6px;
    font-size: var(--flora-chat-font-size);
    line-height: 1.45;
    box-shadow: 0 2px 3px rgba(16, 30, 20, 0.07);
}

.flora-chat-bubble-agent {
    background: #ffffff;
    color: #22392d;
    border-top-left-radius: 4px;
}

.flora-chat-bubble-agent::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 7px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid #ffffff;
}

.flora-chat-bubble-visitor {
    background: #dcf8c6;
    color: #1b3829;
    border-top-right-radius: 4px;
}

.flora-chat-bubble-visitor::before {
    content: "";
    position: absolute;
    right: -5px;
    top: 7px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid #dcf8c6;
}

.flora-chat-bubble-system {
    background: #fff7df;
    color: #5a4920;
}

.flora-chat-message-meta {
    margin-top: 4px;
    display: block;
    text-align: right;
    font-size: var(--flora-chat-meta-size);
    line-height: 1.2;
    color: #648173;
}

.flora-chat-message-text {
    margin: 0;
    font-size: var(--flora-chat-font-size) !important;
    line-height: 1.45 !important;
    font-weight: 400;
    color: inherit;
    white-space: pre-wrap;
    word-break: break-word;
}

.flora-chat-feedback {
    min-height: 18px;
    margin: 0;
    padding: 0 12px 12px;
}

.flora-chat-feedback.is-error {
    color: #9d1f1f;
}

.flora-chat-message-form {
    border: 1px solid #c8d9cc;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbf8 100%);
    box-shadow: 0 8px 16px rgba(19, 36, 25, 0.1);
    width: 100%;
    flex: 0 0 auto;
    padding: 10px;
}

.flora-chat-message-form .form-control {
    border: 1px solid #bfd3c5;
    border-radius: 10px;
    background: #f8fcf9;
    min-height: 74px;
    padding: 10px 12px;
    color: #203a2c;
    font-size: var(--flora-chat-input-size);
    line-height: 1.45;
    resize: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.flora-chat-message-form .form-control::placeholder {
    color: #6d8578;
}

.flora-chat-message-form .form-control:focus {
    border-color: #5f9d78;
    box-shadow: 0 0 0 3px rgba(95, 157, 120, 0.17);
    background: #ffffff;
}

.flora-chat-message-actions {
    margin-top: 10px;
    justify-content: space-between;
    align-items: center;
}

.flora-chat-message-actions .btn {
    border-radius: 999px;
    min-height: 32px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
}

.flora-chat-message-actions .btn-dark {
    min-width: 96px;
    border-color: #203a2c;
    background: #203a2c;
    box-shadow: 0 4px 10px rgba(20, 37, 28, 0.18);
}

.flora-chat-message-actions .btn-outline-danger {
    border-color: #d9c2c2;
    color: #7a2a2a;
    background: #fff8f8;
}

@media (max-width: 600px) {
    .flora-chat-widget {
        right: 8px;
        bottom: 8px;
        left: 8px;
        align-items: stretch;
    }

    .flora-chat-launcher {
        margin-left: auto;
    }

    .flora-chat-cta {
        width: 100%;
    }

    .flora-chat-panel {
        width: 100%;
        max-height: 72vh;
    }

    .flora-chat-topic-grid {
        grid-template-columns: 1fr;
    }

    .flora-chat-topic-summary {
        align-items: flex-start;
        flex-direction: column;
    }
}
