/* CCI Website Chatbot - Clean Redesign */

/* --- Main Container --- */
.chat-container {
    position: fixed;
    bottom: 80px;
    left: 24px;
    width: 420px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transition: opacity 0.25s ease, transform 0.25s ease;
    transform-origin: bottom left;
}

.chat-container.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

/* --- Header --- */
#chat-header {
    padding: 14px 20px;
    background: #ffffff;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

#chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
}

.close-chat {
    background: none;
    border: none;
    color: #666;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background-color 0.2s ease;
    border-radius: 50%;
}

.close-chat:hover {
    color: #e30613;
    background-color: rgba(227, 6, 19, 0.08);
}

/* --- Messages Area --- */
.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.message {
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 88%;
    word-wrap: break-word;
    font-size: 14px !important;
    line-height: 1.5;
}

.user-message {
    background: #e30613;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.bot-message {
    background: #ffffff;
    color: #1a1a1a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.loading-message {
    background: #ffffff;
    color: #999;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    font-style: italic;
}

/* Quellen-Container */
.sources-container {
    background: #f0f4f8;
    border-left: 3px solid #e30613;
    padding: 10px 14px;
    border-radius: 0 12px 12px 0;
    margin-top: 4px;
    max-width: 88%;
    align-self: flex-start;
}

.sources-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.source-link {
    display: block;
    padding: 4px 0;
    color: #1a5490;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.4;
    border-bottom: 1px solid #e0e6ed;
    transition: color 0.2s ease;
}

.source-link:last-child {
    border-bottom: none;
}

.source-link:hover {
    color: #e30613;
    text-decoration: underline;
}

.source-id {
    color: #999;
    font-size: 11px;
    margin-left: 4px;
}

/* --- Markdown-Styling für Bot-Nachrichten --- */
.bot-message strong,
.sources-container strong {
    font-weight: 600 !important;
}

.bot-message em,
.sources-container em {
    font-style: italic;
}

.bot-message a {
    color: #1a5490;
    text-decoration: none;
}

.bot-message a:hover {
    text-decoration: underline;
    color: #e30613;
}

.bot-message ul,
.bot-message ol {
    margin: 6px 0;
    padding-left: 18px;
}

.bot-message li {
    margin-bottom: 2px;
}

.bot-message br {
    display: block;
    content: "";
    margin: 4px 0;
}

.bot-message p {
    margin: 0 0 6px 0;
}

.bot-message p:last-child {
    margin-bottom: 0;
}

/* --- Input Area --- */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #eaeaea;
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #ffffff;
    flex-shrink: 0;
}

.chat-input {
    flex-grow: 1;
    padding: 10px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 20px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    background: #f8f9fa;
}

.chat-input:focus {
    border-color: #e30613;
    box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.1);
    background: #ffffff;
}

.chat-input:disabled {
    background-color: #f1f1f1;
    cursor: not-allowed;
}

.send-message {
    width: 38px;
    height: 38px;
    background: #e30613;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.send-message:hover {
    background: #b80510;
}

.send-message:active {
    transform: scale(0.95);
}

.send-message:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.send-message svg {
    width: 18px;
    height: 18px;
}

/* --- Toggle Button --- */
.chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #e30613;
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(227, 6, 19, 0.3);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-toggle:hover {
    background: #b80510;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(227, 6, 19, 0.4);
}

.chat-widget {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9998;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* --- Responsive Design --- */
@media (max-width: 480px) {
    .chat-container {
        max-width: 100vw;
        width: 100vw;
        height: 100vh;
        bottom: 0;
        left: 0;
        border-radius: 0;
    }
    
    .chat-toggle {
        bottom: 16px;
        left: 16px;
    }
}
