/* ============================================
   AI CHAT STYLES (für Sidebar)
   Dashboard-Design - Clean & Professional
   ============================================ */

/* ============================================
   BUILDING INFO HEADER - Persistent Widget
   ============================================ */
#ai-sidebar-content .ai-building-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;                     /* Von 12px → 10px */
    padding: 10px 12px;            /* Von 12px 16px → 10px 12px (konsistent mit Messages) */
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

#ai-sidebar-content .ai-building-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

#ai-sidebar-content .ai-building-header .ai-building-icon {
    font-size: 24px;
    line-height: 1;
}

#ai-sidebar-content .ai-building-header .ai-building-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

#ai-sidebar-content .ai-building-header .ai-building-address {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#ai-sidebar-content .ai-building-header .ai-building-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

#ai-sidebar-content .ai-building-header .ai-meta-badge {
    font-size: 11px;
    color: #666;
    background: white;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #d0d0d0;
    white-space: nowrap;
}

/* Zurück-Button */
.ai-building-header-back {
    padding: 6px 12px;
    background: white;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-building-header-back:hover {
    background: #f5f5f5;
    border-color: #999;
    color: #333;
}

.ai-building-header-back:active {
    transform: scale(0.95);
}

/* Chat Container */
#ai-sidebar-content .ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    background: #ffffff;
    min-height: 200px;
}

/* Individual Messages - Maximale Platznutzung */
#ai-sidebar-content .ai-message {
    display: flex;
    gap: 4px;                      /* Von 6px → 4px (ultra kompakt) */
    padding: 6px 8px;              /* Von 8px 8px → 6px 8px (noch kompakter!) */
    margin: 0;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Alternating Background */
#ai-sidebar-content .ai-message:nth-child(even) {
    background: #f8f9fa;
}

/* Avatar - Ultra-kompakt für maximalen Content-Platz */
#ai-sidebar-content .ai-avatar {
    width: 20px;                   /* Von 24px → 20px (minimal aber erkennbar) */
    height: 20px;
    border-radius: 5px;            /* Von 6px → 5px (proportional) */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;               /* Von 13px → 11px (proportional) */
    flex-shrink: 0;
}

#ai-sidebar-content .ai-message.user .ai-avatar {
    background: #0077b6;
    color: white;
}

#ai-sidebar-content .ai-message.assistant .ai-avatar {
    background: #e8f4f8;
    color: #0077b6;
}

/* Message Bubble - Optimiert */
#ai-sidebar-content .ai-bubble {
    flex: 1;
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-width: 0; /* Wichtig für text-overflow */
    max-width: 95%; /* Nutze fast die gesamte Breite */
}

#ai-sidebar-content .ai-message.user .ai-bubble {
    color: #333;
    font-weight: 500;
}

/* Markdown Elements - Kompakter */
#ai-sidebar-content .ai-bubble h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 6px 0 10px 0;
    color: #0077b6;
    line-height: 1.3;
}

#ai-sidebar-content .ai-bubble h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 6px 0 6px 0;
    color: #0077b6;
    line-height: 1.3;
}

#ai-sidebar-content .ai-bubble h4 {
    font-size: 13px;
    font-weight: 600;
    margin: 4px 0 4px 0;
    color: #333;
    line-height: 1.3;
}

#ai-sidebar-content .ai-bubble strong {
    font-weight: 600;
    color: #0077b6;
}

#ai-sidebar-content .ai-bubble em {
    font-style: italic;
    color: #666;
}

#ai-sidebar-content .ai-bubble a {
    color: #0077b6;
    text-decoration: none;
    border-bottom: 1px solid #0077b6;
}

#ai-sidebar-content .ai-bubble a:hover {
    background: #e8f4f8;
}

#ai-sidebar-content .ai-bubble br {
    display: block;
    content: "";
    margin: 4px 0;
}

/* Listen (Bullet & Nummeriert) */
#ai-sidebar-content .ai-bubble ul,
#ai-sidebar-content .ai-bubble ol {
    margin: 8px 0;
    padding-left: 24px;
}

#ai-sidebar-content .ai-bubble ul {
    list-style-type: disc;
}

#ai-sidebar-content .ai-bubble ol {
    list-style-type: decimal;
}

#ai-sidebar-content .ai-bubble li {
    margin: 4px 0;
    line-height: 1.5;
}

/* Code-Blocks & Inline Code */
#ai-sidebar-content .ai-bubble code {
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 12px;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    color: #d63384;
}

