/* ================================================
   AllyouneedisHarry Chatbot
   CSS - Glassmorphismus-Roboter + Dark Theme
   ================================================ */

/* --- Launcher-Wrapper --- */
#chatbot-launcher {
    position: fixed;
    bottom: 135px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

/* --- Sprechblase --- */
#harry-bubble {
    background: rgba(26, 37, 53, 0.92);
    color: #e8edf2;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px 12px 4px 12px;
    padding: 9px 14px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}

#harry-bubble.sichtbar {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* --- Figur-Button --- */
#harry-figure {
    position: relative;
    width: 76px;
    height: 76px;
    cursor: pointer;
    background: transparent;
    border: none;
    border-radius: 50%;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    transition: transform 0.2s ease;
}

#harry-figure:hover {
    transform: scale(1.08);
}

#harry-figure:focus {
    outline: none;
}

/* Nur für Tastatur-Navigation sichtbar, nicht bei Maus/Touch */
#harry-figure:focus-visible {
    outline: 3px solid #4499ff;
    outline-offset: 4px;
    border-radius: 50%;
}

/* --- Roboter-SVG --- */
#mascot-robot {
    display: block;
    /* Blauer Atmosphären-Glow + Tiefenschatten */
    filter: drop-shadow(0 0 10px rgba(51,136,255,0.55))
            drop-shadow(0 5px 14px rgba(0,0,0,0.65));
    animation: robotFloat 4s ease-in-out infinite;
    overflow: visible;
}

@keyframes robotFloat {
    0%, 100% { transform: translateY(0); }
    45%       { transform: translateY(-6px); }
    65%       { transform: translateY(-3px); }
}

/* --- Arme: sanfte Pendelbewegung --- */
#robot-arm-l {
    transform-box: view-box;
    transform-origin: 14px 31px;
    animation: armSwingL 5s ease-in-out infinite;
}

#robot-arm-r {
    transform-box: view-box;
    transform-origin: 42px 31px;
    animation: armSwingR 5s ease-in-out infinite;
}

@keyframes armSwingL {
    0%, 100% { transform: rotate(-10deg); }
    25%      { transform: rotate(-28deg); }
    75%      { transform: rotate(-2deg); }
}

@keyframes armSwingR {
    0%, 100% { transform: rotate(10deg); }
    25%      { transform: rotate(28deg); }
    75%      { transform: rotate(2deg); }
}

/* --- Augenlider (Android-Blink) --- */
.robot-eyelid {
    transform-box: fill-box;
    transform-origin: 50% 0%;
    transform: scaleY(0);
    animation: robotBlink 6s ease-in-out infinite;
}

@keyframes robotBlink {
    0%, 78%   { transform: scaleY(0); }   /* Augen offen */
    83%       { transform: scaleY(1); }   /* zuklappen */
    90%       { transform: scaleY(1); }   /* kurz geschlossen */
    95%, 100% { transform: scaleY(0); }   /* aufklappen */
}

/* --- Antennen-Lampe blinkt blau --- */
#antenna-light {
    animation: antennaFlash 3.5s ease-in-out infinite;
}

#antenna-glow {
    animation: antennaFlash 3.5s ease-in-out infinite;
}

@keyframes antennaFlash {
    0%, 35%, 55%, 100% { opacity: 1; }
    45%                { opacity: 0.08; }
}

/* --- Gelegentlicher Neon-Orange/Gelb-Blink der Antenne --- */
#antenna-orange {
    animation: antennaOrangeFlash 13s ease-in-out 3s infinite;
}

#antenna-glow-orange {
    animation: antennaOrangeFlash 13s ease-in-out 3s infinite;
}

@keyframes antennaOrangeFlash {
    /* Fast immer unsichtbar – kurzes Orange-Aufflackern ca. alle 13 Sekunden */
    0%, 52%, 72%, 100% { opacity: 0; }
    57%                { opacity: 1; }
    64%                { opacity: 0.9; }
    69%                { opacity: 0; }
}

/* --- Hover: rechter Arm winkt --- */
#harry-figure:hover #robot-arm-r {
    animation: armWave 0.55s ease-in-out infinite;
}

@keyframes armWave {
    0%, 100% { transform: rotate(10deg); }
    50%      { transform: rotate(45deg); }
}

/* --- Klopfen --- */
@keyframes robotKnock {
    0%, 100% { transform: rotate(0deg); }
    45%      { transform: rotate(50deg); }
}

@keyframes robotLean {
    0%, 100% { transform: rotate(0deg) translateX(0); }
    20%, 80% { transform: rotate(8deg) translateX(3px); }
}

#harry-figure.knocking #mascot-robot {
    animation: robotLean 1.4s ease-in-out forwards !important;
}

#harry-figure.knocking #robot-arm-r {
    animation: robotKnock 0.45s ease-in-out 3 forwards !important;
}

/* --- Schlafen --- */
.zzz {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 15px;
    font-weight: bold;
    color: #4499ff;
    font-family: sans-serif;
    opacity: 0;
    pointer-events: none;
    line-height: 1;
}

