.customer-chat-modal[hidden],
.customer-chat-topics[hidden],
.customer-chat-conversation[hidden],
.customer-chat-typing[hidden] {
    display: none !important;
}

.customer-chat-back[hidden] {
    display: grid !important;
    visibility: hidden;
    pointer-events: none;
}

body.customer-chat-open {
    overflow: hidden;
}

.customer-chat-launcher {
    position: fixed;
    z-index: 9990;
    left: max(18px, env(safe-area-inset-left));
    bottom: max(18px, env(safe-area-inset-bottom));
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    padding: 0 20px;
    color: #fff;
    background: linear-gradient(135deg, var(--theme-accent), #0a8068);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 999px;
    box-shadow: 0 14px 40px rgba(0, 19, 15, 0.32);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.customer-chat-launcher:hover,
.customer-chat-launcher:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 18px 46px rgba(0, 19, 15, 0.4);
}

.customer-chat-launcher-dot {
    width: 10px;
    height: 10px;
    background: #8df9c7;
    border: 2px solid rgba(255, 255, 255, 0.72);
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(141, 249, 199, 0.16);
}

.app-mode .customer-chat-launcher {
    bottom: calc(78px + env(safe-area-inset-bottom));
}

.customer-chat-modal {
    position: fixed;
    z-index: 10000;
    inset: 0;
    padding: 0;
    background: rgba(0, 15, 12, 0.82);
    backdrop-filter: blur(10px);
}

.customer-chat-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: 100%;
    color: #15251f;
    background: radial-gradient(circle at 12% 0%, rgba(39, 190, 151, 0.11), transparent 34%), #f4f7f5;
}

