/**
 * Voice Glass V2 — Glassmorphism Focus Mode
 * Overlay on the normal chat with spotlight on active element
 */

/* ═══════════════════════════════════════
   GLASS OVERLAY — The "Glasscheibe"
   ═══════════════════════════════════════ */

.vg-glass-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    pointer-events: none; /* Klicks gehen durch zum Chat! */
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.vg-glass-overlay.active {
    opacity: 1;
}

/* ═══════════════════════════════════════
   SPOTLIGHT — Active element "vor der Glasscheibe"
   ═══════════════════════════════════════ */

/* Das aktive Chat-Element bekommt diesen Spotlight */
.vg-spotlight {
    position: relative !important;
    z-index: 10001 !important;
    pointer-events: auto !important;
    transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Glow-Rahmen um das aktive Element */
.vg-spotlight::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    z-index: -1;
    animation: vgSpotlightEnter 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes vgSpotlightEnter {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Exit-Animation: Element gleitet zurück hinter die Glasscheibe */
.vg-spotlight-exit {
    position: relative !important;
    z-index: 10001 !important;
    animation: vgSpotlightExit 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.vg-spotlight-exit::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.5);
    z-index: -1;
    animation: vgGlowFade 0.4s ease-out forwards;
}

@keyframes vgSpotlightExit {
    from {
        opacity: 1;
        transform: scale(1);
        filter: none;
    }
    to {
        opacity: 0.6;
        transform: scale(0.98);
        filter: blur(2px);
    }
}

@keyframes vgGlowFade {
    to { opacity: 0; }
}

/* Antwort-Buttons innerhalb des Spotlights: klickbar */
.vg-spotlight .choice-button,
.vg-spotlight .choice-input,
.vg-spotlight .senden-button {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Spacing between consecutive spotlighted bot-messages (ki-element + follow-up) */
.vg-spotlight.bot-message + .vg-spotlight.bot-message {
    margin-top: 12px;
}

/* Visuelles Feedback: Button "magisch" geklickt */
.vg-voice-clicked {
    animation: vgButtonClick 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes vgButtonClick {
    0% { transform: scale(1); box-shadow: none; }
    30% { transform: scale(0.95); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3); }
    60% { transform: scale(1.02); box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.15); }
    100% { transform: scale(1); box-shadow: none; }
}

/* ═══════════════════════════════════════
   BOTTOM CONTROLS — Fixed am unteren Rand
   ═══════════════════════════════════════ */

.vg-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10002;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 16px 20px;
    gap: 8px;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: auto;
}

.vg-controls.active {
    transform: translateY(0);
}

