.ai-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1080;
    font-family: inherit;
}

.ai-chat-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 60px;
    padding: 10px 17px 10px 10px;
    color: #0F172A;
    border: 1px solid rgba(14, 165, 233, 0.32);
    border-radius: 999px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(239, 249, 255, 0.96)),
        linear-gradient(135deg, rgba(14, 165, 233, 0.14), rgba(45, 212, 191, 0.14));
    box-shadow: 0 18px 42px rgba(8, 47, 73, 0.24), 0 0 0 0 rgba(14, 165, 233, 0.28);
    font-weight: 900;
    letter-spacing: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    animation: ai-chat-breathe 2.8s ease-in-out infinite;
}

.ai-chat-toggle:hover,
.ai-chat-toggle:focus {
    border-color: rgba(20, 184, 166, 0.56);
    box-shadow: 0 22px 50px rgba(8, 47, 73, 0.3), 0 0 0 8px rgba(14, 165, 233, 0.08);
    transform: translateY(-2px);
}

.ai-chat-toggle-core {
    position: relative;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    color: #FFFFFF;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284C7 0%, #14B8A6 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34);
}

.ai-chat-robot-face {
    position: relative;
    width: 22px;
    height: 17px;
    border: 2px solid rgba(255, 255, 255, 0.95);
    border-radius: 7px;
}

.ai-chat-robot-face::before,
.ai-chat-robot-face::after {
    content: "";
    position: absolute;
    top: 5px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #FFFFFF;
}

.ai-chat-robot-face::before {
    left: 4px;
}

.ai-chat-robot-face::after {
    right: 4px;
}

.ai-chat-toggle-text {
    white-space: nowrap;
}

.ai-chat-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    display: flex;
    width: min(410px, calc(100vw - 32px));
    height: min(620px, calc(100vh - 118px));
    min-height: 430px;
    overflow: hidden;
    flex-direction: column;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    background: #F8FBFF;
    box-shadow: 0 26px 80px rgba(15, 23, 42, 0.28);
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px) scale(0.98);
    transform-origin: right bottom;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.ai-chat-widget.is-open .ai-chat-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.ai-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    color: #FFFFFF;
    background:
        linear-gradient(135deg, rgba(12, 74, 110, 0.98), rgba(15, 118, 110, 0.98)),
        linear-gradient(90deg, rgba(255, 255, 255, 0.12), transparent);
}

.ai-chat-kicker {
    color: rgba(255, 255, 255, 0.74);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.3;
    text-transform: uppercase;
}

.ai-chat-title {
    color: #FFFFFF;
    font-size: 18px;
    font-weight: 900;
    line-height: 1.35;
}

.ai-chat-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.84);
    font-size: 12px;
    font-weight: 700;
}

.ai-chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #67E8F9;
    box-shadow: 0 0 0 4px rgba(103, 232, 249, 0.16);
}

.ai-chat-close {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    flex: 0 0 auto;
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    font-size: 24px;
    line-height: 1;
}

.ai-chat-close:hover,
.ai-chat-close:focus {
    background: rgba(255, 255, 255, 0.22);
}

.ai-chat-quick {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    background: #FFFFFF;
}

.ai-chat-quick-btn {
    flex: 0 0 auto;
    max-width: 180px;
    min-height: 32px;
    padding: 7px 10px;
    color: #0F4C81;
    border: 1px solid rgba(14, 165, 233, 0.22);
    border-radius: 999px;
    background: #F0F9FF;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.3;
    white-space: nowrap;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.ai-chat-quick-btn:hover,
.ai-chat-quick-btn:focus {
    border-color: rgba(20, 184, 166, 0.5);
    background: #ECFEFF;
    transform: translateY(-1px);
}

.ai-chat-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding: 18px;
    background:
        linear-gradient(180deg, rgba(248, 251, 255, 0.98), rgba(238, 247, 255, 0.98)),
        repeating-linear-gradient(0deg, rgba(14, 165, 233, 0.045) 0, rgba(14, 165, 233, 0.045) 1px, transparent 1px, transparent 28px);
}

.ai-chat-message {
    display: flex;
    width: 100%;
    flex-direction: column;
}

.ai-chat-message-user {
    align-items: flex-end;
}

.ai-chat-message-bot {
    align-items: flex-start;
}

.ai-chat-bubble {
    max-width: 86%;
    padding: 11px 13px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
}

