/* Standalone AI chat UI; no Blazor circuit or scoped CSS attributes required. */
.ai-robot-wrapper {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ai-robot-toggle {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
}

.ai-robot-toggle[hidden] {
    display: none;
}

.ai-robot-toggle:hover {
    transform: scale(1.1);
}

.ai-robot-toggle:active {
    transform: scale(0.95);
}

.ai-robot-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.ai-robot-open .ai-robot-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ai-robot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #0d6efd, #6610f2);
    color: #fff;
    flex-shrink: 0;
}

.ai-robot-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.ai-robot-header-left i {
    font-size: 22px;
}

.ai-robot-close {
    color: #fff;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
}

.ai-robot-close:hover {
    background: rgba(255, 255, 255, 0.35);
    color: #fff;
}

.ai-robot-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background: #f8f9fa;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.ai-robot-body::-webkit-scrollbar {
    width: 5px;
}

.ai-robot-body::-webkit-scrollbar-track {
    background: transparent;
}

.ai-robot-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.ai-robot-body::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

.ai-robot-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #adb5bd;
    text-align: center;
    padding: 20px;
}

.ai-robot-welcome-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.ai-robot-welcome p {
    font-size: 15px;
    margin: 0;
}

.ai-robot-message {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: flex-start;
}

.ai-robot-message-user {
    flex-direction: row-reverse;
}

.ai-robot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #6610f2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.ai-robot-avatar-user {
    background: linear-gradient(135deg, #6c757d, #495057);
}

.ai-robot-bubble {
    max-width: calc(100% - 48px);
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    overflow-wrap: break-word;
}

.ai-robot-message-assistant .ai-robot-bubble {
    background: #fff;
    border: 1px solid #e9ecef;
    border-top-left-radius: 4px;
    color: #212529;
}

.ai-robot-message-user .ai-robot-bubble {
    background: #0d6efd;
    color: #fff;
    border-top-right-radius: 4px;
}

.ai-robot-bubble p {
    margin: 0 0 8px 0;
}

.ai-robot-bubble p:last-child {
    margin-bottom: 0;
}

.ai-robot-bubble pre {
    background: #212529;
    color: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    margin: 8px 0;
}

.ai-robot-bubble code {
    font-size: 13px;
}

.ai-robot-bubble :not(pre) > code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
}

.ai-robot-message-user .ai-robot-bubble :not(pre) > code {
    background: rgba(255, 255, 255, 0.2);
}

.ai-robot-bubble ul,
.ai-robot-bubble ol {
    padding-left: 20px;
    margin: 4px 0;
}

.ai-robot-bubble table {
    font-size: 13px;
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}

.ai-robot-bubble th,
.ai-robot-bubble td {
    border: 1px solid #dee2e6;
    padding: 6px 10px;
    text-align: left;
}

.ai-robot-bubble th {
    background: #f1f3f5;
}

.ai-robot-cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    background: #0d6efd;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: ai-cursor-blink 0.8s infinite;
}

@keyframes ai-cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.ai-robot-footer {
    padding: 10px 12px;
    border-top: 1px solid #e9ecef;
    background: #fff;
    flex-shrink: 0;
}

.ai-robot-input-group {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f1f3f5;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    border: 1px solid #e9ecef;
    transition: border-color 0.2s ease;
}

.ai-robot-input-group:focus-within {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.ai-robot-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    font-size: 16px;
    line-height: 1.5;
    padding: 6px 0;
    max-height: 120px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.ai-robot-input::placeholder {
    color: #adb5bd;
}

.ai-robot-input:disabled {
    opacity: 0.6;
}

.ai-robot-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.ai-robot-send:not(:disabled):hover {
    transform: scale(1.08);
}

.ai-robot-send:not(:disabled):active {
    transform: scale(0.92);
}

.ai-robot-send:disabled {
    opacity: 0.5;
}

.ai-robot-retry {
    display: inline-block;
}

@media (max-width: 767.98px) {
    .ai-robot-wrapper {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        pointer-events: none;
    }

    .ai-robot-open {
        pointer-events: auto;
    }

    .ai-robot-toggle {
        position: fixed;
        bottom: 80px;
        right: 20px;
        width: 52px;
        height: 52px;
        font-size: 22px;
        pointer-events: auto;
        z-index: 1051;
    }

    .ai-robot-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
        transform: translateY(100%);
        transform-origin: bottom center;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    .ai-robot-open .ai-robot-panel {
        transform: translateY(0);
    }

    .ai-robot-header {
        padding: 14px 16px;
        padding-top: max(14px, calc(env(safe-area-inset-top, 0px) + 14px));
    }

    .ai-robot-body {
        padding: 12px;
    }

    .ai-robot-footer {
        padding: 10px 12px;
        padding-bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) + 10px));
    }

    .ai-robot-bubble {
        max-width: calc(100% - 44px);
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .ai-robot-panel {
        width: 360px;
        height: 480px;
    }
}

@media (min-width: 992px) {
    .ai-robot-panel {
        width: 400px;
        height: 560px;
    }
}

@supports not (height: 100dvh) {
    @media (max-width: 767.98px) {
        .ai-robot-panel {
            height: 100%;
        }
    }
}