.customer-chat-header {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    align-items: center;
    min-height: 78px;
    padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    color: #fff;
    background: radial-gradient(circle at 18% -50%, rgba(71, 233, 191, 0.34), transparent 44%), linear-gradient(135deg, #001f18, #064f40);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 28px rgba(0, 25, 20, 0.16);
}

.customer-chat-agent {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    min-width: 0;
}

.customer-chat-agent > span:last-child {
    display: grid;
    gap: 2px;
}

.customer-chat-agent strong {
    font-size: 1rem;
}

.customer-chat-agent small {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.75rem;
}

.customer-chat-agent small i {
    width: 7px;
    height: 7px;
    background: #6bf0b5;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(107, 240, 181, 0.14);
}

.customer-chat-avatar {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 40px;
    height: 40px;
    color: #05352b;
    background: linear-gradient(145deg, #bafee1, #68d7b6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 900;
}

.customer-chat-avatar.large {
    width: 62px;
    height: 62px;
    margin-bottom: 16px;
    border-radius: 20px;
    font-size: 1rem;
    box-shadow: 0 13px 30px rgba(0, 72, 57, 0.15);
}

.customer-chat-back,
.customer-chat-close {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 14px;
    font: inherit;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

.customer-chat-back {
    justify-self: start;
    font-size: 2.2rem;
}

.customer-chat-close {
    justify-self: end;
}

.customer-chat-topics,
.customer-chat-conversation {
    min-height: 0;
}

.customer-chat-topics {
    display: grid;
    align-content: center;
    width: min(680px, calc(100% - 36px));
    margin: 0 auto;
    padding: 44px 0;
}

.customer-chat-welcome {
    margin-bottom: 28px;
    text-align: center;
}

.customer-chat-welcome .eyebrow {
    margin: 0 0 8px;
    color: #0b7b62;
}

.customer-chat-welcome h2 {
    margin: 0;
    color: #092d25;
    font-size: clamp(2rem, 5vw, 3.2rem);
}

.customer-chat-welcome p:last-child {
    margin: 10px 0 0;
    color: #60716a;
}

.customer-chat-topic-list {
    display: grid;
    gap: 12px;
}

.customer-chat-topic-list button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: 100%;
    min-height: 72px;
    padding: 17px 20px;
    color: #17362f;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #d6e2dd;
    border-radius: 18px;
    box-shadow: 0 9px 28px rgba(0, 54, 43, 0.07);
    font: inherit;
    font-size: 1rem;
    font-weight: 750;
    text-align: left;
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.customer-chat-topic-list button:hover,
.customer-chat-topic-list button:focus-visible {
    transform: translateY(-2px);
    border-color: #49b99a;
    box-shadow: 0 13px 34px rgba(0, 72, 57, 0.12);
}

.customer-chat-topic-list button b {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    color: #fff;
    background: #08745d;
    border-radius: 11px;
}

.customer-chat-limit-note {
    margin: 18px auto 0;
    color: #788780;
    font-size: 0.72rem;
    text-align: center;
}

.customer-chat-conversation {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    width: min(920px, 100%);
    margin: 0 auto;
    overflow: hidden;
}

.customer-chat-messages {
    min-height: 0;
    padding: 28px clamp(16px, 4vw, 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.customer-chat-message {
    display: grid;
    width: fit-content;
    max-width: min(78%, 650px);
    margin: 0 0 18px;
}

.customer-chat-message strong {
    margin: 0 10px 6px;
    color: #718079;
    font-size: 0.7rem;
}

.customer-chat-message p {
    margin: 0;
    padding: 13px 16px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #fff;
    border: 1px solid #dce5e1;
    border-radius: 6px 18px 18px;
    box-shadow: 0 8px 24px rgba(0, 43, 34, 0.06);
    line-height: 1.55;
}

.customer-chat-message small {
    margin: 6px 10px 0;
    color: #8b9792;
    font-size: 0.66rem;
}

.customer-chat-message.role-user {
    justify-items: end;
    margin-left: auto;
}

.customer-chat-message.role-user p {
    color: #fff;
    background: linear-gradient(135deg, #08634f, #09866b);
    border-color: transparent;
    border-radius: 18px 6px 18px 18px;
}

.customer-chat-products {
    display: grid;
    gap: 10px;
    width: min(650px, 100%);
    margin-top: 10px;
}

.customer-chat-product-card {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 13px 15px;
    padding: 12px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #d6e2dd;
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(0, 54, 43, 0.09);
}

.customer-chat-product-image {
    grid-row: span 2;
    display: block;
    width: 96px;
    height: 96px;
    overflow: hidden;
    background: #edf4f1;
    border-radius: 13px;
}

.customer-chat-product-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.customer-chat-product-details {
    display: grid;
    align-content: start;
    gap: 3px;
    min-width: 0;
}

.customer-chat-product-name {
    color: #103b31;
    font-size: 0.98rem;
    font-weight: 850;
    line-height: 1.2;
    text-decoration: none;
}

.customer-chat-product-details small {
    margin: 0;
    color: #6d7c76;
    font-size: 0.72rem;
}

.customer-chat-product-price {
    margin-top: 4px;
    color: #08735c;
    font-size: 0.94rem;
}

.customer-chat-product-form {
    grid-column: 2;
    display: grid;
    gap: 8px;
    min-width: 0;
}

.customer-chat-product-form select {
    width: 100%;
    min-height: 38px;
    padding: 7px 32px 7px 10px;
    color: #193a32;
    background: #f5f8f7;
    border: 1px solid #ccd9d4;
    border-radius: 10px;
    font: inherit;
    font-size: 0.76rem;
}

.customer-chat-product-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.customer-chat-product-actions button {
    min-height: 38px;
    padding: 0 14px;
    color: #fff;
    background: #08735c;
    border: 0;
    border-radius: 10px;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 850;
    cursor: pointer;
}

.customer-chat-product-actions button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.customer-chat-product-actions a {
    color: #315d52;
    font-size: 0.74rem;
    font-weight: 750;
}

.customer-chat-product-status {
    min-height: 0;
    margin: 0 !important;
    color: #08735c !important;
    font-size: 0.7rem !important;
}

.customer-chat-product-status[data-type="error"] {
    color: #a53c32 !important;
}

.customer-chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 clamp(22px, 5vw, 48px) 14px;
}

.customer-chat-typing span {
    width: 7px;
    height: 7px;
    background: #4d6b61;
    border-radius: 50%;
    animation: customer-chat-typing 1.2s infinite ease-in-out;
}

.customer-chat-typing span:nth-child(2) {
    animation-delay: 150ms;
}

.customer-chat-typing span:nth-child(3) {
    animation-delay: 300ms;
}

.customer-chat-typing small {
    margin-left: 7px;
    color: #6f7e78;
    font-size: 0.72rem;
}

@keyframes customer-chat-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.42; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.customer-chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
    padding: 14px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: rgba(255, 255, 255, 0.94);
    border-top: 1px solid #dce5e1;
    box-shadow: 0 -10px 28px rgba(0, 49, 39, 0.06);
}

.customer-chat-form textarea {
    width: 100%;
    min-height: 44px;
    max-height: 128px;
    margin: 0;
    padding: 11px 14px;
    resize: none;
    color: #16332c;
    background: #f4f7f5;
    border: 1px solid #cedbd6;
    border-radius: 15px;
    font: inherit;
    line-height: 1.45;
}

.customer-chat-form textarea:focus {
    outline: 3px solid rgba(18, 154, 121, 0.16);
    border-color: #159876;
}

.customer-chat-form button {
    min-width: 76px;
    min-height: 44px;
    padding: 0 17px;
    color: #fff;
    background: #08735c;
    border: 0;
    border-radius: 14px;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 800;
    cursor: pointer;
}

.customer-chat-form button:disabled {
    cursor: wait;
    opacity: 0.55;
}

@media (max-width: 760px) {
    .customer-chat-launcher {
        min-height: 46px;
        padding: 0 15px;
        font-size: 0.78rem;
    }

    .customer-chat-header {
        min-height: 70px;
    }

    .customer-chat-topics {
        align-content: start;
        width: min(100% - 28px, 620px);
        padding: 30px 0;
        overflow-y: auto;
    }

    .customer-chat-topic-list button {
        min-height: 64px;
    }

    .customer-chat-message {
        max-width: 88%;
    }

    .customer-chat-product-card {
        grid-template-columns: 76px minmax(0, 1fr);
        gap: 10px 12px;
        padding: 10px;
    }

    .customer-chat-product-image {
        width: 76px;
        height: 76px;
    }

    .customer-chat-product-actions {
        align-items: stretch;
        flex-direction: column;
        gap: 7px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .customer-chat-typing span {
        animation: none;
    }
}
