/* Public styles for n8n Chat Bot WP - Osmia Labs V3 Fix */

:root {
    --n8n-chatbot-border-radius: 50%;
    --osmia-yellow: #FFD000;
    --osmia-yellow-light: #FFDC33;
    --osmia-dark: #1e293b;
    --osmia-panel: #2c3e50;
    --input-h: 72px;
}

/* --- BASE WIDGET STYLES --- */
.n8n-chatbot-widget {
    position: fixed !important;
    bottom: 20px !important;
    top: auto !important;
    z-index: 999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: visible;
    -webkit-text-size-adjust: 100%;
    pointer-events: none;
}

.n8n-chatbot-widget.position-right {
    right: 20px !important;
    left: auto !important;
}

.n8n-chatbot-widget.position-left {
    left: 20px !important;
    right: auto !important;
}

/* LAUNCHER ICON */
.n8n-chatbot-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--n8n-chatbot-border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    background: #2c3e50;
    /* Fallback */
    color: #ffffff;
}

.n8n-chatbot-widget:not(.open) .n8n-chatbot-icon {
    position: fixed !important;
    bottom: 20px !important;
    z-index: 1000000 !important;
}

.n8n-chatbot-widget:not(.open).position-right .n8n-chatbot-icon {
    right: 20px !important;
}

.n8n-chatbot-widget:not(.open).position-left .n8n-chatbot-icon {
    left: 20px !important;
}

/* Hide launcher when open (built-in logic) */
.n8n-chatbot-widget.open .n8n-chatbot-icon {
    display: none !important;
}

/* ICON HOVER */
.n8n-chatbot-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.n8n-chatbot-icon svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.n8n-chatbot-icon:hover svg {
    transform: scale(1.1);
}

/* CHAT BOX */
.n8n-chatbot-box {
    width: 400px;
    height: min(700px, calc(100vh - 100px));
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    display: none;
    grid-template-rows: auto 1fr auto;
    /* Explicit: Header, Messages, Input (3 children) */
    overflow: hidden;
    box-sizing: border-box;
    margin-bottom: 10px;
    animation: slideUp 0.3s ease-out;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    background: #2c3e50;
    color: #ffffff;
    transition: opacity 0.3s ease, height 0.25s ease;
}

.n8n-chatbot-widget.open .n8n-chatbot-box,
.n8n-chatbot-box.active {
    display: grid;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* HEADER */
.n8n-chatbot-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 56px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: inherit;
}

.n8n-chatbot-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.header-subtitle {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
    margin-top: 2px;
    transition: opacity 0.3s ease;
}

.header-subtitle.fade {
    opacity: 0;
}

/* CONTROLS (Close/Reset) */
.n8n-chatbot-header-right-controls {
    display: flex;
    gap: 8px;
}

.n8n-chatbot-close,
.n8n-chatbot-reset {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.n8n-chatbot-close:hover,
.n8n-chatbot-reset:hover {
    background: rgba(255, 255, 255, 0.1);
}

.n8n-chatbot-reset.rotating {
    animation: spin360 0.5s linear;
}

@keyframes spin360 {
    to {
        transform: rotate(360deg);
    }
}

/* AUDIT PROGRESS BAR */
.audit-progress {
    display: none;
    padding: 0 16px 8px;
    background: inherit;
    z-index: 9;
}

.audit-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--osmia-yellow), var(--osmia-yellow-light));
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

.audit-progress-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    padding: 6px 0 0;
}

/* MESSAGES AREA */
.n8n-chatbot-messages {
    padding: 20px;
    overflow-y: auto;
    display: block;
    scroll-behavior: smooth;
    min-height: 0;
    /* Clean overrides for double bubble prevention */
    background: transparent !important;
}

/* Spacing between items inside messages */
.n8n-chatbot-messages>*+* {
    margin-top: 15px;
}

/* MESSAGE BLOCKS */
.n8n-chatbot-message-block {
    display: flex;
    gap: 8px;
    max-width: 85%;
    background: transparent !important;
    /* Safety for double bubble */
}

/* Osmia theme: full width blocks */
.n8n-chatbot-widget[data-theme="osmia"] .n8n-chatbot-message-block {
    max-width: 100% !important;
    width: 100% !important;
    gap: 0 !important;
}

.n8n-chatbot-message-block.bot {
    align-self: flex-start;
    flex-direction: row;
    align-items: flex-end;
}

.n8n-chatbot-message-block.user {
    align-self: flex-end;
    flex-direction: column;
    align-items: flex-end;
}

/* GENERIC MESSAGE CONTAINER RESET */
.n8n-chatbot-message {
    display: flex;
    flex-direction: column;
    position: relative;
    background: transparent !important;
    /* CRITICAL FIX */
    box-shadow: none !important;
    /* CRITICAL FIX */
    padding: 0 !important;
    margin: 0 !important;
}

