:root {
    --chat-navy: #0c2e62;
    --chat-blue: #1677d2;
    --chat-green: #18a568;
    --chat-surface: #f4f8fd;
    --chat-border: #d8e4f1;
    --chat-text: #20324a;
}

.chat-widget {
    position: fixed;
    right: 1rem;
    bottom: 4.75rem;
    z-index: 1080;
    font-family: "Nunito Sans", sans-serif;
}

.chat-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    min-height: 4.2rem;
    padding: .95rem 1.35rem;
    border: 0;
    border-radius: 999px;
    background: var(--chat-navy);
    box-shadow: 0 12px 30px rgba(12, 46, 98, .28);
    color: #fff;
    font-size: 1.3rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.chat-launcher:hover,
.chat-launcher:focus-visible {
    transform: translateY(-2px);
    background: #123e7e;
    box-shadow: 0 16px 34px rgba(12, 46, 98, .34);
}

.chat-launcher svg {
    width: 1.85rem;
    height: 1.85rem;
    fill: currentColor;
}

.chat-launcher-badge {
    position: absolute;
    top: -.25rem;
    right: -.1rem;
    min-width: 1.7rem;
    height: 1.7rem;
    padding: 0 .25rem;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #d61b2c;
    color: #fff;
    font-size: .92rem;
    line-height: 1.35rem;
}

.chat-panel {
    position: absolute;
    right: 0;
    bottom: 5.1rem;
    display: grid;
    grid-template-rows: auto minmax(17rem, 1fr) auto;
    width: min(32.5rem, calc(100vw - 2rem));
    max-height: min(48rem, calc(100vh - 6.5rem));
    overflow: hidden;
    border: 1px solid rgba(12, 46, 98, .12);
    border-radius: 1.25rem;
    background: #fff;
    box-shadow: 0 24px 65px rgba(15, 39, 73, .24);
    animation: chat-panel-in .22s ease-out;
}

.chat-panel[hidden] {
    display: none;
}

.chat-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.35rem 1.5rem;
    background: linear-gradient(135deg, #0c2e62 0%, #155c9e 100%);
    color: #fff;
}

.chat-panel-header strong {
    display: block;
    font-size: 1.5rem;
}

.chat-availability {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-top: .25rem;
    color: #dceeff;
    font-size: 1.15rem;
}

.chat-availability i {
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    background: #aab9ca;
}

.chat-availability.is-online i {
    background: #39df8d;
    box-shadow: 0 0 0 4px rgba(57, 223, 141, .15);
}

.chat-close {
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: .9rem;
    min-height: 17rem;
    padding: 1.3rem;
    overflow-y: auto;
    background:
        radial-gradient(circle at 90% 10%, rgba(82, 169, 235, .12), transparent 35%),
        var(--chat-surface);
}

.chat-message {
    align-self: flex-start;
    max-width: 84%;
    padding: .9rem 1.1rem;
    border-radius: .95rem .95rem .95rem .25rem;
    background: #fff;
    box-shadow: 0 3px 12px rgba(24, 51, 84, .08);
    color: var(--chat-text);
    font-size: 1.3rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-message-customer {
    align-self: flex-end;
    border-radius: .95rem .95rem .25rem .95rem;
    background: var(--chat-blue);
    color: #fff;
}

.chat-message-system {
    max-width: 100%;
    border: 1px solid var(--chat-border);
    background: rgba(255, 255, 255, .8);
    color: #52647b;
    font-size: 1.2rem;
}

.chat-form {
    padding: 1.1rem;
    border-top: 1px solid var(--chat-border);
    background: #fff;
}

.chat-contact-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .7rem;
    margin-bottom: .7rem;
}

.chat-contact-fields label,
.chat-form > label {
    margin: 0;
}

.chat-contact-fields span {
    display: block;
    margin: 0 0 .2rem .15rem;
    color: #53657c;
    font-size: 1.08rem;
    font-weight: 700;
}

.chat-contact-fields small {
    font-weight: 500;
}

.chat-contact-fields input,
.chat-form textarea {
    width: 100%;
    border: 1px solid #c9d8e8;
    border-radius: .7rem;
    background: #fbfdff;
    color: var(--chat-text);
    font: inherit;
    font-size: 1.3rem;
    outline: none;
}

.chat-contact-fields input {
    height: 3.2rem;
    padding: .7rem .9rem;
}

.chat-form textarea {
    min-height: 4.6rem;
    max-height: 10rem;
    padding: .9rem 1rem;
    resize: vertical;
}

.chat-contact-fields input:focus,
.chat-form textarea:focus {
    border-color: var(--chat-blue);
    box-shadow: 0 0 0 3px rgba(22, 119, 210, .12);
}

.chat-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .9rem;
    margin-top: .75rem;
}

.chat-form-footer button {
    min-height: 3.4rem;
    padding: .7rem 1.45rem;
    border: 0;
    border-radius: .7rem;
    background: var(--chat-green);
    color: #fff;
    font-size: 1.3rem;
    font-weight: 800;
    cursor: pointer;
}

.chat-form-footer button:disabled {
    cursor: wait;
    opacity: .55;
}

.chat-form-error {
    color: #b7192d;
    font-size: 1.1rem;
    line-height: 1.25;
}

@keyframes chat-panel-in {
    from { opacity: 0; transform: translateY(.6rem) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 30rem) {
    .chat-widget {
        right: .75rem;
        bottom: 4.5rem;
    }

    .chat-panel {
        right: -.25rem;
        bottom: 5rem;
        width: calc(100vw - 1rem);
        max-height: calc(100vh - 5.5rem);
    }

    .chat-launcher-label {
        display: none;
    }

    .chat-launcher {
        width: 4.2rem;
        padding: .95rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-panel { animation: none; }
    .chat-launcher { transition: none; }
}
