/* AiChat Widget Styles */
.aichat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* Trigger Button */
.aichat-trigger {
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s;
    position: relative;
    padding: 0;
}

.aichat-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.aichat-trigger:active {
    transform: scale(0.95);
}

.aichat-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
}

/* Tooltip */
.aichat-tooltip {
    position: absolute;
    right: 100%;
    margin-right: 16px;
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateX(10px);
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.aichat-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -4px;
    transform: translateY(-50%);
    border-width: 4px;
    border-style: solid;
    border-color: transparent transparent transparent #1f2937;
}

.aichat-trigger:hover .aichat-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Chat Widget Window */
.aichat-widget {
    --aichat-bg: #ffffff;
    --aichat-fg: #111827;
    --aichat-muted: #6b7280;
    --aichat-border: #e5e7eb;
    --aichat-accent: #2563eb;
    --aichat-user-bg: #2563eb;
    --aichat-user-fg: #ffffff;
    --aichat-assistant-bg: #f3f4f6;
    --aichat-assistant-fg: #1f2937;

    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--aichat-bg);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
    display: none; /* Hidden by default */
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--aichat-border);
    animation: aichat-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.aichat-widget.aichat-visible {
    display: flex;
}

@keyframes aichat-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.aichat-header {
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid var(--aichat-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.aichat-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--aichat-fg);
}

.aichat-close {
    background: transparent;
    border: none;
    color: var(--aichat-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.aichat-close:hover {
    background: var(--aichat-assistant-bg);
    color: var(--aichat-fg);
}

/* Chat Body */
.aichat-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fff;
    scroll-behavior: smooth;
}

/* Messages */
.aichat-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.aichat-message--user {
    align-self: flex-end;
    align-items: flex-end;
}

.aichat-message--assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.aichat-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.aichat-message--user .aichat-message-content {
    background: var(--aichat-user-bg);
    color: var(--aichat-user-fg);
    border-bottom-right-radius: 2px;
}

.aichat-message--assistant .aichat-message-content {
    background: var(--aichat-assistant-bg);
    color: var(--aichat-assistant-fg);
    border-bottom-left-radius: 2px;
}

/* Input Area */
.aichat-input {
    padding: 16px;
    border-top: 1px solid var(--aichat-border);
    display: flex;
    gap: 10px;
    background: white;
    flex-shrink: 0;
}

.aichat-text {
    flex: 1;
    border: 1px solid var(--aichat-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f9fafb;
}

.aichat-text:focus {
    background: white;
    border-color: var(--aichat-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.aichat-send {
    background: var(--aichat-accent);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 0 20px;
    font-weight: 500;
    cursor: pointer;
    font-size: 14px;
    transition: filter 0.2s;
}

.aichat-send:hover {
    filter: brightness(1.1);
}

.aichat-send:active {
    transform: translateY(1px);
}

/* Scrollbar Styling */
.aichat-body::-webkit-scrollbar {
    width: 6px;
}
.aichat-body::-webkit-scrollbar-track {
    background: transparent;
}
.aichat-body::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}
.aichat-body::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.2);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .aichat-widget {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        right: 16px;
        bottom: 90px;
    }

    .aichat-container {
        right: 16px;
        bottom: 16px;
    }
}
