/* ===== FUCHS AVATAR KOMPONENTE ===== */

/* CSS Variables für Anpassbarkeit */
:root {
    --fox-size: 100px;
    --fox-speech-bg: white;
    --fox-speech-shadow: rgba(0, 0, 0, 0.15);
}

/* Container */
.fox-container {
    position: fixed;
    top: 80px;
    right: 20px;
    width: var(--fox-size);
    height: calc(var(--fox-size) * 1.4);
    z-index: 1000;
    cursor: grab;
    /* Keine transition hier - würde Drag&Drop stören */
}

/* user-select: none nur für Avatar, nicht für Chat */
.fox-container .fox-avatar,
.fox-container .fox-speech-bubble {
    user-select: none;
}

.fox-container.fox-dragging {
    cursor: grabbing;
}

/* Positionierungs-Varianten (falls manuell gesetzt) */
.fox-container.fox-inline {
    position: relative;
    top: auto;
    right: auto;
    display: inline-block;
    cursor: default;
}

.fox-container.fox-fixed-corner {
    top: auto;
    bottom: 20px;
    right: 20px;
}

.fox-container.fox-fixed-corner-left {
    top: auto;
    bottom: 20px;
    left: 20px;
    right: auto;
}

/* Versteckt-Status */
.fox-container.fox-hidden {
    display: none;
}

/* Sprechblase - links neben dem Fuchs */
.fox-speech-bubble {
    position: absolute;
    top: 10px;
    right: calc(100% + 15px);
    left: auto;
    transform: scale(0);
    transform-origin: right center;
    background: var(--fox-speech-bg);
    padding: 10px 15px;
    border-radius: 15px;
    box-shadow: 0 5px 30px var(--fox-speech-shadow);
    min-width: 150px;
    max-width: 220px;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
}

.fox-speech-bubble.visible {
    opacity: 1;
    transform: scale(1);
}

/* Pfeil zeigt nach rechts zum Fuchs */
.fox-speech-bubble::after {
    content: '';
    position: absolute;
    top: 20px;
    right: -10px;
    left: auto;
    bottom: auto;
    transform: none;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 12px solid var(--fox-speech-bg);
    border-right: none;
}

.fox-speech-bubble p {
    margin: 0;
    color: #333;
    font-size: 13px;
    line-height: 1.3;
    text-align: center;
}

/* Fuchs SVG Container */
.fox-avatar {
    width: var(--fox-size);
    height: var(--fox-size);
    cursor: pointer;
    transition: transform 0.3s ease;
}

.fox-avatar:hover {
    transform: scale(1.05);
}

/* ===== ANIMATIONEN ===== */

@keyframes fox-float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

@keyframes fox-blink {
    0%, 45%, 55%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.1); }
}

@keyframes fox-tailWag {
    0%, 100% { transform: rotate(-10deg); }
    50% { transform: rotate(10deg); }
}

@keyframes fox-earTwitch {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(5deg); }
    75% { transform: rotate(-5deg); }
}

@keyframes fox-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    25% { transform: translateY(-15px) scale(1.02); }
    50% { transform: translateY(0) scale(0.98); }
    75% { transform: translateY(-8px) scale(1.01); }
}

@keyframes fox-sparkle {
    0%, 100% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1); }
}

/* Basis-Animationen */
.fox-body {
    animation: fox-float 3s ease-in-out infinite;
}

.fox-eye {
    transform-origin: center;
    animation: fox-blink 4s ease-in-out infinite;
}

.fox-eye.left {
    animation-delay: 0.1s;
}

.fox-tail {
    transform-origin: 85% 50%;
    animation: fox-tailWag 1s ease-in-out infinite;
}

.fox-ear {
    transform-origin: bottom center;
}

.fox-ear.left {
    animation: fox-earTwitch 5s ease-in-out infinite;
}

.fox-ear.right {
    animation: fox-earTwitch 5s ease-in-out infinite;
    animation-delay: 2.5s;
}

/* ===== ZUSTÄNDE ===== */

/* Speaking State */
.fox-avatar.speaking .fox-body {
    animation: fox-float 1.5s ease-in-out infinite;
}

/* Celebrating State */
.fox-avatar.celebrating .fox-body {
    animation: fox-bounce 0.6s ease-in-out infinite;
}

.fox-avatar.celebrating .fox-tail {
    animation: fox-tailWag 0.3s ease-in-out infinite;
}

/* Container während Feier-Animation vergrößern und zentrieren */
.fox-container.fox-celebrating {
    width: calc(var(--fox-size) * 1.8);
    height: calc(var(--fox-size) * 1.8);
    /* Zentriert den Fuchs auf dem Bildschirm */
    left: 50% !important;
    right: auto !important;
    top: 50% !important;
    transform: translate(-50%, -50%);
    margin: 0;
    transition: all 0.5s ease-out;
}

.fox-container.fox-celebrating .fox-chat-button {
    transition: opacity 0.3s ease;
}

/* Sprechblase beim Feiern über dem Fuchs positionieren */
.fox-container.fox-celebrating .fox-speech-bubble {
    top: auto;
    bottom: calc(100% + 10px);
    right: 50%;
    left: auto;
    transform: translateX(50%);
    transform-origin: center bottom;
}

