/**
 * MMIND Custom Chat - Styles v7.2.0
 * Build: 2026-04-23
 *
 * Layout passend zum Design:
 * - Nachrichten-Bereich oben
 * - Textarea darunter
 * - Quick-Reply Buttons + Send-Button am unteren Rand
 *
 * Vollstaendig kompatibel mit Elementor.
 */

/* ============================================
   RESET fuer Elementor-Kompatibilitaet
   ============================================ */

.mmind-custom-chat-container *,
.mmind-custom-chat-container *::before,
.mmind-custom-chat-container *::after {
    box-sizing: border-box;
}

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

.mmind-custom-chat-container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Innerhalb von Elementor: Schatten und Max-Width vom Widget steuern lassen */
.elementor-widget-container .mmind-custom-chat-container {
    max-width: 100%;
    box-shadow: none;
}

/* ============================================
   NACHRICHTEN BEREICH
   ============================================ */

.mmind-chat-messages {
    padding: 20px;
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
    background: #f9f9f9;
    scroll-behavior: smooth;
    flex-shrink: 0;
}

/* Leerer Zustand */
.mmind-chat-messages:empty {
    min-height: 60px;
}

/* Scrollbar Styling */
.mmind-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.mmind-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.mmind-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}
.mmind-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Firefox Scrollbar */
.mmind-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 transparent;
}

/* ============================================
   EINZELNE NACHRICHT
   ============================================ */

.mmind-message {
    margin-bottom: 16px;
    animation: mmindMessageSlideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

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

.mmind-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.6;
    font-size: 15px;
}

.mmind-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 8px;
}

/* Nutzer-Nachricht (Rechts) */
.mmind-user-message {
    align-items: flex-end;
}

.mmind-user-message .mmind-message-content {
    background: #6B46C1;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.mmind-user-message .mmind-message-time {
    text-align: right;
}

/* Bot-Nachricht (Links) */
.mmind-bot-message {
    align-items: flex-start;
}

.mmind-bot-message .mmind-message-content {
    background: #ffffff;
    color: #333333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.mmind-bot-message .mmind-message-time {
    text-align: left;
}

/* Bot: Markdown-ähnliche Auszeichnung (**, Zeilen, *-Aufzählung, http(s)-Links) */
.mmind-message-content.mmind-md strong {
    font-weight: 600;
    color: inherit;
}

.mmind-message-content.mmind-md a.mmind-md-link {
    color: #6B46C1;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
}

.mmind-message-content.mmind-md a.mmind-md-link:hover {
    color: #553C9A;
}

.mmind-message-content.mmind-md .mmind-md-bullet {
    font-weight: inherit;
    color: inherit;
}

.mmind-message-content.mmind-md .mmind-md-li {
    display: block;
    margin: 0.2em 0 0.15em 0;
    padding-left: 0.1em;
}

.mmind-message-content.mmind-md .mmind-md-li-num {
    display: block;
    margin: 0.2em 0 0.15em 0;
    padding-left: 0.1em;
    list-style: none;
}

.mmind-message-content.mmind-md .mmind-md-bq {
    display: block;
    margin: 0.35em 0;
    padding: 0.25em 0 0.25em 0.9em;
    border-left: 3px solid #c4b5fd;
    color: #444;
}

.mmind-message-content.mmind-md em {
    font-style: italic;
    color: inherit;
}

.mmind-message-content.mmind-md .mmind-md-code {
    font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
    font-size: 0.9em;
    background: #f3f4f6;
    padding: 0.1em 0.35em;
    border-radius: 4px;
    word-break: break-word;
}

.mmind-custom-chat-container .mmind-message-content.mmind-md a.mmind-md-link,
.mmind-custom-chat-container .mmind-message-content.mmind-md a.mmind-md-link:visited {
    color: #6B46C1;
}