/* SHARED MESSAGE BUBBLE */
.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* BOT MESSAGE STYLE */
.n8n-chatbot-message-block.bot .message-content {
    background: rgba(255, 255, 255, 0.08);
    /* Transparent / Glass */
    color: inherit;
    border-bottom-left-radius: 4px;
}

/* AVATAR */
.n8n-chatbot-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.n8n-chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* USER MESSAGE STYLE */
/* Content holds the color */
.n8n-chatbot-message-block.user .message-content {
    background-color: var(--osmia-yellow) !important;
    color: #1a1a2e !important;
    /* Dark text */
    border-bottom-right-radius: 4px;
    /* Ensure no ::after affects us badly */
}

/* Ensure no pseudo-element creates a colored background on the wrapper */
.n8n-chatbot-message::after,
.n8n-chatbot-message::before {
    display: none !important;
}

/* TIME STAMP */
.message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
}

.n8n-chatbot-message-block.user .message-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.7);
}

/* TYPING INDICATOR */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator .text {
    display: none;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--osmia-yellow);
    animation: pulse 1.2s infinite ease-in-out;
}

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

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

@keyframes pulse {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* INTERACTIVE CHOICE BUTTONS (Unified & Fixed) */
.n8n-chatbot-suggestions {
    /* Horizontal scrolling container or wrap */
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 10px;
    width: 100%;
}

/* Specifically target our container */
.n8n-chatbot-suggestions.horizontal-mode {
    flex-direction: row;
    white-space: normal;
    justify-content: flex-start;
    /* Align left */
}

.chat-choice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid rgba(255, 208, 0, 0.4);
    border-radius: 12px;
    /* Rounded Rectangle requested by user */
    background: rgba(255, 208, 0, 0.1);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: normal;
    /* Allow text wrap */
    text-align: center;
    line-height: 1.3;
    max-width: 100%;
    box-sizing: border-box;
    width: auto;
}

.chat-choice-btn:hover {
    background: var(--osmia-yellow);
    color: #1a1a2e;
    border-color: var(--osmia-yellow);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 208, 0, 0.2);
}

.chat-choice-btn.selected {
    background: var(--osmia-yellow);
    color: #1a1a2e;
    border-color: var(--osmia-yellow);
}

.chat-choice-btn.fade-out {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

/* ================================================================= */
/*        OSMIA RICH COMPONENTS — GLASSMORPHISM NATIVE               */
/* ================================================================= */

/* --- BUSINESS CARD (Fiche entreprise) --- */
.osmia-biz-card {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(249, 231, 30, 0.25);
    border-radius: 16px;
    padding: 16px 14px;
    margin: 8px 0;
    overflow: hidden;
    position: relative;
    animation: osmia-card-in 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.osmia-biz-card::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 120px; height: 120px;
    background: radial-gradient(circle, rgba(249, 231, 30, 0.12) 0%, transparent 70%);
    pointer-events: none;
}
.osmia-biz-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(249, 231, 30, 0.15);
}
.osmia-biz-header span {
    font-weight: 600;
    font-size: 15px;
    color: #fff;
    letter-spacing: 0.01em;
}
.osmia-biz-header .osmia-biz-icon {
    color: #f9e71e;
    font-size: 14px;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(249, 231, 30, 0.12);
    border-radius: 8px;
    flex-shrink: 0;
}
.osmia-biz-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    font-size: 13px;
    color: rgba(248, 250, 252, 0.85);
}
.osmia-biz-row .osmia-biz-icon {
    color: rgba(249, 231, 30, 0.7);
    font-size: 11px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}
.osmia-biz-row.osmia-biz-highlight {
    color: #f9e71e;
    font-weight: 500;
}
.osmia-biz-row.osmia-biz-highlight .osmia-biz-icon {
    color: #f9e71e;
}