/* Pfeil zeigt nach unten zum Fuchs beim Feiern */
.fox-container.fox-celebrating .fox-speech-bubble::after {
    top: auto;
    bottom: -10px;
    right: 50%;
    left: auto;
    transform: translateX(50%);
    border-top: 12px solid var(--fox-speech-bg);
    border-bottom: none;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
}

/* ===== SPARKLES ===== */

.fox-sparkles {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 150px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fox-sparkles.visible {
    opacity: 1;
}

.fox-sparkle {
    position: absolute;
    width: 20px;
    height: 20px;
    animation: fox-sparkle 1s ease-in-out infinite;
}

.fox-sparkle:nth-child(1) { top: 10%; left: 10%; animation-delay: 0s; }
.fox-sparkle:nth-child(2) { top: 5%; left: 80%; animation-delay: 0.2s; }
.fox-sparkle:nth-child(3) { top: 30%; left: 5%; animation-delay: 0.4s; }
.fox-sparkle:nth-child(4) { top: 25%; left: 90%; animation-delay: 0.6s; }
.fox-sparkle:nth-child(5) { top: 50%; left: 15%; animation-delay: 0.8s; }

/* ===== GRÖßEN-VARIANTEN ===== */

.fox-container.fox-small {
    --fox-size: 120px;
}

.fox-container.fox-small .fox-speech-bubble {
    top: -60px;
    min-width: 150px;
    max-width: 200px;
    padding: 10px 15px;
    font-size: 14px;
}

.fox-container.fox-large {
    --fox-size: 280px;
}

.fox-container.fox-large .fox-speech-bubble {
    top: -100px;
    min-width: 250px;
    max-width: 350px;
}

/* ===== CHAT BUTTON ===== */

.fox-chat-button {
    position: absolute;
    bottom: 10px;
    left: -15px;
    right: auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border: 2px solid white;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 101;
}

.fox-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.fox-chat-button:active {
    transform: scale(0.95);
}

.fox-chat-button svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* ===== CHAT CONTAINER ===== */

.fox-chat-container {
    position: absolute;
    top: 0;
    right: calc(100% + 15px);
    left: auto;
    bottom: auto;
    width: 280px;
    max-height: 400px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.9) translateX(10px);
    transform-origin: right top;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1001;
}

.fox-chat-container.visible {
    opacity: 1;
    transform: scale(1) translateX(0);
    pointer-events: auto;
}

/* Chat Header */
.fox-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: linear-gradient(135deg, #FF8C42 0%, #E85D04 100%);
    color: white;
}

.fox-chat-header span {
    font-weight: 600;
    font-size: 14px;
}

.fox-chat-close {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s ease;
}

.fox-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages */
.fox-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 280px;
    min-height: 150px;
}

.fox-chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.4;
    animation: messageSlideIn 0.3s ease;
}

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

.fox-chat-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.fox-chat-message.fox {
    align-self: flex-start;
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.fox-chat-message.fox.correction {
    background: #fff3e0;
    border-left: 3px solid #ff9800;
}

/* Typing Indicator */
.fox-chat-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #f0f0f0;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 60px;
}

.fox-chat-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}

.fox-chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.fox-chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Chat Input */
.fox-chat-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.fox-chat-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

.fox-chat-input input:focus {
    border-color: #FF8C42;
}

.fox-chat-input input::placeholder {
    color: #aaa;
}

.fox-chat-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #FF8C42 0%, #E85D04 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.fox-chat-input button:hover {
    transform: scale(1.05);
}

.fox-chat-input button:active {
    transform: scale(0.95);
}

.fox-chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.fox-chat-input button svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* ===== CHAT QUIZ ===== */

.fox-chat-quiz {
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cd 100%);
    border: 2px solid #ffc107;
    border-radius: 12px;
    padding: 12px;
    margin-top: 8px;
    animation: messageSlideIn 0.3s ease;
}

.fox-quiz-question {
    font-weight: 600;
    color: #856404;
    font-size: 14px;
    margin-bottom: 10px;
    text-align: center;
}

.fox-quiz-input-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.fox-quiz-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 16px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
    user-select: text;
    pointer-events: auto;
    -webkit-user-select: text;
}

.fox-quiz-input:focus {
    border-color: #ffc107;
}

.fox-quiz-check {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fox-quiz-check svg {
    width: 16px;
    height: 16px;
    fill: #333;
}

.fox-quiz-check:hover {
    transform: scale(1.05);
}

.fox-quiz-check:active {
    transform: scale(0.95);
}

.fox-quiz-hint-btn {
    display: block;
    width: 100%;
    padding: 6px;
    border: 1px dashed #ccc;
    border-radius: 8px;
    background: transparent;
    color: #666;
    font-size: 11px;
    cursor: pointer;
    margin-bottom: 6px;
    transition: all 0.2s ease;
}

.fox-quiz-hint-btn:hover {
    background: rgba(255, 193, 7, 0.1);
    border-color: #ffc107;
}

.fox-quiz-hint {
    background: #fff;
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
    color: #666;
    font-style: italic;
    text-align: center;
    margin-bottom: 6px;
}

.fox-quiz-result {
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    min-height: 20px;
}

.fox-quiz-result.correct {
    color: #28a745;
}

.fox-quiz-result.wrong {
    color: #dc3545;
}
