:root {
    /* Apollon Brand Colors */
    --apln-blue: #00A7E7;
    --apln-darkblue: #00709A;
    /* Hover state for blue */
    --apln-darkgrey-60: #999999;
    --apln-darkgrey-45: #727272;
    /* Hover state for grey */

    /* Common UI Colors */
    --color-white: #ffffff;
    --color-bg-light: #f8f9fa;
    --color-border-light: #e0e0e0;
    --color-text-dark: #333333;
    --color-text-medium: #666666;
}

/* ========== AI Chat Styles ========== */
/* === AI Search styles === */
#ai-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: transparent;
    color: transparent;
    border: none;
    border-radius: 0;
    width: 56px;
    height: 57px;
    font-size: 0;
    cursor: pointer;
    box-shadow: none;
    display: block;
    transition: transform 0.2s;
    padding: 0;
    z-index: 1000;

    /* PNG Icon Background */
    background-image: url('../../icons/bot_default.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#ai-toggle:hover {
    background: transparent;
    color: transparent;
    border: none;
    transform: none;
    box-shadow: none;

    /* Hover State Icon */
    background-image: url('../../icons/bot_hover.png');
    /* Adjust size to match default icon visual scale (default has more padding) */
    background-size: 85%;
    background-position: center;
    background-repeat: no-repeat;
}

#ai-toggle.active {
    /* Active State Icon */
    background-image: url('../../icons/bot_selected.png');
    transform: none;
}

/* ========== AI Chat Window Styles ========== */
/* All rules scoped to #ai-chat to avoid conflicts with Antora */

/* Chat container */
#ai-chat .chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-white);
    height: 100%;
    min-height: 400px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#ai-chat .chat-header {
    background: var(--color-white);
    padding: 20px;
    border-bottom: 1px solid var(--color-border-light);
    text-align: center;
}

#ai-chat .chat-header h1 {
    color: var(--color-text-dark);
    font-size: 24px;
    font-weight: 600;
}

/* Messages */
#ai-chat .chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#ai-chat .message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 80%;
}

#ai-chat .message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

#ai-chat .message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}

#ai-chat .message.ai .message-avatar {
    background: var(--apln-blue);
    font-size: 18px;
}

#ai-chat .message.user .message-avatar {
    background: var(--apln-darkgrey-60);
    font-size: 14px;
}

#ai-chat .message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
}

#ai-chat .message.ai .message-content {
    background-color: #E3F2FD;
    color: #333;
    border-bottom-left-radius: 4px;
}

#ai-chat .message.user .message-content {
    background-color: #F5F5F5;
    color: #333;
    border-bottom-right-radius: 4px;
}

#ai-chat .message-content strong {
    font-weight: 600;
}

#ai-chat .message-content a {
    color: #1976D2;
    text-decoration: underline;
}

/* Structured message parts */
#ai-chat .thought-section {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin: 8px 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#ai-chat .thought-header {
    font-weight: 600;
    color: #495057;
    padding: 12px;
    font-size: 14px;
}

#ai-chat .thought-header:hover {
    background-color: #dee2e6;
}

#ai-chat .thought-content {
    padding: 12px;
    font-size: 13px;
    color: #6c757d;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
}

#ai-chat .thought-content.expanded {
    display: block;
}

#ai-chat .thought-toggle {
    transition: transform 0.2s ease;
}

#ai-chat .thought-toggle.expanded {
    transform: rotate(90deg);
}

#ai-chat .result-section {
    margin: 0;
}

#ai-chat .result-content {
    font-size: 15px;
    line-height: 1.6;
    color: #333;
    margin-left: 12px;
}

/* Ensure uniform line-height for content inside chat */
#ai-chat .content {
    line-height: 1.4 !important;
}

#ai-chat .content * {
    line-height: inherit !important;
}

/* Heading and paragraph normalization inside chat messages */
#ai-chat .message-content h1,
#ai-chat .message-content h2,
#ai-chat .message-content h3,
#ai-chat .message-content h4,
#ai-chat .message-content h5,
#ai-chat .message-content h6 {
    margin: 4px 0 !important;
    line-height: 1.3 !important;
}

#ai-chat .message-content p {
    margin: 4px 0 !important;
    line-height: 1.3 !important;
}

#ai-chat .result-content h1,
#ai-chat .result-content h2,
#ai-chat .result-content h3,
#ai-chat .result-content h4,
#ai-chat .result-content h5,
#ai-chat .result-content h6,
#ai-chat .content h1,
#ai-chat .content h2,
#ai-chat .content h3,
#ai-chat .content h4,
#ai-chat .content h5,
#ai-chat .content h6 {
    margin: 4px 0;
    font-weight: 600;
    color: #2c3e50;
}

#ai-chat .result-content h1 {
    font-size: 24px;
}

#ai-chat .result-content h2 {
    font-size: 20px;
}

#ai-chat .result-content h3 {
    font-size: 18px;
}

#ai-chat .result-content h4 {
    font-size: 16px;
}

#ai-chat .result-content p,
#ai-chat .content p {
    margin: 4px 0;
}

/* Extra whitespace specifically for result content */
#ai-chat .result-content h1,
#ai-chat .result-content h2,
#ai-chat .result-content h3,
#ai-chat .result-content h4,
#ai-chat .result-content h5,
#ai-chat .result-content h6 {
    margin: 8px 0 !important;
}