/* --- REVELATION CARD (Phase transitions) --- */
.osmia-revelation {
    background: linear-gradient(135deg, rgba(249, 231, 30, 0.08), rgba(249, 231, 30, 0.03));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(249, 231, 30, 0.2);
    border-radius: 14px;
    padding: 14px 16px;
    margin: 10px 0;
    position: relative;
    overflow: hidden;
    animation: osmia-card-in 0.4s ease forwards;
}
.osmia-revelation::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(249, 231, 30, 0.4), transparent);
}
.osmia-rev-status {
    font-weight: 600;
    font-size: 13px;
    color: #fff;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.osmia-rev-status i {
    color: #22c55e;
    font-size: 12px;
}
.osmia-rev-teaser {
    font-size: 12px;
    color: rgba(249, 231, 30, 0.9);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.osmia-rev-teaser i {
    color: rgba(249, 231, 30, 0.7);
    font-size: 11px;
}
.osmia-rev-progress {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}
.osmia-rev-line {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    margin: 2px 0;
}

/* --- PHASE PROGRESS INDICATOR --- */
.osmia-phase-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
}
.osmia-phase-dots {
    display: flex;
    gap: 5px;
}
.osmia-phase-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    transition: all 0.3s ease;
}
.osmia-phase-dot.filled {
    background: linear-gradient(135deg, #f9e71e, #f59e0b);
    box-shadow: 0 0 8px rgba(249, 231, 30, 0.4);
}
.osmia-phase-dot.empty {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.osmia-phase-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}
.osmia-phase-label i {
    color: #22c55e;
    margin-right: 2px;
}

/* --- SCORES DASHBOARD --- */
.osmia-scores-dashboard {
    padding: 8px 0;
    width: 100%;
}
.osmia-score-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    opacity: 0;
    transform: translateX(-10px);
    animation: osmia-score-in 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.osmia-score-row:nth-child(1) { animation-delay: 0.1s; }
.osmia-score-row:nth-child(2) { animation-delay: 0.25s; }
.osmia-score-row:nth-child(3) { animation-delay: 0.4s; }
.osmia-score-row:nth-child(4) { animation-delay: 0.55s; }
.osmia-score-row:nth-child(5) { animation-delay: 0.7s; }

.osmia-score-icon {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(249, 231, 30, 0.08);
    border: 1px solid rgba(249, 231, 30, 0.15);
    border-radius: 8px;
    flex-shrink: 0;
}
.osmia-score-icon i {
    font-size: 12px;
    color: rgba(249, 231, 30, 0.8);
}
.osmia-score-info {
    flex: 1;
    min-width: 0;
}
.osmia-score-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.osmia-score-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}
.osmia-score-fill {
    height: 100%;
    border-radius: 3px;
    width: 0;
    transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
}
.osmia-score-fill::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
    animation: osmia-shimmer 2s ease-in-out infinite;
    animation-delay: 1.5s;
}
.osmia-score-val {
    font-size: 13px;
    font-weight: 700;
    min-width: 42px;
    text-align: right;
    flex-shrink: 0;
}

/* --- SCORE HERO (Global score) --- */
.osmia-score-hero {
    text-align: center;
    margin: 16px 0;
    padding: 20px 16px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(249, 231, 30, 0.2);
    border-radius: 16px;
    opacity: 0;
    animation: osmia-card-in 0.6s ease forwards;
    animation-delay: 0.9s;
    position: relative;
    overflow: hidden;
}
.osmia-score-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 30%, rgba(249, 231, 30, 0.08) 0%, transparent 60%);
    pointer-events: none;
}
.osmia-score-hero-ring {
    width: 90px; height: 90px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: conic-gradient(var(--score-color) 0deg, var(--score-color) var(--score-pct), rgba(255,255,255,0.08) var(--score-pct));
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.osmia-score-hero-ring::before {
    content: '';
    width: 70px; height: 70px;
    border-radius: 50%;
    background: #0f172a;
    position: absolute;
}
.osmia-score-hero-val {
    position: relative;
    z-index: 1;
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}
.osmia-score-hero-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.osmia-score-hero-label i {
    color: rgba(249, 231, 30, 0.7);
    margin-right: 4px;
}

/* --- SEPARATOR --- */
.osmia-separator {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(249, 231, 30, 0.25), transparent);
    margin: 12px 0;
}

/* --- ANIMATIONS --- */
@keyframes osmia-card-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes osmia-score-in {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes osmia-shimmer {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* CONFETTI */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 50;
}

.confetti-particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation: confetti-fall 2.5s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(-20px) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: translateY(400px) rotate(720deg);
    }
}

/* INPUT AREA */
.n8n-chatbot-input-area {
    padding: 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: inherit;
}

.n8n-chatbot-form {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.n8n-chatbot-form input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.n8n-chatbot-form input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.n8n-chatbot-form button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.n8n-chatbot-form button:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
}

.n8n-chatbot-form button svg {
    width: 20px;
    height: 20px;
    fill: var(--osmia-yellow);
}

/* MOBILE / RESPONSIVE */
@media (max-width: 480px) {
    .n8n-chatbot-box {
        width: 100% !important;
        height: 100% !important;
        position: fixed !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
        margin: 0 !important;
        max-height: 100vh !important;
    }

    .n8n-chatbot-widget {
        z-index: 1000000 !important;
    }
}

/* DARK THEME SPECIFICS (Already applied by base classes, but enforcing) */
.n8n-chatbot-widget.theme-dark .n8n-chatbot-box {
    background: #1e293b;
    color: #fff;
}