#ai-sidebar-content .ai-bubble pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 12px;
    line-height: 1.5;
}

#ai-sidebar-content .ai-bubble pre code {
    background: transparent;
    padding: 0;
    color: #f8f8f2;
    border-radius: 0;
}

#ai-sidebar-content .ai-bubble pre::-webkit-scrollbar {
    height: 6px;
}

#ai-sidebar-content .ai-bubble pre::-webkit-scrollbar-track {
    background: #1e1e1e;
}

#ai-sidebar-content .ai-bubble pre::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

/* Blockquotes */
#ai-sidebar-content .ai-bubble blockquote {
    margin: 8px 0;
    padding: 8px 12px;
    border-left: 4px solid #0077b6;
    background: #f0f7ff;
    font-style: italic;
    color: #555;
}

/* Interactive Button Groups */
#ai-sidebar-content .ai-button-group {
    margin: 10px 0;                /* Von 16px → 10px (kompakter) */
    padding: 12px;                 /* Von 16px → 12px (kompakter) */
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

#ai-sidebar-content .ai-button-group-question {
    font-weight: 600;
    color: #0077b6;
    margin-bottom: 8px;            /* Von 12px → 8px (kompakter) */
    font-size: 14px;
}

#ai-sidebar-content .ai-button-group-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;                      /* Von 8px → 6px (kompakter) */
}

#ai-sidebar-content .ai-interactive-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;                      /* Von 6px → 4px (kompakter) */
    padding: 12px 10px;            /* Von 16px 12px → 12px 10px (kompakter) */
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    color: #333;
    min-height: 70px;              /* Von 80px → 70px (kompakter) */
}

#ai-sidebar-content .ai-interactive-btn:hover:not(:disabled) {
    border-color: #0077b6;
    background: #e8f4f8;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 119, 182, 0.15);
}

#ai-sidebar-content .ai-interactive-btn.selected {
    border-color: #0077b6;
    background: #0077b6;
    color: white;
}

#ai-sidebar-content .ai-interactive-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#ai-sidebar-content .ai-btn-emoji {
    font-size: 28px;
    line-height: 1;
}

#ai-sidebar-content .ai-btn-label {
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
}

/* Input Area */
#ai-sidebar-content .ai-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

#ai-sidebar-content .ai-input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d0d0d0;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: white;
}

/* Textarea statt Input */
#ai-sidebar-content .ai-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: white;
    resize: none;
    min-height: 42px;
    max-height: 60px; /* 3 Zeilen */
    line-height: 20px;
    overflow-y: hidden;
}

#ai-sidebar-content .ai-input-area textarea:focus {
    border-color: #0077b6;
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.1);
}

#ai-sidebar-content .ai-send-btn {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, #007AFF 0%, #5E5CE6 100%);
    border: 0.5px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow:
        0 8px 24px -8px rgba(0, 122, 255, 0.42),
        0 3px 12px -3px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
    position: relative;
}

#ai-sidebar-content .ai-send-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 0.5px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.08));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

#ai-sidebar-content .ai-send-btn:hover {
    transform: scale(1.12) translateY(-1px);
    box-shadow:
        0 12px 32px -8px rgba(0, 122, 255, 0.5),
        0 4px 16px -4px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

#ai-sidebar-content .ai-send-btn:active {
    transform: scale(1.05);
}

#ai-sidebar-content .ai-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

/* Typing Indicator */
#ai-sidebar-content .ai-typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

#ai-sidebar-content .ai-typing-dot {
    width: 8px;
    height: 8px;
    background: #0077b6;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

#ai-sidebar-content .ai-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

#ai-sidebar-content .ai-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile Adjustments */
@media (max-width: 480px) {
    #ai-sidebar-content .ai-button-group-options {
        grid-template-columns: 1fr;
    }

    #ai-sidebar-content .ai-message {
        padding: 8px 8px;          /* Konsistent mit Desktop */
        gap: 6px;
    }

    #ai-sidebar-content .ai-avatar {
        width: 18px;               /* Auf Mobile noch kleiner (aber erkennbar) */
        height: 18px;
        font-size: 10px;
    }
}

/* Scrollbar Styling */
#ai-sidebar-content .ai-messages::-webkit-scrollbar {
    width: 6px;
}

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

#ai-sidebar-content .ai-messages::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 3px;
}

#ai-sidebar-content .ai-messages::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* ============================================
   SUGGESTED FOLLOW-UPS (Pill-Buttons)
   ============================================ */
