/* ============================================================
 * JULIA — Widget Chatbot CSS
 * assets/css/julia-bot.css
 * Couleur Julia : #FF4D67 (Pinkish Red)
 * ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    --julia-red: #B11226;
    --julia-deep: #8b0e1e;
    --julia-gradient: linear-gradient(135deg, #B11226 0%, #8b0e1e 100%);
    --julia-dark: #0f172a;
    --julia-surface: #1e293b;
    --julia-border: rgba(255, 255, 255, 0.08);
    --julia-glow: 0 0 24px rgba(177, 18, 38, 0.35);
    --julia-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    --julia-radius: 20px;
    --julia-msg-radius: 16px;
    --julia-z: 3000;
    --julia-font: 'Poppins', sans-serif;
}

/* ── FAB BUTTON ─────────────────────────────────────────────── */
.julia-fab {
    position: fixed !important;
    bottom: 115px !important;
    left: 20px !important;
    right: auto !important;
    z-index: var(--julia-z) !important;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--julia-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--julia-glow), 0 8px 24px rgba(0, 0, 0, 0.3);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
    animation: julia-fab-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.julia-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 0 32px rgba(177, 18, 38, 0.5), 0 12px 32px rgba(0, 0, 0, 0.35);
}

.julia-fab:active {
    transform: scale(0.95);
}

.julia-fab-text {
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
    transition: opacity 0.2s;
}

.julia-fab-icon {
    width: 30px;
    height: 30px;
    object-fit: contain;
    pointer-events: none;
    transition: opacity 0.2s;
}

.julia-fab-icon-close {
    opacity: 0;
    position: absolute;
    color: #fff;
    font-size: 22px;
}

.julia-fab.open .julia-fab-icon {
    opacity: 0;
}

.julia-fab.open .julia-fab-icon-close {
    opacity: 1;
}

/* Badge non-lu */
.julia-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #fbbf24;
    color: #0f172a;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s, transform 0.2s;
}

.julia-fab-badge.show {
    opacity: 1;
    transform: scale(1);
}

@keyframes julia-fab-in {
    from {
        opacity: 0;
        transform: scale(0) translateY(20px);
    }

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

/* ── PANEL ──────────────────────────────────────────────────── */
.julia-panel {
    position: fixed !important;
    bottom: 185px !important;
    left: 20px !important;
    right: auto !important;
    z-index: var(--julia-z) !important;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 200px);
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--julia-border);
    border-radius: var(--julia-radius);
    box-shadow: var(--julia-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom left;
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.2s ease;
}

.julia-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
    display: flex !important;
    visibility: visible !important;
}

/* ── HEADER ─────────────────────────────────────────────────── */
.julia-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(177, 18, 38, 0.15) 0%, rgba(0, 0, 0, 0) 100%);
    border-bottom: 1px solid var(--julia-border);
    flex-shrink: 0;
}

.julia-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--julia-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(177, 18, 38, 0.4);
}

.julia-avatar-emoji {
    line-height: 1;
    user-select: none;
}

.julia-header-info {
    flex: 1;
    min-width: 0;
}

.julia-header-name {
    font-family: var(--julia-font);
    font-weight: 700;
    font-size: 15px;
    color: #fff;
}

.julia-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #94a3b8;
}

.julia-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
}

.julia-status-dot.thinking {
    background: #fbbf24;
    animation: julia-pulse 2s infinite;
}

@keyframes julia-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5);
    }

    50% {
        box-shadow: 0 0 0 5px rgba(251, 191, 36, 0);
    }
}

.julia-header-clear {
    background: none;
    border: none;
    color: #475569;
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
}

/* ── MESSAGES ───────────────────────────────────────────────── */
.julia-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 14px 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.julia-messages::-webkit-scrollbar {
    width: 4px;
}

.julia-messages::-webkit-scrollbar-thumb {
    background: rgba(177, 18, 38, 0.3);
    border-radius: 4px;
}

.julia-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: julia-msg-in 0.25s ease both;
}

@keyframes julia-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.julia-msg.user-msg {
    flex-direction: row-reverse;
}

.julia-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--julia-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.julia-msg-avatar.user {
    background: rgba(255, 255, 255, 0.1);
}

.julia-msg-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--julia-msg-radius);
    font-family: var(--julia-font);
    font-size: 13px;
    line-height: 1.5;
}

.julia-msg:not(.user-msg) .julia-msg-bubble {
    background: rgba(177, 18, 38, 0.12);
    border: 1px solid rgba(177, 18, 38, 0.2);
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
}

