#chatbot-root {
    --chatbot-radius: 22px;
    --chatbot-shadow: 0 24px 60px rgba(0, 12, 34, 0.24);
    --chatbot-border: 1px solid rgba(0, 31, 73, 0.12);
    font-family: 'Montserrat', sans-serif;
}

#chatbot-button {
    position: fixed;
    right: 35px;
    bottom: 35px;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: #072968;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    overflow: hidden;
    box-shadow: 0 14px 30px rgba(0, 31, 73, 0.28);
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.2s ease;
}

#chatbot-button:hover {
    transform: scale(1.08);
    box-shadow: 0 0 25px rgba(0, 80, 180, 0.45);
}

#chatbot-button:focus-visible,
#chatbot-close:focus-visible,
#chatbot-send:focus-visible,
#chatbot-input:focus-visible {
    outline: 3px solid rgba(0, 80, 180, 0.28);
    outline-offset: 2px;
}

#chatbot-button-img {
    max-width: 66px;
    height: 54px;
    display: block;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#chatbot-button-close {
    position: absolute;
    top: 50%;
    left: 50%;
    color: #fff;
    font-size: 34px;
    line-height: 1;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-open #chatbot-button-img {
    opacity: 0;
    transform: scale(0.85);
}

.chat-open #chatbot-button-close {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#chatbot-modal {
    position: fixed;
    right: 70px;
    bottom: 110px;
    width: min(420px, calc(100vw - 32px));
    height: min(680px, calc(100vh - 145px));
    background: #fff;
    border: var(--chatbot-border);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    transform-origin: bottom right;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

#chatbot-modal.chatbot-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(18px) scale(0.98);
}

#chatbot-header {
    background: #001F49;
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#chatbot-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

#chatbot-header img {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

#chatbot-header-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#chatbot-title {
    font-size: 15px;
    line-height: 1.2;
    font-weight: 600;
}

#chatbot-status {
    font-size: 12px;
    line-height: 1.2;
    font-weight: 500;
    opacity: 0.78;
}

#chatbot-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

#chatbot-close {
    display: none;
}

#chatbot-close:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.08);
}

#chatbot-messages {
    flex: 1;
    padding: 18px;
    background: #fff;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#chatbot-messages::-webkit-scrollbar {
    display: none;
}

#chatbot-input-area {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border-top: var(--chatbot-border);
    background: #fff;
}

#chatbot-input-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#chatbot-input {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    max-height: 132px;
    padding: 12px 14px;
    border: 1px solid rgba(0, 31, 73, 0.16);
    border-radius: 14px;
    background: #fff;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    overflow-y: hidden;
}

#chatbot-input::placeholder {
    color: #6f7b8a;
}

#chatbot-send {
    min-width: 92px;
    min-height: 46px;
    padding: 0 16px;
    border: none;
    border-radius: 14px;
    background: #001F49;
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

#chatbot-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(0, 31, 73, 0.2);
}

#chatbot-send:disabled,
#chatbot-input:disabled {
    cursor: not-allowed;
}

#chatbot-send:disabled {
    opacity: 0.82;
    box-shadow: none;
}

.chat-row {
    display: flex;
    width: 100%;
    animation: fadeInUp 0.25s ease;
}

#chatbot-root .chat-row.user {
    justify-content: flex-end;
}

#chatbot-root .chat-row.bot {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 75%;
    padding: 12px 14px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 400;
    overflow-wrap: anywhere;
    box-shadow: 0 8px 18px rgba(0, 31, 73, 0.06);
}

.chat-bubble.user {
    background: #001F49;
    color: #fff;
    border-bottom-right-radius: 6px;
}

.chat-bubble.bot {
    background: #fff;
    color: #333;
    border: 1px solid #e3e6ea;
    border-bottom-left-radius: 6px;
}

@media (max-width: 1600px) {
    #chatbot-modal {
        width: min(380px, calc(100vw - 32px));
        height: min(580px, calc(100vh - 130px));
        right: 60px;
    }
}

@media (max-width: 1300px) {
    #chatbot-modal {
        width: min(360px, calc(100vw - 28px));
        height: min(540px, calc(100vh - 120px));
    }
}

@media (max-width: 768px) {
    #chatbot-button {
        right: 20px;
        bottom: 20px;
        touch-action: manipulation;
    }

    .chat-open #chatbot-button {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(12px) scale(0.9);
    }

    #chatbot-modal {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 88vh;
        max-height: 88vh;
        height: min(720px, 88dvh);
        max-height: 88dvh;
        border-radius: 28px 28px 0 0;
        transform-origin: bottom center;
        z-index: 10001;
    }

    #chatbot-modal:not(.chatbot-hidden) {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0) scale(1);
    }

    #chatbot-header {
        padding: 16px;
    }

    #chatbot-close {
        display: inline-flex;
    }

    #chatbot-messages {
        padding: 14px;
    }

    #chatbot-input-area {
        padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    }

    .chat-bubble {
        max-width: 85%;
    }
}

@media (prefers-reduced-motion: reduce) {
    #chatbot-button,
    #chatbot-button-img,
    #chatbot-button-close,
    #chatbot-modal,
    #chatbot-close,
    #chatbot-send,
    .chat-row {
        transition: none;
        animation: none;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}