@media (prefers-reduced-motion: reduce) {
    .mmind-typing-dots span {
        animation: none;
    }
    .mmind-ghost-dots span {
        animation: none !important;
    }
    .mmind-ghost-bubble,
    .mmind-ghost-row {
        transition-duration: 0.01ms !important;
    }
    .mmind-chat-messages {
        scroll-behavior: auto;
    }
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.mmind-typing-indicator .mmind-typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 8px 16px;
}

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

.mmind-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}
.mmind-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.mmind-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes mmindTypingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* ============================================
   ERROR MESSAGE
   ============================================ */

.mmind-error-message .mmind-message-content {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    font-size: 14px;
}

/* ============================================
   EINGABEBEREICH (Textarea + Bottom Bar)
   ============================================ */

.mmind-chat-input-area {
    display: flex;
    flex-direction: column;
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
}

/* Textarea */
.mmind-chat-input {
    width: 100% !important;
    padding: 16px 20px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #f9f9f9;
    resize: vertical;
    min-height: 60px;
    max-height: 200px;
    color: #333;
}

/* Auch fuer input[type=text] */
input.mmind-chat-input {
    resize: none;
    min-height: auto;
    max-height: none;
    height: auto;
}

.mmind-chat-input:focus {
    border-color: #6B46C1;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(107, 70, 193, 0.1);
}

.mmind-chat-input::placeholder {
    color: #999;
}

/* ============================================
   BOTTOM BAR (Quick Replies + Send Button)
   ============================================ */

.mmind-chat-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ============================================
   QUICK REPLY BUTTONS
   ============================================ */

.mmind-quick-replies {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
}

.mmind-quick-reply {
    padding: 8px 18px !important;
    background: #ffffff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 20px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    color: #333 !important;
    line-height: 1.4 !important;
    font-family: inherit !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
}

.mmind-quick-reply:hover {
    background: #6B46C1 !important;
    color: #ffffff !important;
    border-color: #6B46C1 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(107, 70, 193, 0.25);
}

.mmind-quick-reply:active {
    transform: translateY(0);
}

/* ============================================
   SEND BUTTON
   ============================================ */

.mmind-chat-send {
    padding: 10px 22px !important;
    background: #6B46C1 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 24px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    box-shadow: 0 2px 8px rgba(107, 70, 193, 0.3) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    text-decoration: none !important;
    font-family: inherit !important;
    line-height: 1.4 !important;
    flex-shrink: 0;
}

.mmind-chat-send:hover {
    background: #553399 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 70, 193, 0.4) !important;
}

.mmind-chat-send:active {
    transform: translateY(0);
}

.mmind-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    transform: none !important;
}

.mmind-chat-send svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ============================================
   LEGACY INPUT WRAPPER (Shortcode v4 compat)
   ============================================ */

.mmind-chat-input-wrapper {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    align-items: center;
}

.mmind-chat-input-wrapper .mmind-chat-input {
    flex: 1;
}

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

@media (max-width: 768px) {
    .mmind-custom-chat-container {
        border-radius: 12px;
        max-width: 100%;
    }

    .mmind-chat-messages {
        max-height: 50vh;
        padding: 16px;
    }

    .mmind-message-content {
        max-width: 88% !important;
        font-size: 14px;
    }

    .mmind-chat-input-area {
        padding: 12px 16px;
    }

    .mmind-chat-input {
        font-size: 16px; /* Verhindert iOS Zoom */
        padding: 12px 16px;
    }

    .mmind-chat-bottom-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .mmind-quick-replies {
        justify-content: center;
    }

    .mmind-chat-send {
        width: 100%;
        justify-content: center !important;
    }
}

@media (max-width: 480px) {
    .mmind-chat-input-area {
        padding: 10px 12px;
    }

    .mmind-quick-replies {
        gap: 6px;
    }

    .mmind-quick-reply {
        padding: 6px 14px !important;
        font-size: 13px !important;
    }

    .mmind-message-content {
        max-width: 92% !important;
        padding: 10px 14px;
    }
}

/* ============================================
   ELEMENTOR EDITOR PREVIEW
   ============================================ */