/* Waveform Container */
.vg-waveform-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border-radius: 20px 20px 14px 14px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow:
        0 -4px 24px rgba(0, 0, 0, 0.06),
        0 -1px 8px rgba(0, 0, 0, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.vg-waveform-canvas {
    width: 100%;
    height: 56px;
    border-radius: 12px;
    background: linear-gradient(180deg,
        rgba(99, 102, 241, 0.04) 0%,
        rgba(99, 102, 241, 0.02) 100%);
}

/* Status-Text */
.vg-status {
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--gruen, #475569);
    text-align: center;
    letter-spacing: 0.02em;
    padding: 2px 0;
    opacity: 0.8;
}

/* Button-Leiste */
.vg-button-bar {
    width: 100%;
    max-width: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border-radius: 14px 14px 20px 20px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Gemeinsame Button-Styles */
.vg-btn {
    height: 40px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.5);
    color: var(--gruen, #334155);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.vg-btn:hover {
    background: rgba(255, 255, 255, 0.75);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.vg-btn:active {
    transform: translateY(0);
}

.vg-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Pause-Button */
.vg-btn-pause.paused {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
    color: #6366f1;
}

/* Beenden-Button */
.vg-btn-stop {
    background: rgba(220, 38, 38, 0.06);
    border-color: rgba(220, 38, 38, 0.12);
    color: #dc2626;
}

.vg-btn-stop:hover {
    background: rgba(220, 38, 38, 0.12);
}

/* Voice-Selector */
.vg-voice-select {
    height: 40px;
    padding: 0 28px 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.5);
    color: var(--gruen, #334155);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23475569'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.2s;
}

.vg-voice-select:hover {
    background-color: rgba(255, 255, 255, 0.75);
}

/* ═══════════════════════════════════════
   STATUS DOT — Replaces old mic button
   ═══════════════════════════════════════ */

.vg-status-dot {
    width: 12px;
    height: 12px;
    min-width: 12px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    animation: vgDotBreathe 2s ease-in-out infinite;
    flex-shrink: 0;
}

body.vg-active .vg-status-dot {
    background: #22c55e;
}

@keyframes vgDotBreathe {
    0%, 100% { opacity: 0.6; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Paused state: amber dot, no breathing animation */
.vg-status-dot.vg-paused {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
    animation: none;
    opacity: 0.85;
}

/* ═══════════════════════════════════════
   GOAL-PAGE CONTINUE BUTTON
   ═══════════════════════════════════════ */

.vg-goal-continue {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.08));
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 16px;
    cursor: pointer;
    z-index: 5;
    font-size: 14px;
    font-weight: 600;
    color: #4f46e5;
    white-space: nowrap;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: vgGoalFadeIn 0.4s ease-out;
}

.vg-goal-continue:hover {
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.15));
    border-color: rgba(99,102,241,0.4);
    transform: scale(1.02);
    box-shadow: 0 4px 20px rgba(99,102,241,0.15);
}

.vg-goal-continue:active {
    transform: scale(0.98);
}

.vg-goal-continue-icon {
    font-size: 20px;
}

.vg-goal-continue-text {
    letter-spacing: 0.01em;
}

.vg-goal-continue-arrow {
    display: flex;
    align-items: center;
    animation: vgArrowPulse 1.5s ease-in-out infinite;
}

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

@keyframes vgArrowPulse {
    0%, 100% { transform: translateX(0); opacity: 0.7; }
    50% { transform: translateX(4px); opacity: 1; }
}

/* ═══════════════════════════════════════
   IN-CHAT INLINE "Weiter" BUTTON
   Placed inside the goal-page bot-message
   so it's visible in the spotlight area
   ═══════════════════════════════════════ */

.vg-goal-continue-inline {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    margin-top: 12px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), rgba(16, 185, 129, 0.08));
    border: 2px solid rgba(34, 197, 94, 0.3);
    border-radius: 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #16a34a;
    white-space: nowrap;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: vgGoalFadeIn 0.4s ease-out;
    z-index: 5;
}

.vg-goal-continue-inline:hover {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.22), rgba(16, 185, 129, 0.16));
    border-color: rgba(34, 197, 94, 0.5);
    transform: scale(1.02);
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.2);
}

.vg-goal-continue-inline:active {
    transform: scale(0.98);
}

.vg-goal-continue-inline .vg-goal-continue-icon {
    font-size: 20px;
}

.vg-goal-continue-inline .vg-goal-continue-text {
    letter-spacing: 0.01em;
}

.vg-goal-continue-inline .vg-goal-continue-arrow {
    display: flex;
    align-items: center;
    animation: vgArrowPulse 1.5s ease-in-out infinite;
    color: #16a34a;
}

/* ═══════════════════════════════════════
   TOGGLE BUTTON — Centered in chat area
   ═══════════════════════════════════════ */

/* ═══════════════════════════════════════
   MIC FOOTER BAR — SVG notch design
   Sits in .chat-parent-container (absolute)
   ═══════════════════════════════════════ */

.vg-mic-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    z-index: 90;
    pointer-events: none;
    overflow: visible;
}

.vg-mic-footer .vg-notch-svg {
    display: block;
    width: 100%;
    height: 100%;
}

.vg-toggle-custom {
    position: absolute !important;
    bottom: 6px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    z-index: 95 !important;
    width: 48px !important;
    height: 48px !important;
    border: 3px solid var(--vg-footer-color, #b0bec5) !important;
    box-shadow: 0 2px 14px rgba(0,0,0,0.15) !important;
    margin: 0 !important;
}

.vg-toggle-custom:hover {
    transform: translateX(-50%) scale(1.08) !important;
    border-color: var(--vg-footer-color, #b0bec5) !important;
}

/* Hide the OLD voice-toggle-btn (from chat_v.php) when footer mic exists */
body:has(.vg-mic-footer) #voice-toggle-btn {
    display: none !important;
}

/* Position undo button ABOVE the footer bar */
body:has(.vg-mic-footer) .undo-btn {
    bottom: 64px !important;
}

/* ═══════════════════════════════════════
   LOADING DOTS (during extraction)
   ═══════════════════════════════════════ */

.vg-thinking {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
}

.vg-thinking span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gruen, #6366f1);
    opacity: 0.3;
    animation: vgDotPulse 1.2s ease-in-out infinite;
}

