/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
    --fp-button-color: #3B81F6;
    --fp-bot-bg: #f0f4ff;
    --fp-user-bg: #3B81F6;
    --fp-bot-text: #1a1a1a;
    --fp-user-text: #ffffff;
    --fp-font-size: 14px;
    --fp-window-height: 520px;
    --fp-window-width: 380px;
    --fp-radius: 12px;
    --fp-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --fp-header-height: 56px;
    --fp-input-height: 64px;
    --fp-z: 99999;
}

/* ─── Bubble Button ─────────────────────────────────────────────────────── */
.fp-bubble-btn {
    position: fixed;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--fp-button-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--fp-shadow);
    z-index: var(--fp-z);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    outline: none;
}

.fp-bubble-btn:hover,
.fp-bubble-btn:focus {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    outline: 3px solid rgba(255, 255, 255, 0.6);
}

.fp-pos-bottom-right.fp-bubble-btn {
    right: 24px;
}

.fp-pos-bottom-left.fp-bubble-btn {
    left: 24px;
}

/* ─── Chat Window ───────────────────────────────────────────────────────── */
.fp-chat-window {
    position: fixed;
    bottom: 92px;
    width: var(--fp-window-width);
    height: var(--fp-window-height);
    background: #ffffff;
    border-radius: var(--fp-radius);
    box-shadow: var(--fp-shadow);
    z-index: var(--fp-z);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: var(--fp-font-size);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.fp-pos-bottom-right.fp-chat-window {
    right: 24px;
}

.fp-pos-bottom-left.fp-chat-window {
    left: 24px;
}

/* Inline mode (shortcode) */
.fp-chat-inline .fp-chat-window {
    position: relative;
    bottom: auto;
    right: auto;
    left: auto;
    width: 100%;
    max-width: var(--fp-window-width);
    margin: 0 auto;
}

.fp-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
}

/* ─── Header ────────────────────────────────────────────────────────────── */
.fp-chat-header {
    background: var(--fp-button-color);
    color: #fff;
    height: var(--fp-header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.fp-chat-title {
    font-weight: 600;
    font-size: 1.05em;
}

.fp-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s;
}

.fp-close-btn:hover,
.fp-close-btn:focus {
    background: rgba(255, 255, 255, 0.2);
    outline: 2px solid rgba(255, 255, 255, 0.5);
}

/* ─── Messages area ─────────────────────────────────────────────────────── */
.fp-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.fp-messages::-webkit-scrollbar {
    width: 4px;
}

.fp-messages::-webkit-scrollbar-track {
    background: transparent;
}

.fp-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* ─── Message ───────────────────────────────────────────────────────────── */
.fp-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.fp-message-bot {
    align-self: flex-start;
    align-items: flex-start;
}

.fp-message-user {
    align-self: flex-end;
    align-items: flex-end;
}

/* Label H5/H6 — accesibil dar vizual discret */
.fp-message-label {
    font-size: 0.75em;
    font-weight: 600;
    color: #888;
    margin: 0 0 4px 4px;
    padding: 0;
    line-height: 1;
    border: none;
    background: none;
}

.fp-message-user .fp-message-label {
    color: #888;
    text-align: right;
    margin: 0 4px 4px 0;
}

/* Bubble */
.fp-message-bubble {
    padding: 10px 14px;
    border-radius: var(--fp-radius);
    line-height: 1.55;
    word-break: break-word;
    overflow-wrap: break-word;
}

.fp-message-bot .fp-message-bubble {
    background: var(--fp-bot-bg);
    color: var(--fp-bot-text);
    border-bottom-left-radius: 4px;
}

.fp-message-user .fp-message-bubble {
    background: var(--fp-user-bg);
    color: var(--fp-user-text);
    border-bottom-right-radius: 4px;
}

.fp-message-bubble code {
    background: rgba(0, 0, 0, 0.08);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: monospace;
}

/* ─── Typing indicator ──────────────────────────────────────────────────── */
.fp-typing .fp-message-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}

