/**
 * MPM Chatbot - Widget Styles
 * Modern Glass Design
 * Prefix: pcb- (plugin-chatbot)
 */

/* CSS Variables */
:root {
    --pcb-primary: #0073aa;
    --pcb-primary-dark: #005a87;
    --pcb-primary-light: #e6f3f9;
    --pcb-text: #1d2327;
    --pcb-text-light: #646970;
    --pcb-bg: #ffffff;
    --pcb-border: #dcdcde;
    --pcb-shadow: rgba(0, 0, 0, 0.15);
    --pcb-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --pcb-font-size: 14px;
    --pcb-font-color: #1d2327;
}

/* Container */
.pcb-widget {
    position: fixed;
    z-index: 999999;
    font-family: var(--pcb-font-family);
    font-size: var(--pcb-font-size);
    line-height: 1.5;
}

.pcb-widget.position-bottom-right {
    bottom: 1rem;
    right: 1rem;
}

.pcb-widget.position-bottom-left {
    bottom: 1rem;
    left: 1rem;
}

/* Inline-Modus (Shortcode) */
.pcb-widget.position-inline {
    position: relative;
    bottom: auto;
    right: auto;
    left: auto;
}

.pcb-widget.position-inline .pcb-trigger {
    display: none;
}

.pcb-widget.position-inline .pcb-window {
    position: relative;
    display: block;
    width: 100%;
    max-width: 500px;
    height: 500px;
    margin: 0 auto;
    transform: none;
    opacity: 1;
    pointer-events: all;
}

/* Trigger Button (Pill) */
.pcb-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--pcb-primary);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--pcb-shadow);
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.pcb-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--pcb-shadow);
    background: var(--pcb-primary-dark);
}

.pcb-trigger:active {
    transform: translateY(0);
}

.pcb-trigger svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    stroke: currentColor;
}

.pcb-online-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pcb-pulse 2s infinite;
}

@keyframes pcb-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Window */
.pcb-window {
    position: fixed;
    bottom: 1rem;
    width: 380px;
    height: 520px;
    background: var(--pcb-bg);
    border-radius: 16px;
    box-shadow: 0 10px 40px var(--pcb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.position-bottom-right .pcb-window {
    right: 1rem;
}

.position-bottom-left .pcb-window {
    left: 1rem;
}

.pcb-widget.open .pcb-window {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

.pcb-widget.open .pcb-trigger {
    display: none;
}

/* Header */
.pcb-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--pcb-primary);
    color: #fff;
    flex-shrink: 0;
}

/* Body Container */
.pcb-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.pcb-topbar-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pcb-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pcb-avatar svg {
    width: 24px;
    height: 24px;
    fill: #fff;
    stroke: #fff;
}

.pcb-topbar-text h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

.pcb-topbar-text span {
    font-size: 12px;
    opacity: 0.9;
}

.pcb-topbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.pcb-action-clear,
.pcb-action-close {
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
}

.pcb-action-clear:hover,
.pcb-action-close:hover {
    opacity: 1;
    transform: scale(1.2);
}

.pcb-action-clear svg,
.pcb-action-close svg {
    width: 24px;
    height: 24px;
    stroke: #fff;
}

/* Messages Container */
.pcb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8f9fa;
    min-height: 0;
}

/* Scrollbar */
.pcb-messages::-webkit-scrollbar {
    width: 6px;
}

.pcb-messages::-webkit-scrollbar-track {
    background: transparent;
}

.pcb-messages::-webkit-scrollbar-thumb {
    background: var(--pcb-border);
    border-radius: 3px;
}

/* Message Bubble */
.pcb-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: pcb-message-in 0.3s ease;
}

@keyframes pcb-message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pcb-message.bot {
    align-self: flex-start;
}

.pcb-message.user {
    align-self: flex-end;
}

.pcb-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
}

.pcb-message.bot .pcb-bubble {
    background: var(--pcb-bg);
    color: var(--pcb-font-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.pcb-message.user .pcb-bubble {
    background: var(--pcb-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.pcb-meta {
    font-size: 11px;
    color: var(--pcb-text-light);
    margin-top: 4px;
    padding: 0 4px;
}

.pcb-message.user .pcb-meta {
    text-align: right;
}

/* Typing Indicator */
.pcb-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--pcb-bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.pcb-typing span {
    width: 8px;
    height: 8px;
    background: var(--pcb-text-light);
    border-radius: 50%;
    animation: pcb-typing 1.4s infinite;
}

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

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

@keyframes pcb-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Input Area */
.pcb-input-area {
    padding: 16px 20px;
    background: var(--pcb-bg);
    border-top: 1px solid var(--pcb-border);
    flex-shrink: 0;
}

.pcb-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.pcb-input {
    flex: 1;
    border: 1px solid var(--pcb-border);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    line-height: 1.4;
    font-family: inherit;
}

.pcb-input:focus {
    border-color: var(--pcb-primary);
    box-shadow: 0 0 0 3px var(--pcb-primary-light);
}

.pcb-input::placeholder {
    color: var(--pcb-text-light);
}

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

.pcb-btn-send:hover:not(:disabled) {
    background: var(--pcb-primary-dark);
    transform: scale(1.05);
}

.pcb-btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pcb-btn-send svg {
    width: 20px;
    height: 20px;
    fill: #fff;
    stroke: #fff;
}

/* GDPR Consent */
.pcb-gdpr {
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
}

.pcb-gdpr p {
    margin: 0;
    color: var(--pcb-text-light);
    font-size: 13px;
}

.pcb-gdpr-btn {
    background: var(--pcb-primary);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.pcb-gdpr-btn:hover {
    background: var(--pcb-primary-dark);
}

/* Sources */
.pcb-sources {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--pcb-border);
    font-size: 12px;
}

.pcb-sources-title {
    color: var(--pcb-text-light);
    margin-bottom: 6px;
}

.pcb-sources a {
    color: var(--pcb-primary);
    text-decoration: none;
    display: block;
    padding: 2px 0;
}

.pcb-sources a:hover {
    text-decoration: underline;
}

/* Error State */
.pcb-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .pcb-widget:not(.position-inline) .pcb-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .pcb-trigger {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Markdown-like formatting in messages */
.pcb-bubble p {
    margin: 0 0 8px 0;
}

.pcb-bubble p:last-child {
    margin-bottom: 0;
}

.pcb-bubble ul,
.pcb-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.pcb-bubble li {
    margin: 4px 0;
}

.pcb-bubble strong {
    font-weight: 600;
}

.pcb-bubble a {
    color: inherit;
    text-decoration: underline;
}

.pcb-message.user .pcb-bubble a {
    color: #fff;
}

.pcb-message.bot .pcb-bubble a {
    color: var(--pcb-primary);
}