.zzz2 { font-size: 11px; top: -6px;  right: 8px;  }
.zzz3 { font-size: 9px;  top: -14px; right: 14px; }

#harry-figure.sleeping .zzz  { animation: zzzFloat 2.5s ease-out infinite; }
#harry-figure.sleeping .zzz2 { animation: zzzFloat 2.5s ease-out 0.8s infinite; }
#harry-figure.sleeping .zzz3 { animation: zzzFloat 2.5s ease-out 1.6s infinite; }

@keyframes zzzFloat {
    0%   { opacity: 0; transform: translate(0, 0) scale(0.7); }
    25%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-12px, -24px) scale(1.1); }
}

#harry-figure.sleeping #mascot-robot     { animation: none; }
#harry-figure.sleeping .robot-eyelid     { animation: none; transform: scaleY(1); }
#harry-figure.sleeping #robot-arm-l,
#harry-figure.sleeping #robot-arm-r      { animation: none; }
#harry-figure.sleeping #antenna-light,
#harry-figure.sleeping #antenna-glow     { animation: none; opacity: 0.15; }
#harry-figure.sleeping #antenna-orange,
#harry-figure.sleeping #antenna-glow-orange { animation: none; opacity: 0; }

/* --- Chatfenster --- */
#chat-container {
    position: fixed;
    bottom: 255px;
    right: 24px;
    width: 320px;
    max-height: 460px;
    background: #1a2535;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    display: none;
    flex-direction: column;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

#chat-container.offen {
    display: flex;
}

/* --- Header --- */
#chat-header {
    background: #1565c0;
    color: #ffffff;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: 0.01em;
}

#chat-header-inner {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#chat-header-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

#chat-header-sub {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.72;
    margin-top: 3px;
    line-height: 1.3;
}

#chat-schliessen {
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: #ffffff;
    opacity: 0.75;
    transition: opacity 0.15s, background 0.15s;
}

#chat-schliessen:hover,
#chat-schliessen:focus {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
    outline: 2px solid rgba(255, 255, 255, 0.6);
}

/* --- Nachrichtenbereich --- */
#chat-nachrichten {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 180px;
    scrollbar-width: thin;
    scrollbar-color: #3a4f6a #1a2535;
}

#chat-nachrichten::-webkit-scrollbar       { width: 5px; }
#chat-nachrichten::-webkit-scrollbar-track { background: #1a2535; }
#chat-nachrichten::-webkit-scrollbar-thumb { background: #3a4f6a; border-radius: 4px; }

/* --- Nachrichten --- */
.nachricht {
    max-width: 88%;
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    color: #e8edf2;
}

.nachricht.bot  { background: #243347; align-self: flex-start; border-bottom-left-radius: 3px; color: #d4dde8; }
.nachricht.user { background: #1565c0; color: #ffffff; align-self: flex-end; border-bottom-right-radius: 3px; }
.nachricht.tipp {
    background: rgba(255,255,255,0.06);
    color: #7a96b2; font-size: 11.5px;
    align-self: center; text-align: center;
    border-radius: 8px; max-width: 95%; padding: 7px 10px;
}

/* --- Eingabebereich --- */
#chat-eingabe-bereich {
    display: flex;
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,0.07);
    gap: 8px;
    align-items: center;
    background: #1a2535;
}

#chat-eingabe {
    flex: 1;
    background: #243347;
    border: 1px solid #3a4f6a;
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 14px;
    color: #e8edf2;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

#chat-eingabe::placeholder { color: #5a7a9a; }
#chat-eingabe:focus { border-color: #1976d2; box-shadow: 0 0 0 2px rgba(25,118,210,0.3); }

/* --- Senden-Button --- */
#chat-senden {
    background: #1976d2;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 38px; height: 38px; min-width: 38px;
    cursor: pointer;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, transform 0.1s;
}

#chat-senden:hover    { background: #1565c0; }
#chat-senden:focus    { outline: 3px solid #64b5f6; outline-offset: 2px; }
#chat-senden:active   { transform: scale(0.93); }
#chat-senden:disabled { background: #2d3d50; color: #4a6a8a; cursor: not-allowed; }

/* Links in Nachrichten */
.nachricht a       { color: #64b5f6; text-decoration: underline; word-break: break-all; }
.nachricht.user a  { color: #cce5ff; }
.nachricht a:hover { color: #ffffff; }

/* --- Disclaimer-Badge --- */
#chat-disclaimer {
    font-size: 10px;
    color: #3a5268;
    text-align: center;
    padding: 5px 12px 7px;
    background: #1a2535;
    border-top: 1px solid rgba(255,255,255,0.04);
    line-height: 1.4;
    letter-spacing: 0.01em;
}

/* Screen Reader */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* --- Reduzierte Bewegung --- */
@media (prefers-reduced-motion: reduce) {
    #mascot-robot, .robot-eyelid, #robot-arm-l, #robot-arm-r,
    #antenna-light, #antenna-glow, #antenna-orange, #antenna-glow-orange,
    .zzz, #harry-bubble {
        animation: none;
        transition: none;
    }
    #antenna-orange, #antenna-glow-orange { opacity: 0; }
}