.ai-chat-message-bot .ai-chat-bubble {
    color: #1E293B;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.ai-chat-message-user .ai-chat-bubble {
    color: #FFFFFF;
    background: linear-gradient(135deg, #2563EB, #0891B2);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}

.ai-chat-message-error .ai-chat-bubble {
    color: #7C2D12;
    border-color: rgba(251, 146, 60, 0.35);
    background: #FFF7ED;
}

.ai-chat-thinking .ai-chat-bubble {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #475569;
}

.ai-chat-dots {
    display: inline-flex;
    gap: 4px;
}

.ai-chat-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #14B8A6;
    animation: ai-chat-dot 1s ease-in-out infinite;
}

.ai-chat-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-chat-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

.ai-chat-actions {
    display: flex;
    max-width: 86%;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.ai-chat-action {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    color: #0F766E;
    border: 1px solid rgba(20, 184, 166, 0.28);
    border-radius: 999px;
    background: #F0FDFA;
    font-size: 12px;
    font-weight: 900;
}

.ai-chat-action:hover,
.ai-chat-action:focus {
    color: #0F4C81;
    border-color: rgba(14, 165, 233, 0.45);
    background: #E0F2FE;
}

.ai-chat-form {
    display: flex;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    background: #FFFFFF;
}

.ai-chat-input {
    min-width: 0;
    height: 42px;
    flex: 1;
    padding: 9px 12px;
    color: #172033;
    border: 1px solid #C6D4E4;
    border-radius: 8px;
    background: #F8FAFC;
    font-size: 14px;
    outline: none;
}

.ai-chat-input:focus {
    border-color: #0284C7;
    background: #FFFFFF;
    box-shadow: 0 0 0 0.18rem rgba(14, 165, 233, 0.14);
}

.ai-chat-send {
    width: 68px;
    height: 42px;
    flex: 0 0 auto;
    color: #FFFFFF;
    border: 0;
    border-radius: 8px;
    background: #0F766E;
    font-weight: 900;
}

.ai-chat-send:hover,
.ai-chat-send:focus {
    background: #115E59;
}

.ai-chat-send:disabled,
.ai-chat-input:disabled,
.ai-chat-quick-btn:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

@keyframes ai-chat-breathe {
    0%,
    100% {
        box-shadow: 0 18px 42px rgba(8, 47, 73, 0.24), 0 0 0 0 rgba(14, 165, 233, 0.24);
    }
    50% {
        box-shadow: 0 18px 42px rgba(8, 47, 73, 0.24), 0 0 0 10px rgba(14, 165, 233, 0);
    }
}

@keyframes ai-chat-dot {
    0%,
    80%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@media (max-width: 575.98px) {
    .ai-chat-widget {
        right: 14px;
        bottom: 14px;
    }

    .ai-chat-panel {
        right: -2px;
        bottom: 72px;
        width: calc(100vw - 28px);
        height: min(560px, calc(100vh - 104px));
        min-height: 360px;
    }

    .ai-chat-toggle {
        min-height: 54px;
        padding-right: 12px;
    }

    .ai-chat-toggle-text {
        display: none;
    }

    .ai-chat-bubble,
    .ai-chat-actions {
        max-width: 92%;
    }

    .ai-chat-quick-btn {
        max-width: 168px;
    }
}

@media (min-width: 992px) {
    .site-body:has(.user-dashboard-page) .ai-chat-widget,
    .site-body:has(.order-list-page) .ai-chat-widget {
        right: 24px;
        bottom: calc(8px + var(--ai-chat-lift, 0px));
    }

    .site-body:has(.user-dashboard-page) .ai-chat-toggle,
    .site-body:has(.order-list-page) .ai-chat-toggle {
        width: 48px;
        min-height: 48px;
        justify-content: center;
        gap: 0;
        padding: 4px;
        animation: none;
        box-shadow: 0 10px 28px rgba(8, 47, 73, 0.2);
    }

    .site-body:has(.user-dashboard-page) .ai-chat-toggle:hover,
    .site-body:has(.user-dashboard-page) .ai-chat-toggle:focus,
    .site-body:has(.order-list-page) .ai-chat-toggle:hover,
    .site-body:has(.order-list-page) .ai-chat-toggle:focus {
        box-shadow: 0 12px 32px rgba(8, 47, 73, 0.24), 0 0 0 6px rgba(14, 165, 233, 0.08);
    }

    .site-body:has(.user-dashboard-page) .ai-chat-toggle-core,
    .site-body:has(.order-list-page) .ai-chat-toggle-core {
        width: 38px;
        height: 38px;
    }

    .site-body:has(.user-dashboard-page) .ai-chat-toggle-text,
    .site-body:has(.order-list-page) .ai-chat-toggle-text {
        display: none;
    }
}
