/**
 * Chat-UI Styles für Vidacta ElevenLabs Agents
 *
 * CSS Custom Properties (gesetzt inline pro Container):
 * --vea-primary: Primary Color (Buttons, User-Bubble)
 * --vea-bubble-ai: AI-Bubble Hintergrund
 * --vea-bubble-user: User-Bubble Hintergrund
 */

/* ============================================
   SHARED: Container & Grundstruktur
   ============================================ */

.vea-agent-container {
    position: relative;
    width: 100%;
    background-color: #f4f7f9;
    border-radius: 16px;
    border: 1px solid #e1e1e1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

/* Section-Modus: feste Höhe */
.vea-agent-section {
    min-height: 400px;
}

/* Widget-Modus: füllt Overlay */
.vea-agent-widget {
    width: 100%;
    height: 100%;
    border-radius: 16px 16px 0 0;
}

/* ============================================
   FLOATING WIDGET
   ============================================ */

.vea-widget-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.vea-widget-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--vea-primary, #111111);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: auto;
    transition: transform 0.2s, box-shadow 0.2s;
}

.vea-widget-launcher:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.vea-widget-chat-overlay {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    flex-direction: column;
    z-index: 999998;
    border: 1px solid #e1e1e1;
}

@media (max-width: 480px) {
    .vea-widget-chat-overlay {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px);
        right: 10px;
        bottom: 80px;
        border-radius: 16px;
    }
}

/* ============================================
   PRE-CHAT FORMULAR
   ============================================ */

.vea-form-ui {
    background: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    width: 90%;
    max-width: 420px;
    text-align: center;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.vea-form-title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 22px;
    color: #111;
}

.vea-form-desc {
    font-size: 14px;
    color: #555;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.4;
}

.vea-form-ui .vea-input {
    width: 100% !important;
    padding: 12px !important;
    margin: 0 !important;
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
    font-size: 14px !important;
    outline: none;
    transition: border-color 0.2s;
    height: auto !important;
    line-height: normal !important;
}

.vea-form-ui .vea-input:focus {
    border-color: var(--vea-primary, #111111) !important;
}

/* Name-Felder nebeneinander */
.vea-name-row {
    display: flex !important;
    flex-direction: row !important;
    gap: 12px !important;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
}

.vea-name-row .vea-input {
    flex: 1 !important;
    min-width: 0 !important;
}

/* Consent */
.vea-consent-label {
    font-size: 12px;
    color: #555;
    display: flex;
    align-items: flex-start;
    text-align: left;
    margin-bottom: 20px;
    line-height: 1.5;
    cursor: pointer;
    gap: 10px;
}

.vea-consent-label input[type="checkbox"] {
    margin-top: 3px;
    transform: scale(1.1);
    flex-shrink: 0;
}

.vea-consent-text a {
    color: var(--vea-primary, #0073aa);
}

/* Modus-Wahl */
.vea-mode-choice {
    display: flex;
    gap: 12px;
    margin-top: 5px;
}

.vea-btn {
    padding: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    transition: background 0.2s, transform 0.1s;
}

.vea-btn:active {
    transform: scale(0.98);
}

.vea-btn-mode {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    background-color: #f0f0f0;
    color: #333;
    border: 2px solid transparent;
}

.vea-btn-mode:hover {
    background-color: #e4e4e4;
    border-color: var(--vea-primary, #111111);
}

.vea-btn-icon {
    font-size: 24px;
}

.vea-btn-start {
    width: 100%;
    background-color: var(--vea-primary, #111111);
    color: #ffffff;
}

.vea-btn-start:hover {
    opacity: 0.9;
}

/* Daten ändern Button */
.vea-change-data-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    padding: 8px 0 0;
    text-decoration: underline;
    transition: color 0.2s;
}

.vea-change-data-btn:hover {
    color: var(--vea-primary, #0073aa);
}

/* ============================================
   MESSENGER UI
   ============================================ */

.vea-messenger-ui {
    width: 100%;
    height: 100%;
    flex-direction: column;
    background: #ffffff;
}

/* Header */
.vea-messenger-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #ffffff;
    border-bottom: 1px solid #eaeaea;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
    z-index: 5;
    flex-shrink: 0;
}

.vea-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vea-agent-orb {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--vea-primary, #111111), #333333);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s, box-shadow 0.3s;
    flex-shrink: 0;
}

.vea-agent-display-name {
    margin: 0;
    font-size: 16px;
    color: #111;
}

.vea-agent-status {
    font-size: 12px;
    color: #666;
}

.vea-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vea-audio-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f0f0f0;
    border: 1px solid #ddd;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.vea-audio-toggle-btn:hover {
    background: #e4e4e4;
}

.vea-audio-toggle-btn.vea-muted {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.vea-end-chat-btn {
    padding: 8px 16px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: background 0.2s;
}

.vea-end-chat-btn:hover {
    background-color: #c82333;
}

/* Orb-Animationen */
.vea-orb-listening {
    animation: vea-pulse-listen 2s infinite;
}

.vea-orb-speaking {
    animation: vea-pulse-speak 1s infinite alternate;
    background: linear-gradient(135deg, #0073aa, #00507a) !important;
}

@keyframes vea-pulse-listen {
    0%   { box-shadow: 0 0 0 0 rgba(17, 17, 17, 0.1); }
    70%  { box-shadow: 0 0 0 10px rgba(17, 17, 17, 0); }
    100% { box-shadow: 0 0 0 0 rgba(17, 17, 17, 0); }
}

@keyframes vea-pulse-speak {
    0%   { transform: scale(1); box-shadow: 0 0 8px rgba(0, 115, 170, 0.3); }
    100% { transform: scale(1.05); box-shadow: 0 0 16px rgba(0, 115, 170, 0.6); }
}

/* ============================================
   CHAT-LOG & BUBBLES
   ============================================ */

.vea-chat-log {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: #f9fbfd;
}

.vea-chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.4;
    animation: vea-fadeIn 0.3s ease;
    word-wrap: break-word;
}

.vea-bubble-ai {
    background-color: var(--vea-bubble-ai, #ffffff);
    border: 1px solid #eaeaea;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.vea-bubble-user {
    background-color: var(--vea-bubble-user, #111111);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

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

/* ============================================
   TEXT-EINGABE
   ============================================ */

.vea-text-input-area {
    padding: 15px 20px;
    background: #ffffff;
    border-top: 1px solid #eaeaea;
    display: flex;
    gap: 10px;
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s;
    flex-shrink: 0;
}

.vea-text-input-area.vea-active {
    opacity: 1;
    pointer-events: auto;
}

.vea-text-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.vea-text-input:focus {
    border-color: var(--vea-primary, #0073aa);
}

.vea-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--vea-primary, #0073aa);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.vea-send-btn:hover {
    opacity: 0.9;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
    .vea-agent-section {
        border-radius: 8px;
        min-height: 350px;
    }

    .vea-form-ui {
        padding: 20px;
        width: 95%;
    }

    .vea-messenger-header {
        padding: 12px 15px;
    }

    .vea-chat-log {
        padding: 15px;
    }

    .vea-text-input-area {
        padding: 10px 15px;
    }

    .vea-chat-bubble {
        max-width: 90%;
        font-size: 14px;
    }

    .vea-mode-choice {
        flex-direction: column;
        gap: 8px;
    }
}