.fp-typing .fp-message-bubble span {
    display: block;
    width: 7px;
    height: 7px;
    background: #aab;
    border-radius: 50%;
    animation: fp-bounce 1.2s infinite ease-in-out;
}

.fp-typing .fp-message-bubble span:nth-child(2) {
    animation-delay: 0.2s;
}

.fp-typing .fp-message-bubble span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes fp-bounce {
    0%,
    80%,
    100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* ─── Input area ────────────────────────────────────────────────────────── */
.fp-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    background: #fff;
    box-sizing: border-box;
    width: 100%;
}

.fp-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: var(--fp-font-size);
    font-family: inherit;
    resize: none;
    min-height: 38px;
    max-height: 120px;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.15s;
    min-width: 0;
}

.fp-input:focus {
    border-color: var(--fp-button-color);
    box-shadow: 0 0 0 2px rgba(59, 129, 246, 0.15);
}

.fp-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--fp-button-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
padding:0px;
}

.fp-send-btn:hover {
    filter: brightness(1.1);
}

.fp-send-btn:active {
    transform: scale(0.95);
}

.fp-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── Screen reader only ────────────────────────────────────────────────── */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ─── Admin CSS minimal ─────────────────────────────────────────────────── */
.fp-admin pre {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 4px;
    font-size: 12px;
    border-left: 3px solid #3B81F6;
}

/* ─── Markdown în mesaje ────────────────────────────────────────────────── */
.fp-message-bubble h3,
.fp-message-bubble h4 {
    margin: 8px 0 4px;
    font-size: 1em;
    font-weight: 700;
    line-height: 1.3;
    border: none;
    background: none;
    padding: 0;
}

.fp-message-bubble ul,
.fp-message-bubble ol {
    margin: 6px 0 6px 0;
    padding-left: 20px;
}

.fp-message-bubble li {
    margin-bottom: 3px;
    line-height: 1.5;
}

.fp-message-bubble pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85em;
    margin: 8px 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.fp-message-bubble code {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.88em;
    font-family: 'Consolas', 'Monaco', monospace;
}

.fp-message-bubble pre code {
    background: none;
    padding: 0;
    font-size: 1em;
    color: inherit;
}

.fp-message-bubble a {
    color: var(--fp-button-color);
    text-decoration: underline;
    word-break: break-word;
}

.fp-message-bubble a:hover {
    opacity: 0.8;
}

.fp-message-bubble strong {
    font-weight: 700;
}

.fp-message-bubble em {
    font-style: italic;
}

.fp-message-bubble del {
    text-decoration: line-through;
    opacity: 0.7;
}

/* ─── Responsive Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .fp-chat-window {
        position: fixed !important;
        top: var(--fp-mobile-top, 0px) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important;
        width: 100% !important;
        height: var(--fp-mobile-vh, 100dvh) !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        transform: none !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .fp-chat-window.fp-hidden {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateY(100%) !important;
    }

    .fp-chat-header {
        flex: 0 0 56px;
        min-height: 56px;
        padding: 0 16px;
    }

    .fp-messages {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        padding: 12px 10px;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .fp-message {
        max-width: 82%;
    }

    .fp-message-user {
        margin-right: 8px;
    }

    .fp-message-bubble {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .fp-input-area {
        position: relative !important;
        bottom: auto !important;
        flex: 0 0 auto;
        display: flex;
        align-items: flex-end;
        gap: 8px;
        padding: 10px 12px;
        background: #fff;
        border-top: 1px solid #eee;
        box-sizing: border-box;
        width: 100%;
    }

    .fp-input {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 16px !important;
    }

    .fp-send-btn {
        flex-shrink: 0;
        width: 44px;
        height: 44px;
    }

    .fp-close-btn {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .fp-pos-bottom-right.fp-bubble-btn {
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .fp-pos-bottom-left.fp-bubble-btn {
        left: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}