.vg-thinking span:nth-child(2) { animation-delay: 0.2s; }
.vg-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes vgDotPulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1.1); }
}

/* ═══════════════════════════════════════
   SCROLL PADDING — Platz für Controls
   ═══════════════════════════════════════ */

body.vg-active .chat-container {
    padding-bottom: 200px !important;
}

body.vg-active .undo-btn {
    bottom: 200px !important;
}

/* In voice mode: hide structural UI elements for clean overlay */
body.vg-active .header,
body.vg-active .haupt-menue,
body.vg-active #tabs-header-container,
body.vg-active .kapitel_schritte_container,
body.vg-active #chat-ladebalken {
    display: none !important;
}

/* Hide speech bubble triangles in voice mode — they overflow the glass container */
body.vg-active .bot-message::after {
    content: none !important;
}

/* Keep logo visible above the glass overlay, fixed at top */
body.vg-active .header-logo {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10100;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 8px 16px;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* Chat parent fills full viewport in voice mode */
body.vg-active .chat-parent-container {
    padding-top: 0 !important;
    margin-top: 0 !important;
    min-height: 100vh !important;
    height: 100vh !important;
}

body.vg-active #chat-container {
    padding-top: 20px !important;
}

/* Elevate payment overlays ABOVE the glass layer during voice mode */
body.vg-active #payment-overlay,
body.vg-active #abo-details-modal,
body.vg-active .abo-details-modal,
body.vg-active #loadingOverlay,
body.vg-active .loadingOverlay,
body.vg-active #login-overlay {
    z-index: 10050 !important;
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */

@media (max-width: 600px) {
    .vg-controls {
        padding: 0 8px 12px;
    }

    .vg-waveform-container {
        padding: 8px 12px;
    }

    .vg-waveform-canvas {
        height: 40px;
    }

    .vg-button-bar {
        gap: 6px;
        padding: 8px 10px;
    }

    .vg-btn {
        height: 36px;
        padding: 0 10px;
        font-size: 12px;
    }


    .vg-voice-select {
        height: 36px;
        font-size: 12px;
    }
}

/* ═══════════════════════════════════════
   TRANSITION: Voice-Antwort -> Chat scrollt
   ═══════════════════════════════════════ */

.chat-container {
    scroll-behavior: smooth;
}

/* Sanfte Scroll-Animation zum nächsten Element */
.vg-scroll-target {
    scroll-margin-top: 80px;
    scroll-margin-bottom: 220px;
}

/* ═══════════════════════════════════════
   TUTORIAL OVERLAY
   ═══════════════════════════════════════ */

.vg-tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 10010;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.4s;
    pointer-events: auto;
}

.vg-tutorial-overlay.active {
    opacity: 1;
}

.vg-tutorial-card {
    width: 90%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    padding: 32px 28px;
    text-align: center;
    animation: vgTutorialSlideIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes vgTutorialSlideIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.vg-tutorial-card h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 8px;
    color: #1e293b;
}

.vg-tutorial-card p {
    font-size: 14px;
    line-height: 1.6;
    color: #475569;
    margin: 0 0 20px;
}

.vg-tutorial-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.vg-tutorial-step {
    display: none;
}

.vg-tutorial-step.active {
    display: block;
    animation: vgTutorialFadeIn 0.4s ease-out;
}

@keyframes vgTutorialFadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.vg-tutorial-success {
    display: none;
    font-size: 64px;
    animation: vgSuccessPop 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.vg-tutorial-success.show {
    display: block;
}

@keyframes vgSuccessPop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.vg-tutorial-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border-radius: 14px;
    border: none;
    background: var(--chat-button-bg, #6366f1);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.vg-tutorial-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.vg-tutorial-btn.secondary {
    background: rgba(0, 0, 0, 0.06);
    color: #475569;
}

.vg-tutorial-btn.secondary:hover {
    background: rgba(0, 0, 0, 0.1);
    box-shadow: none;
}

.vg-tutorial-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 20px;
}

.vg-tutorial-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.15);
    transition: all 0.3s;
}

.vg-tutorial-dot.active {
    background: var(--chat-button-bg, #6366f1);
    width: 20px;
    border-radius: 4px;
}

/* Tutorial help button (in controls) */
.vg-btn-help {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
    font-size: 14px;
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.15);
    color: #6366f1;
}

.vg-btn-help:hover {
    background: rgba(99, 102, 241, 0.15);
}