.julia-msg.user-msg .julia-msg-bubble {
    background: var(--julia-gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.julia-msg-time {
    font-size: 9px;
    color: #475569;
    margin-top: 3px;
}

.julia-typing {
    display: flex;
    gap: 8px;
    align-items: center;
}

.julia-typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(177, 18, 38, 0.12);
    border-radius: var(--julia-msg-radius);
    border-bottom-left-radius: 4px;
}

.julia-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #B11226;
    animation: julia-dot 1.4s infinite;
}

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

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

@keyframes julia-dot {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

.julia-welcome-chip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.julia-chip {
    background: rgba(177, 18, 38, 0.1);
    border: 1px solid rgba(177, 18, 38, 0.3);
    color: #B11226;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 11px;
    cursor: pointer;
    transition: 0.2s;
}

.julia-chip:hover {
    background: rgba(177, 18, 38, 0.2);
}

/* ── INPUT ZONE ─────────────────────────────────────────────── */
.julia-input-zone {
    padding: 10px 12px 12px;
    border-top: 1px solid var(--julia-border);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.julia-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.julia-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 10px 14px;
    color: #f1f5f9;
    font-family: var(--julia-font);
    font-size: 13px;
    resize: none;
    max-height: 90px;
    min-height: 42px;
    outline: none;
}

.julia-input::placeholder {
    color: #475569;
}

.julia-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--julia-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(177, 18, 38, 0.4);
}

.julia-footer-label {
    text-align: center;
    font-size: 9px;
    color: #475569;
    margin-top: 7px;
}

.julia-footer-label span {
    color: #B11226;
    font-weight: 600;
}

/* ── DARK OVERLAY (mobile) ──────────────────────────────────── */
.julia-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--julia-z) - 1);
    backdrop-filter: blur(2px);
}

@media (max-width: 480px) {
    .julia-overlay.show {
        display: block;
    }

    .julia-panel {
        bottom: 0px !important;
        left: 0px !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 75vh !important;
        max-height: 75vh !important;
        border-radius: var(--julia-radius) var(--julia-radius) 0 0 !important;
        transform-origin: bottom center;
    }

    .julia-fab {
        bottom: 115px !important;
        left: 15px !important;
        right: auto !important;
    }
}

/* ── ESCALADE BAR (support humain) ─────────────────────────── */
.julia-escalation-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin: 0 12px 8px;
    background: linear-gradient(135deg, rgba(255, 77, 103, 0.12) 0%, rgba(255, 77, 103, 0.06) 100%);
    border: 1px solid rgba(255, 77, 103, 0.25);
    border-radius: 12px;
    font-size: 12px;
    color: #f1f5f9;
    animation: julia-slide-in 0.3s ease-out;
}

.julia-escalation-bar ion-icon {
    font-size: 18px;
    color: #FF4D67;
    flex-shrink: 0;
}

.julia-escalation-bar span {
    flex: 1;
    line-height: 1.4;
}

.julia-escalation-btn {
    background: linear-gradient(135deg, #FF4D67 0%, #cc2a42 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s, transform 0.1s;
    font-family: inherit;
}

.julia-escalation-btn:hover {
    opacity: 0.9;
}

.julia-escalation-btn:active {
    transform: scale(0.96);
}

.julia-escalation-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.julia-escalation-close:hover {
    color: #94a3b8;
}

@keyframes julia-slide-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

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

/* ── BOUTONS D'ACTION (après réponse Julia) ───────────────── */
.julia-action-row {
    margin: 0;
}

.julia-action-btn {
    background: rgba(255, 77, 103, 0.08);
    border: 1px solid rgba(255, 77, 103, 0.25);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #f1f5f9;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.julia-action-btn:hover {
    background: rgba(255, 77, 103, 0.18);
    border-color: rgba(255, 77, 103, 0.5);
    transform: translateY(-1px);
}

.julia-action-btn:active {
    transform: translateY(0);
    background: rgba(255, 77, 103, 0.25);
}

/* ── BULLE PROACTIVE (suggestions contextuelles) ──────────── */
.julia-proactive-bubble {
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: 2999;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px 16px 12px;
    max-width: 320px;
    width: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transform: translateY(16px) scale(0.95);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.julia-proactive-bubble.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.julia-proactive-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.julia-proactive-icon {
    font-size: 16px;
    line-height: 1;
}

.julia-proactive-title {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.julia-proactive-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.2s;
}

.julia-proactive-close:hover {
    color: #f1f5f9;
}

.julia-proactive-body {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.julia-proactive-chip {
    background: rgba(255, 77, 103, 0.08);
    border: 1px solid rgba(255, 77, 103, 0.2);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #f8fafc;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: normal;
    word-break: break-word;
    text-align: left;
    line-height: 1.3;
}

.julia-proactive-chip:hover {
    background: rgba(255, 77, 103, 0.2);
    border-color: rgba(255, 77, 103, 0.5);
    transform: translateY(-1px);
}

.julia-proactive-chip:active {
    transform: translateY(0);
}