/*
 * Der Immobilien Chatbot – Frontend-CSS
 * Responsive, barrierefrei, kein Framework-Overhead
 * Designvariable: --imc-color-primary (via PHP gesetzt)
 */

:root {
    --imc-color-primary:   #1a3c6e;
    --imc-color-light:     #e8f0fb;
    --imc-color-bot-bg:    #f3f4f6;
    --imc-color-user-bg:   var(--imc-color-primary);
    --imc-color-user-text: #ffffff;
    --imc-color-bot-text:  #1a1a1a;
    --imc-color-border:    #d1d5db;
    --imc-color-error:     #dc2626;
    --imc-radius:          12px;
    --imc-shadow:          0 4px 24px rgba(0,0,0,.18);
    --imc-font:            -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --imc-z:               99999;
    --imc-widget-w:        360px;
    --imc-widget-h:        520px;
}

/* ── Wrapper ───────────────────────────────────────────────────────────────── */
.imc-chatbot-wrapper {
    position: fixed;
    z-index: var(--imc-z);
    font-family: var(--imc-font);
    font-size: 14px;
    line-height: 1.5;
}
.imc-position-bottom-right { bottom: 24px; right: 24px; }
.imc-position-bottom-left  { bottom: 24px; left:  24px; }

/* ── Toggle-Button ─────────────────────────────────────────────────────────── */
.imc-chatbot-toggle {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--imc-color-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--imc-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
}
.imc-chatbot-toggle:hover  { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,.24); }
.imc-chatbot-toggle:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.imc-badge {
    position: absolute;
    top: 2px; right: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Chat-Box ──────────────────────────────────────────────────────────────── */
.imc-chatbot-box {
    position: absolute;
    bottom: 68px;
    width: var(--imc-widget-w);
    max-width: calc(100vw - 32px);
    height: var(--imc-widget-h);
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: var(--imc-radius);
    box-shadow: var(--imc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--imc-color-border);
    animation: imc-slide-up .22s ease;
}
.imc-position-bottom-right .imc-chatbot-box { right: 0; }
.imc-position-bottom-left  .imc-chatbot-box { left:  0; }

@keyframes imc-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0);     }
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.imc-chatbot-header {
    background: var(--imc-color-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.imc-chatbot-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.imc-chatbot-title {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.imc-chatbot-btn-icon {
    background: none; border: none; color: rgba(255,255,255,.8);
    cursor: pointer; padding: 4px; border-radius: 4px; line-height: 1;
    display: flex; align-items: center;
}
.imc-chatbot-btn-icon:hover { color: #fff; background: rgba(255,255,255,.15); }
.imc-chatbot-btn-icon:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ── GDPR-Overlay ──────────────────────────────────────────────────────────── */
.imc-gdpr-overlay {
    padding: 20px;
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.imc-gdpr-text { font-size: 13px; color: #374151; line-height: 1.6; margin: 0; }
.imc-gdpr-text a { color: var(--imc-color-primary); }

/* ── Nachrichtenbereich ────────────────────────────────────────────────────── */
.imc-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.imc-chatbot-messages::-webkit-scrollbar { width: 4px; }
.imc-chatbot-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* ── Nachrichten-Bubbles ───────────────────────────────────────────────────── */
.imc-msg { display: flex; }
.imc-msg--user { justify-content: flex-end; }
.imc-msg--bot  { justify-content: flex-start; }

.imc-msg__bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    word-break: break-word;
    font-size: 13.5px;
    line-height: 1.55;
}
.imc-msg--user .imc-msg__bubble {
    background: var(--imc-color-user-bg);
    color: var(--imc-color-user-text);
    border-bottom-right-radius: 4px;
}
.imc-msg--bot  .imc-msg__bubble {
    background: var(--imc-color-bot-bg);
    color: var(--imc-color-bot-text);
    border-bottom-left-radius: 4px;
}
.imc-msg--error .imc-msg__bubble {
    background: #fef2f2;
    color: var(--imc-color-error);
    border: 1px solid #fecaca;
}

.imc-msg__bubble a { color: var(--imc-color-primary); text-decoration: underline; }
.imc-msg__bubble ul { margin: 8px 0 0 16px; }
.imc-msg__bubble li { margin-bottom: 4px; }

/* ── Link-Buttons ──────────────────────────────────────────────────────────── */
.imc-msg--links {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    padding-left: 0;
}
.imc-link-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--imc-color-primary);
    color: var(--imc-color-primary);
    font-size: 12.5px;
    text-decoration: none;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.imc-link-btn:hover { background: var(--imc-color-primary); color: #fff; }

/* ── Tipp-Indikator ────────────────────────────────────────────────────────── */
.imc-typing {
    padding: 10px 14px;
    max-width: 70px;
}
.imc-typing span {
    display: inline-block;
    width: 8px; height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    margin: 0 2px;
    animation: imc-bounce .9s infinite ease-in-out;
}
.imc-typing span:nth-child(2) { animation-delay: .15s; }
.imc-typing span:nth-child(3) { animation-delay: .30s; }

@keyframes imc-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: .5; }
    40%            { transform: scale(1);   opacity: 1;  }
}

/* ── Eingabebereich ────────────────────────────────────────────────────────── */
.imc-chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--imc-color-border);
    background: #fafafa;
    flex-shrink: 0;
}
.imc-chat-input {
    flex: 1;
    border: 1.5px solid var(--imc-color-border);
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    background: #fff;
    transition: border-color .15s;
}
.imc-chat-input:focus { border-color: var(--imc-color-primary); }

.imc-btn-send {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--imc-color-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s, transform .15s;
}
.imc-btn-send:disabled { opacity: .4; cursor: default; }
.imc-btn-send:not(:disabled):hover { transform: scale(1.08); }
.imc-btn-send:focus-visible { outline: 2px solid var(--imc-color-primary); outline-offset: 2px; }

.imc-btn-primary {
    padding: 10px 24px;
    background: var(--imc-color-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: opacity .15s;
}
.imc-btn-primary:hover { opacity: .88; }
.imc-btn-primary:focus-visible { outline: 3px solid var(--imc-color-primary); outline-offset: 2px; }

/* ── Footer-Hinweis ────────────────────────────────────────────────────────── */
.imc-chatbot-footer {
    padding: 6px 14px 8px;
    text-align: center;
    background: #fafafa;
    border-top: 1px solid var(--imc-color-border);
    flex-shrink: 0;
}
.imc-chatbot-footer small { color: #9ca3af; font-size: 11px; }

/* ── Screenreader-only ─────────────────────────────────────────────────────── */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); border: 0;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    :root {
        --imc-widget-w: calc(100vw - 24px);
        --imc-widget-h: 70vh;
    }
    .imc-position-bottom-right .imc-chatbot-box,
    .imc-position-bottom-left  .imc-chatbot-box {
        right: 0; left: 0;
        margin: 0 12px;
    }
    .imc-chatbot-toggle { width: 50px; height: 50px; }
}

/* ── Dark-Mode (automatisch) ───────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .imc-chatbot-box     { background: #1e1e2e; border-color: #2d2d3d; }
    .imc-msg--bot .imc-msg__bubble { background: #2d2d3d; color: #e2e2f0; }
    .imc-chat-input      { background: #2d2d3d; border-color: #3d3d4d; color: #e2e2f0; }
    .imc-chatbot-input-area, .imc-chatbot-footer { background: #1a1a2a; border-color: #2d2d3d; }
    .imc-gdpr-overlay    { background: rgba(30,30,46,.97); }
    .imc-gdpr-text       { color: #c8c8e0; }
}
