/* AI Summary Box */
.ai-summary-box {
    background: linear-gradient(135deg, #f6f8fd 0%, #f1f4f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.ai-summary-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: #3b82f6;
}

.ai-summary-header {
    font-size: 1.1em;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-summary-content {
    font-size: 0.95em;
    line-height: 1.6;
    color: #475569;
}

/* AI Assistant Widget */
#ai-assistant-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

#ai-assistant-widget.docked {
    transform: translateX(50%);
    opacity: 0.5;
}

#ai-assistant-widget.docked:hover {
    transform: translateX(0);
    opacity: 1;
}

#ai-assistant-icon {
    width: 42px;
    height: 42px;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#ai-assistant-icon:hover {
    transform: scale(1.1);
}

#ai-assistant-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 100%;
    display: block;
}

#ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #f0f0f0;
}

@media screen and (max-width: 768px) {
    #ai-chat-window {
        position: fixed !important;
        width: calc(100vw - 70px) !important;
        max-width: 300px !important;
        right: 10px !important;
        left: auto !important;
        bottom: 60px !important;
    }

    #ai-assistant-widget {
        right: 10px !important;
        bottom: 10px !important;
    }

    #ai-assistant-icon {
        width: 50px !important;
        height: 50px !important;
    }

    .ai-summary-trigger,
    .ai-summary-popup {
        display: none !important;
    }
}

.ai-chat-header {
    background: linear-gradient(to right, #4f46e5, #3b82f6);
    color: white;
    padding: 15px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-chat {
    cursor: pointer;
    font-size: 20px;
    opacity: 0.8;
}

.close-chat:hover {
    opacity: 1;
}

.ai-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.ai-message.bot {
    background: white;
    color: #334155;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-message.user {
    background: #3b82f6;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.ai-chat-input {
    padding: 12px;
    background: white;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
}

#ai-user-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 16px;
    outline: none;
    font-size: 14px;
}

#ai-user-input:focus {
    border-color: #3b82f6;
}

#ai-send-btn {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

#ai-send-btn:hover {
    background: #2563eb;
}

.ai-chat-options {
    padding: 8px 15px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    font-size: 12px;
    display: flex;
    gap: 15px;
    color: #64748b;
}

.ai-chat-options label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* Loading */
.ai-loading {
    color: #64748b;
    font-style: italic;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.ai-loading::after {
    content: '...';
    animation: blink 1.5s infinite;
}

.ai-summary-content.streaming {
    min-height: 40px;
}

/* Markdown for bot */
.ai-message.bot h1,
.ai-message.bot h2,
.ai-message.bot h3,
.ai-message.bot h4,
.ai-message.bot h5,
.ai-message.bot h6 {
    margin: 0.5em 0 0.3em 0;
    font-weight: 600;
    line-height: 1.3;
}

.ai-message.bot h1 {
    font-size: 1.4em;
}

.ai-message.bot h2 {
    font-size: 1.2em;
}

.ai-message.bot h3 {
    font-size: 1.1em;
}

.ai-message.bot p {
    margin: 0.5em 0;
}

.ai-message.bot ul,
.ai-message.bot ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.ai-message.bot li {
    margin: 0.2em 0;
}

.ai-message.bot code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.ai-message.bot pre {
    background: #f5f5f5;
    padding: 0.8em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.ai-message.bot pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
}

.ai-message.bot blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 0.8em;
    margin: 0.5em 0;
    color: #64748b;
    font-style: italic;
}

.ai-message.bot a {
    color: #3b82f6;
    text-decoration: none;
}

.ai-message.bot a:hover {
    text-decoration: underline;
}

.ai-message.bot strong {
    font-weight: 600;
}

.ai-message.bot em {
    font-style: italic;
}

.ai-message.bot hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 0.8em 0;
}

.ai-message.bot table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
}

.ai-message.bot th,
.ai-message.bot td {
    border: 1px solid #e2e8f0;
    padding: 0.4em 0.6em;
    text-align: left;
}

.ai-message.bot th {
    background: #f8fafc;
    font-weight: 600;
}

/* Abort button */
.ai-abort-btn {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 8px;
    margin-left: 10px;
}

.ai-abort-btn:hover {
    background: #dc2626;
}