.elementor-editor-active .mmind-chat-messages {
    min-height: 120px;
}

.elementor-editor-active .mmind-chat-messages::after {
    content: "Nachrichten erscheinen hier...";
    display: block;
    text-align: center;
    color: #bbb;
    font-size: 14px;
    padding: 40px 0;
    font-style: italic;
}

/* ============================================
   THEME VARIANTEN (optional)
   ============================================ */

/* Lila / Purple Theme */
.mmind-theme-purple .mmind-user-message .mmind-message-content {
    background: linear-gradient(135deg, #6B46C1 0%, #8B5CF6 100%);
}
.mmind-theme-purple .mmind-chat-send {
    background: linear-gradient(135deg, #6B46C1 0%, #8B5CF6 100%) !important;
}
.mmind-theme-purple .mmind-chat-input:focus {
    border-color: #6B46C1;
    box-shadow: 0 0 0 3px rgba(107, 70, 193, 0.1);
}

/* Blau Theme */
.mmind-theme-blue .mmind-user-message .mmind-message-content {
    background: linear-gradient(135deg, #2563EB 0%, #3B82F6 100%);
}
.mmind-theme-blue .mmind-chat-send {
    background: linear-gradient(135deg, #2563EB 0%, #3B82F6 100%) !important;
}
.mmind-theme-blue .mmind-chat-input:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Heller Section-Hintergrund */
.mmind-chat-section-light {
    background: linear-gradient(135deg, #fef5f7 0%, #f9f5ff 100%);
    padding: 60px 20px;
}

/* ============================================
   DARK MODE (optional, falls WordPress dark mode)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .mmind-custom-chat-container {
        /* Nicht automatisch aktivieren - nur wenn gewuenscht
        background: #1a1a2e;
        color: #e0e0e0; */
    }
}

/* ============================================
   GHOST MESSAGES (Easter Egg) – per CSS-Variablen in Elementor ueberschreibbar
   ============================================ */

.mmind-ghost-row {
    --mmind-ghost-fg: #555;
    --mmind-ghost-bg: rgba(107, 70, 193, 0.08);
    --mmind-ghost-border: rgba(107, 70, 193, 0.35);
    --mmind-ghost-accent: #6b46c1;
    margin: 12px 0 4px;
    animation: mmind-ghost-fade-in 0.4s ease forwards;
}

.mmind-ghost-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.mmind-ghost-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--mmind-ghost-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 15px;
    line-height: 1;
}

.mmind-ghost-bubble {
    position: relative;
    background: var(--mmind-ghost-bg);
    border: 1px dashed var(--mmind-ghost-border);
    border-radius: 0 14px 14px 14px;
    padding: 10px 14px;
    font-size: 13.5px;
    font-style: italic;
    color: var(--mmind-ghost-fg);
    line-height: 1.5;
    max-width: 85%;
}

.mmind-ghost-dots {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.mmind-ghost-dots span {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--mmind-ghost-accent);
    opacity: 0.5;
    animation: mmind-ghost-dot 1.2s ease-in-out infinite;
}

.mmind-ghost-dots span:nth-child(2) { animation-delay: 0.2s; }
.mmind-ghost-dots span:nth-child(3) { animation-delay: 0.4s; }

.mmind-ghost-text {
    display: block;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.mmind-ghost-row.mmind-ghost-out {
    animation: mmind-ghost-fade-out 0.4s ease forwards;
}

@keyframes mmind-ghost-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes mmind-ghost-fade-out {
    to { opacity: 0; transform: translateY(4px); }
}

@keyframes mmind-ghost-dot {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

@media print {
    .mmind-ghost-row {
        display: none !important;
    }
}

/* ============================================
   PRINT
   ============================================ */

@media print {
    .mmind-chat-input-area,
    .mmind-chat-bottom-bar,
    .mmind-typing-indicator {
        display: none !important;
    }
    .mmind-chat-messages {
        max-height: none !important;
        overflow: visible !important;
    }
}
