/* KRYA Assistent: Knopf, Fenster, Chat, Live-Gespräch */

.krya-ai-btn {
    position: fixed;
    right: 35px;
    bottom: 100px;
    z-index: 999999;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--krya-ai-akzent-hell, #3B82F6), var(--krya-ai-akzent, #2563EB));
    color: #FFFFFF;
    box-shadow: 0 10px 24px -8px var(--krya-ai-schatten, rgba(37, 99, 235, 0.65));
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.krya-ai-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 28px -8px var(--krya-ai-schatten-hover, rgba(37, 99, 235, 0.7)); }
.krya-ai-btn:focus-visible { outline: 3px solid var(--krya-ai-fokus, #93C5FD); outline-offset: 3px; }
.krya-ai-btn svg { width: 26px; height: 26px; }
.krya-ai-btn[hidden] { display: none; }

.krya-ai-panel {
    position: fixed;
    right: 30px;
    bottom: 100px;
    z-index: 1000000;
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 32px));
    height: min(620px, calc(100vh - 140px));
    overflow: hidden;
    border: 1px solid var(--krya-ai-linie, #E5E7EB);
    border-radius: 18px;
    background: #FFFFFF;
    box-shadow: 0 24px 60px -20px var(--krya-ai-panel-schatten, rgba(15, 23, 42, 0.45));
    font-family: var(--krya-ai-schrift, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    color: var(--krya-ai-text, #1F2937);
}

.krya-ai-panel[hidden] { display: none; }

.krya-ai-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--krya-ai-akzent-hell, #3B82F6), var(--krya-ai-akzent, #2563EB));
    color: #FFFFFF;
}

.krya-ai-head strong { font-size: 1rem; font-weight: 700; }
.krya-ai-head .krya-ai-tag {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.krya-ai-head .krya-ai-close {
    margin-left: auto;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: #FFFFFF;
    cursor: pointer;
}
.krya-ai-head .krya-ai-close:hover { background: rgba(255, 255, 255, 0.3); }
.krya-ai-head .krya-ai-close svg { width: 16px; height: 16px; }

.krya-ai-note {
    padding: 8px 16px;
    background: var(--krya-ai-tint, #EFF6FF);
    color: var(--krya-ai-hinweis-text, #1E40AF);
    font-size: 0.78rem;
    line-height: 1.4;
}

.krya-ai-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--krya-ai-flaeche, #F9FAFB);
}

.krya-ai-msg {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.krya-ai-msg--bot { align-self: flex-start; background: #FFFFFF; border: 1px solid var(--krya-ai-linie, #E5E7EB); }
.krya-ai-msg--me { align-self: flex-end; background: var(--krya-ai-akzent, #2563EB); color: #FFFFFF; }
.krya-ai-msg--sys { align-self: center; max-width: 100%; background: #FEF2F2; border: 1px solid #FCA5A5; color: #7F1D1D; font-size: 0.85rem; }
.krya-ai-msg__wa { display: inline-block; margin-top: 8px; padding: 7px 12px; border-radius: 999px; background: #25D366; color: #06321A; font-weight: 600; text-decoration: none; }
.krya-ai-msg__wa:hover { background: #1EB955; color: #06321A; }

.krya-ai-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; }
.krya-ai-typing span { width: 7px; height: 7px; border-radius: 999px; background: #9CA3AF; animation: krya-ai-bounce 1.2s infinite ease-in-out; }
.krya-ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.krya-ai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes krya-ai-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.6; } 30% { transform: translateY(-4px); opacity: 1; } }

.krya-ai-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--krya-ai-linie, #E5E7EB); }

/* Textfeld mit Mikrofon und Lautsprecher im selben Rahmen */
.krya-ai-inputwrap {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 4px 6px 4px 4px;
    border: 1px solid var(--krya-ai-rahmen, #D1D5DB);
    border-radius: 14px;
    background: #FFFFFF;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.krya-ai-inputwrap:focus-within { border-color: var(--krya-ai-akzent-hell, #3B82F6); box-shadow: 0 0 0 3px var(--krya-ai-ring, rgba(59, 130, 246, 0.15)); }

.krya-ai-inputwrap textarea {
    flex: 1;
    min-height: 36px;
    max-height: 120px;
    padding: 8px 6px 8px 10px;
    border: none;
    background: none;
    font: inherit;
    font-size: 0.92rem;
    line-height: 1.4;
    resize: none;
}

.krya-ai-inputwrap textarea:focus { outline: none; }

.krya-ai-inline {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: none;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--krya-ai-gedaempft, #6B7280);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.krya-ai-inline:hover { background: var(--krya-ai-hover-flaeche, #F3F4F6); color: var(--krya-ai-akzent, #2563EB); }
.krya-ai-inline:focus-visible { outline: 3px solid var(--krya-ai-fokus, #93C5FD); outline-offset: 2px; }
.krya-ai-inline svg { width: 19px; height: 19px; }
.krya-ai-inline[aria-pressed="true"] { background: var(--krya-ai-tint, #EFF6FF); color: var(--krya-ai-akzent-dunkel, #1D4ED8); }
.krya-ai-inline[disabled] { opacity: 0.5; cursor: not-allowed; }

.krya-ai-send {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex: none;
    padding: 0;
    border: none;
    border-radius: 14px;
    background: var(--krya-ai-akzent, #2563EB);
    color: #FFFFFF;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.krya-ai-send:hover { background: var(--krya-ai-akzent-dunkel, #1D4ED8); }
.krya-ai-send:focus-visible { outline: 3px solid var(--krya-ai-fokus, #93C5FD); outline-offset: 2px; }
.krya-ai-send svg { width: 20px; height: 20px; }
.krya-ai-send[disabled] { opacity: 0.6; cursor: not-allowed; }

.krya-ai-foot { display: flex; align-items: center; gap: 10px; padding: 0 14px 10px; }
.krya-ai-foot__hint { color: var(--krya-ai-gedaempft, #6B7280); font-size: 0.74rem; line-height: 1.35; }
.krya-ai-live-btn {
    display: inline-flex;
    align-items: center;
    flex: none;
    white-space: nowrap;
    gap: 7px;
    padding: 9px 14px;
    border: 1px solid var(--krya-ai-rahmen, #D1D5DB);
    border-radius: 999px;
    background: #FFFFFF;
    color: var(--krya-ai-text, #1F2937);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.krya-ai-live-btn:hover { border-color: var(--krya-ai-akzent-hell, #3B82F6); color: var(--krya-ai-akzent, #2563EB); }
.krya-ai-live-btn svg { width: 16px; height: 16px; }
.krya-ai-small { margin: 0 14px 12px; color: var(--krya-ai-gedaempft, #6B7280); font-size: 0.72rem; line-height: 1.45; }

/* Live-Gespräch */
.krya-ai-live { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--krya-ai-linie, #E5E7EB); background: var(--krya-ai-flaeche-2, #F8FAFC); }
.krya-ai-live[hidden] { display: none; }
.krya-ai-live__row { display: flex; align-items: center; gap: 10px; }
.krya-ai-live__dot { width: 10px; height: 10px; border-radius: 999px; background: #10B981; animation: krya-ai-pulse 1.4s infinite; }
@keyframes krya-ai-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.krya-ai-live__status { font-size: 0.88rem; font-weight: 600; }
.krya-ai-live__timer { margin-left: auto; color: var(--krya-ai-gedaempft, #6B7280); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.krya-ai-live__text { max-height: 90px; overflow-y: auto; color: var(--krya-ai-text-2, #4B5563); font-size: 0.85rem; line-height: 1.45; }
.krya-ai-live__end {
    padding: 9px 14px;
    border: none;
    border-radius: 999px;
    background: #DC2626;
    color: #FFFFFF;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.krya-ai-live__end:hover { background: #B91C1C; }

@media (max-width: 640px) {
    .krya-ai-panel { right: 12px; left: 12px; bottom: 90px; width: auto; height: min(78vh, 560px); }
    .krya-ai-btn { right: 20px; bottom: 92px; }
}

@media (prefers-reduced-motion: reduce) {
    .krya-ai-btn, .krya-ai-typing span, .krya-ai-live__dot { transition: none; animation: none; }
}

/* Links in Antworten (assistant.js, fillText). Seiten von krya.ch als Knopf mit Titel. */
.krya-ai-msg a.krya-ai-link { color: var(--krya-ai-akzent-dunkel, #1D4ED8); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.krya-ai-msg a.krya-ai-link--seite {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 3px 0;
    padding: 4px 11px;
    border-radius: 999px;
    background: var(--krya-ai-tint, #EFF6FF);
    color: var(--krya-ai-akzent-dunkel, #1D4ED8);
    font-weight: 600;
    text-decoration: none;
    line-height: 1.3;
    white-space: normal;
}
.krya-ai-msg a.krya-ai-link--seite:hover { background: var(--krya-ai-akzent, #2563EB); color: #FFFFFF; }
.krya-ai-msg a.krya-ai-link:focus-visible { outline: 3px solid var(--krya-ai-fokus, #93C5FD); outline-offset: 2px; }
.krya-ai-msg a.krya-ai-link--seite svg { width: 14px; height: 14px; flex: none; }