#ai-sidebar-content .ai-followup-container {
    margin-top: 8px;               /* Von 6px → 8px (etwas Abstand zur Message) */
    padding-top: 4px;              /* Von 6px → 4px (minimaler padding) */
    border-top: 1px solid #e0e0e0;
}

#ai-sidebar-content .ai-followup-label {
    font-size: 11px;
    color: #86868b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

#ai-sidebar-content .ai-followup-pills {
    display: grid;                 /* Von flex → grid für volle Breite */
    grid-template-columns: 1fr;    /* Eine Spalte = jeder Pill nimmt volle Breite */
    gap: 3px;                      /* Von 4px → 3px (ultra kompakt!) */
}

/* Follow-Ups innerhalb von Bubbles: Kein line-height Inheritance */
#ai-sidebar-content .ai-bubble .ai-followup-container {
    margin-top: 8px;
    margin-bottom: 0;
    line-height: 1;                /* Override bubble line-height von 1.5 */
}

#ai-sidebar-content .ai-bubble .ai-followup-pills {
    line-height: 1;                /* Kein extra spacing durch line-height */
}

#ai-sidebar-content .ai-followup-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border: 0.5px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    font-size: 13px;
    color: #1d1d1f;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    line-height: 1.4;
    font-weight: 500;
    letter-spacing: -0.008em;
    animation: fadeInSpring 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: 100%;
    min-height: auto;
    box-shadow:
        0 2px 8px -2px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    position: relative;
}

@keyframes fadeInSpring {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    60% {
        opacity: 1;
        transform: translateY(-2px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#ai-sidebar-content .ai-followup-pill:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.98);
    color: #007AFF;
    border-color: rgba(0, 122, 255, 0.2);
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 6px 20px -6px rgba(0, 122, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

#ai-sidebar-content .ai-followup-pill.selected {
    background: linear-gradient(135deg, #007AFF 0%, #5E5CE6 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow:
        0 8px 24px -8px rgba(0, 122, 255, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

#ai-sidebar-content .ai-followup-pill.used {
    opacity: 0.4;
    cursor: not-allowed;
}

#ai-sidebar-content .ai-followup-pill:disabled {
    cursor: not-allowed;
}

#ai-sidebar-content .ai-pill-emoji {
    font-size: 13px;               /* Von 14px → 13px (kleiner, proportional) */
    line-height: 1;
    flex-shrink: 0;                /* Emoji darf nicht schrumpfen */
    align-self: flex-start;        /* NEU: Emoji oben ausrichten bei mehrzeiligem Text */
    padding-top: 1px;              /* Von 2px → 1px (weniger Offset) */
}

#ai-sidebar-content .ai-pill-text {
    white-space: normal;           /* Erlaubt Umbruch bei langen Texten */
    word-wrap: break-word;          /* Bricht lange Wörter um */
    overflow-wrap: break-word;      /* Moderne Alternative für word-wrap */
    line-height: 1.3;               /* Von 1.4 → 1.3 (kompakter bei Umbruch) */
    flex: 1;                        /* Nimmt verfügbaren Platz ein */
    min-width: 0;                   /* Ermöglicht Flex-Shrinking */
}

/* Mobile Responsive: Engere Pills auf kleinen Screens */
@media (max-width: 420px) {
    #ai-sidebar-content .ai-followup-pill {
        max-width: calc(100vw - 80px); /* Verhindert Overflow auf Mobile */
    }
}

/* ============================================
   RETRY BUTTON (Error Handling)
   ============================================ */
#ai-sidebar-content .ai-retry-container {
    margin-top: 12px;
    text-align: center;
}

#ai-sidebar-content .ai-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

#ai-sidebar-content .ai-retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
    background: linear-gradient(135deg, #ee5a52 0%, #ff6b6b 100%);
}

#ai-sidebar-content .ai-retry-btn:active {
    transform: translateY(0);
}

/* ============================================
   SCROLL DOWN BUTTON (Smooth-Scroll)
   ============================================ */
.ai-scroll-down-btn {
    position: absolute;
    bottom: 80px; /* Über Input Area */
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 119, 182, 0.9);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    z-index: 10;
}

.ai-scroll-down-btn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.ai-scroll-down-btn:hover {
    background: rgba(0, 119, 182, 1);
    transform: scale(1.1);
}

.ai-scroll-down-btn:active {
    transform: scale(0.95);
}