#ai-chat .result-content p {
    margin: 6px 0 !important;
}

#ai-chat .result-content ul,
#ai-chat .result-content ol,
#ai-chat .content ul,
#ai-chat .content ol {
    margin: 0;
    padding-left: 20px;
    padding-top: 0;
    padding-bottom: 0;
    line-height: 0.6 !important;
}

#ai-chat .result-content li,
#ai-chat .content li {
    margin: 0;
    padding: 0;
    line-height: normal !important;
}

#ai-chat .result-content code {
    background-color: #f1f3f4;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
}

#ai-chat .result-content pre {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

#ai-chat .result-content pre code {
    background: none;
    padding: 0;
}

#ai-chat .result-content blockquote {
    border-left: 4px solid #4A90E2;
    margin: 12px 0;
    padding: 8px 16px;
    background-color: #f8f9fa;
    color: #495057;
}

#ai-chat .result-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

#ai-chat .result-content th,
#ai-chat .result-content td {
    border: 1px solid #dee2e6;
    padding: 8px 12px;
    text-align: left;
}

#ai-chat .result-content th {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* Reference section */
#ai-chat .reference-section {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin: 12px 0;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

#ai-chat .reference-header {
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    font-size: 14px;
}

#ai-chat .reference-content {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    color: #6c757d;
    line-height: 1.4;
}

#ai-chat .reference-url {
    color: #1976D2;
    text-decoration: underline;
    cursor: pointer;
    word-break: break-all;
}

#ai-chat .reference-url:hover {
    color: #0d47a1;
}

#ai-chat .reference-metadata {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
    font-size: 12px;
    color: #868e96;
}

#ai-chat .reference-metadata strong {
    color: #495057;
}

/* Override hardcoded SVG circle fill in legacy HTML files */
#ai-chat .send-button svg circle {
    fill: none !important;
}

/* Input section */
#ai-chat .chat-input-container {
    padding: 20px;
    background: var(--color-white);
    border-top: 1px solid var(--color-border-light);
}

#ai-chat .input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

#ai-chat .input-field {
    width: 100%;
    padding: 12px 50px 12px 16px;
    border: 1px solid var(--apln-darkgrey-60);
    border-radius: 24px;
    font-size: 16px;
    outline: none;
    background-color: var(--color-bg-light);
}

#ai-chat .input-field:focus {
    border-color: var(--apln-blue);
    background-color: var(--color-white);
}

#ai-chat .input-field.has-input {
    border-color: var(--apln-blue);
}

#ai-chat .input-field::placeholder {
    color: var(--apln-darkgrey-60);
}

#ai-chat .send-button {
    position: absolute;
    right: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
    background-color: var(--apln-darkgrey-60);
    color: var(--color-white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#ai-chat .send-button:hover {
    background-color: var(--apln-darkgrey-45);
    transform: scale(1.05);
}

#ai-chat .send-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

#ai-chat .send-button.has-input {
    background-color: var(--apln-blue);
}

#ai-chat .send-button.has-input:hover {
    background-color: var(--apln-darkblue);
}

/* Input History Dropdown Styles */
#ai-chat .input-history-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background-color: #6c757d;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

#ai-chat .input-history-list {
    list-style: none;
    margin: 0;
    padding: 4px;
}

#ai-chat .input-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: white;
    font-size: 14px;
}

#ai-chat .input-history-item:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

#ai-chat .input-history-item.selected {
    background-color: rgba(255, 255, 255, 0.25);
}

#ai-chat .input-history-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
}

#ai-chat .input-history-delete {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    line-height: 1;
    width: 24px;
    height: 24px;
    padding: 0;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
    flex-shrink: 0;
}

#ai-chat .input-history-item:hover .input-history-delete {
    opacity: 1;
}

#ai-chat .input-history-delete:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Scrollbar styling for dropdown */
#ai-chat .input-history-dropdown::-webkit-scrollbar {
    width: 6px;
}

#ai-chat .input-history-dropdown::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

#ai-chat .input-history-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

#ai-chat .input-history-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

#ai-chat .empty-state {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

#ai-chat .empty-state h3 {
    margin-bottom: 8px;
    color: #333;
}

/* Utility classes */
#ai-chat .disabled {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

#ai-chat .message-content .section {
    display: flex;
    flex-direction: column;
}

#ai-chat .message-content .content {
    display: flex;
    flex-direction: column;
}

#ai-chat .message-content .marked-item {
    display: flex;
    flex-direction: column;
}

/* Scrollbar styling */
#ai-chat .chat-messages::-webkit-scrollbar {
    width: 6px;
}

#ai-chat .chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#ai-chat .chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#ai-chat .chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Stopped indicator */
#ai-chat .stopped-indicator {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
    font-size: 13px;
    color: #868e96;
    font-style: italic;
}

/* Temporary message notifications (these are appended to body, not #ai-chat) */
.temp-message {
    position: fixed;
    top: 20px;
    right: 20px;
    border-radius: 4px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 300px;
    word-wrap: break-word;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.temp-message.show {
    opacity: 1;
    transform: translateX(0);
}

.temp-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.temp-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.temp-message-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Responsive design */
@media (max-width: 768px) {
    #ai-chat .chat-container {
        height: 100vh;
    }

    #ai-chat .message {
        max-width: 90%;
    }
}