/* ========================================
   InfinitySpace42 - Smooth Dropdown Animations
   ======================================== */

/* Base dropdown container state */
.dropdown-content {
    position: absolute;
    transform-origin: top right;
    display: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    will-change: opacity, transform;
    z-index: 10002;
}

/* Active animation phases */
.dropdown-content.slideout-animating {
    display: block;
}

.dropdown-content.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.dropdown-content.closing {
    pointer-events: none;
}

/* Inner panel styling + 2-Stage Animation */
.dropdown-content .dropdown-slideout-panel {
    width: 100%;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(28, 31, 38, 0.15);
    overflow: hidden;

    /* Animation: Start collapsed */
    transform: scaleX(0) scaleY(0);
    transform-origin: top right;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-content.slideout-animating .dropdown-slideout-panel {
    /* Stage 1: Width expands from button width */
    transform: scaleX(1) scaleY(0);
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-content.show .dropdown-slideout-panel {
    /* Stage 2: Height expands */
    transform: scaleX(1) scaleY(1);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1) 0.15s;
}

.dropdown-content.closing .dropdown-slideout-panel {
    /* Reverse: First height, then width */
    transform: scaleX(1) scaleY(0);
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Specific sizing for both dropdowns */
.feedback-dropdown .dropdown-slideout-panel {
    min-width: 320px;
    max-height: 600px;
    overflow-y: auto;
}

.profile-dropdown .dropdown-slideout-panel {
    min-width: 280px;
    max-height: 500px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .feedback-dropdown .dropdown-slideout-panel,
    .profile-dropdown .dropdown-slideout-panel {
        min-width: 0;
        width: min(100vw - 32px, 420px);
        max-height: min(80vh, 540px);
        margin: 0 auto;
    }
}

/* Button hover effects during animations */
.dropdown-content button {
    transition: all 0.3s ease;
    transform: translateY(0);
    opacity: 1;
}

.dropdown-content:not(.show) button {
    transform: translateY(-10px);
    opacity: 0;
    transition-delay: 0s;
}

.dropdown-content.show button {
    transform: translateY(0);
    opacity: 1;
    transition-delay: 0.2s;
}

/* Staggered button animations */
.dropdown-content.show button:nth-child(1) { transition-delay: 0.1s; }
.dropdown-content.show button:nth-child(2) { transition-delay: 0.15s; }
.dropdown-content.show button:nth-child(3) { transition-delay: 0.2s; }
.dropdown-content.show button:nth-child(4) { transition-delay: 0.25s; }
.dropdown-content.show button:nth-child(5) { transition-delay: 0.3s; }

/* Loading state animations */
.dropdown-content.loading {
    opacity: 0.7;
    pointer-events: none;
}

.dropdown-content.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #00ffcc;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   Feedback Popup Animations
   ======================================== */

@keyframes feedbackSlideInDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#feedback-popup {
    animation: feedbackSlideInDown 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Chatbot Container Animations - REBUILT
   2-Stage: horizontal (wie Button-Breite), dann vertical
   ======================================== */

.infinity-chatbot-container {
    /* Start unsichtbar */
    display: none;
    opacity: 0;
    transform-origin: bottom right;
    will-change: transform, opacity;
}

/* Opening Animation - 2 Stufen */
.infinity-chatbot-container.is-opening {
    display: flex !important;
    animation: chatbot-expand-new 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Closing Animation */
.infinity-chatbot-container.is-closing {
    animation: chatbot-collapse-new 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Sichtbarer Zustand */
.infinity-chatbot-container[data-open="true"]:not(.is-opening):not(.is-closing) {
    display: flex !important;
    opacity: 1 !important;
    transform: scale(1) !important;
}

/* NEU: 2-Stage Animation */
@keyframes chatbot-expand-new {
    0% {
        transform: scaleX(0.1) scaleY(0.1);
        opacity: 0;
    }
    45% {
        /* Stage 1: Horizontal (wie Button-Breite 60px) */
        transform: scaleX(1) scaleY(0.1);
        opacity: 1;
    }
    100% {
        /* Stage 2: Vertical voll ausfahren */
        transform: scaleX(1) scaleY(1);
        opacity: 1;
    }
}

@keyframes chatbot-collapse-new {
    0% {
        transform: scaleX(1) scaleY(1);
        opacity: 1;
    }
    55% {
        /* Stage 1: Vertical zusammenfahren */
        transform: scaleX(1) scaleY(0.1);
        opacity: 1;
    }
    100% {
        /* Stage 2: Horizontal zusammenfahren */
        transform: scaleX(0.1) scaleY(0.1);
        opacity: 0;
    }
}

/* Fallback ohne Animation */
.infinity-chatbot-container.visible {
    display: flex !important;
    opacity: 1 !important;
    transform: scale(1) !important;
    pointer-events: auto !important;
}

.infinity-chatbot-container.hidden {
    display: none !important;
    opacity: 0 !important;
    transform: scale(0) !important;
    pointer-events: none !important;
}

/* Performance */
.infinity-chatbot-container {
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Shared slideout modal template */
.slideout-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(28, 31, 38, 0.78);
    z-index: 20000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
    padding: 20px;
    box-sizing: border-box;
}

.slideout-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.slideout-panel {
    background: #ffffff;
    border-radius: 15px;
    padding: 30px;
    max-width: 520px;
    width: min(90vw, 520px);
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 24px 48px rgba(28, 31, 38, 0.25);
    position: relative;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .feedback-dropdown .dropdown-slideout-panel,
    .profile-dropdown .dropdown-slideout-panel {
        min-width: min(90vw, 420px);
        width: min(90vw, 420px);
    }

    .slideout-panel {
        width: min(92vw, 480px);
        max-width: 480px;
        padding: 24px;
    }
}
