/* ============================================================
   WiseChat Widget — Styles du chat client (PrestaShop)
   Design moderne, responsive, pas de conflit CSS
   ============================================================ */

/* Reset pour eviter les conflits avec le theme PS */
#wisechat-widget,
#wisechat-widget * {
    box-sizing: border-box !important;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif !important;
    -webkit-font-smoothing: antialiased;
}

/* ---- CONTAINER ---- */
.wisechat-container {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
}

.wisechat-container.wisechat-right {
    right: 20px;
}

.wisechat-container.wisechat-left {
    left: 20px;
}

/* ---- BULLE ---- */
.wisechat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.wisechat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.25);
}

.wisechat-bubble:active {
    transform: scale(0.95);
}

.wisechat-bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 10px;
    padding: 0 5px;
    border: 2px solid #fff;
    animation: wisechat-pulse 2s infinite;
}

@keyframes wisechat-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

@keyframes wisechat-bounceIn {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* ---- FENETRE ---- */
.wisechat-window {
    position: absolute;
    bottom: 75px;
    width: 370px;
    max-height: 550px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wisechat-slideUp 0.3s ease;
}

.wisechat-right .wisechat-window {
    right: 0;
}

.wisechat-left .wisechat-window {
    left: 0;
}

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

/* ---- HEADER ---- */
.wisechat-header {
    padding: 16px 20px !important;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.wisechat-header-info {
    flex: 1;
}

.wisechat-header-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.wisechat-header-status {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

.wisechat-header-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    margin-right: 6px;
}

.wisechat-header-close {
    background: rgba(255,255,255,0.15);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.wisechat-header-close:hover {
    background: rgba(255,255,255,0.3);
}

/* ---- STATUS VARIATIONS ---- */
.wisechat-header-status.wisechat-offline::before {
    background: #94a3b8;
}

.wisechat-header-status.wisechat-online::before {
    background: #22c55e;
}

/* ---- NOTICE ---- */
.wisechat-notice {
    background: #fef3c7;
    color: #92400e;
    padding: 10px 20px !important;
    font-size: 12px;
    border-bottom: 1px solid #fde68a;
    line-height: 1.5;
}

.wisechat-notice::before {
    content: '\26A0\FE0F ';
}

/* ---- PRE-CHAT FORM ---- */
.wisechat-prechat {
    padding: 28px 24px !important;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wisechat-prechat-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    text-align: center;
    margin-bottom: 4px;
}

.wisechat-prechat-input {
    padding: 12px 16px !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100% !important;
    height: auto !important;
    background: #fff !important;
    color: #1e293b !important;
}

.wisechat-prechat-input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14,165,233,0.12);
}

.wisechat-prechat-btn {
    padding: 14px !important;
    border: none !important;
    border-radius: 10px !important;
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    width: 100%;
    margin-top: 4px;
}

.wisechat-prechat-btn:hover {
    opacity: 0.9;
}

/* ---- ZONE MESSAGES ---- */
.wisechat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 340px;
    background: #f8fafc;
}

.wisechat-msg {
    display: flex;
    gap: 10px;
    max-width: 82%;
    animation: wisechat-msgIn 0.2s ease;
}

@keyframes wisechat-msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.wisechat-msg-visitor {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.wisechat-msg-other {
    align-self: flex-start;
}

.wisechat-msg-system {
    align-self: center;
    max-width: 90%;
}

.wisechat-msg-system-text {
    background: #f1f5f9;
    color: #8894a5;
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 11px;
    text-align: center;
    border: none;
    line-height: 1.4;
    font-style: italic;
}

.wisechat-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    flex-shrink: 0;
    object-fit: cover;
}

.wisechat-msg-avatar-ai {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.wisechat-msg-content {
    min-width: 0;
    max-width: 100%;
}

.wisechat-msg-name {
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 4px;
    padding-left: 2px;
}

.wisechat-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.wisechat-msg-visitor .wisechat-msg-bubble {
    background: #0ea5e9;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.wisechat-msg-other .wisechat-msg-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.wisechat-msg-time {
    font-size: 9px;
    color: #b0b8c4;
    margin-top: 4px;
    padding-left: 2px;
}

.wisechat-msg-visitor .wisechat-msg-time {
    text-align: right;
    padding-right: 2px;
    padding-left: 0;
}

.wisechat-msg-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-top: 6px;
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

/* ---- TYPING ---- */
.wisechat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 12px;
    color: #64748b;
    background: #f8fafc;
}

.wisechat-typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: wisechat-typingDot 1.4s infinite ease-in-out;
}

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

@keyframes wisechat-typingDot {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ---- INPUT ---- */
.wisechat-input-area {
    padding: 12px 18px !important;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.wisechat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.wisechat-input {
    flex: 1;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 11px 16px !important;
    font-size: 13px !important;
    resize: none;
    outline: none;
    max-height: 80px;
    min-height: 42px;
    line-height: 1.4;
    transition: border-color 0.2s;
    width: 100% !important;
    background: #fff !important;
    color: #1e293b !important;
}

.wisechat-input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
}

.wisechat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}

.wisechat-send-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.wisechat-send-btn:active {
    transform: scale(0.95);
}

/* ---- FOOTER ---- */
.wisechat-footer {
    padding: 8px 18px !important;
    text-align: center;
    font-size: 10px;
    color: #cbd5e1;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}

/* ---- SCROLLBAR ---- */
.wisechat-messages::-webkit-scrollbar {
    width: 5px;
}

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

.wisechat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 480px) {
    .wisechat-window {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 100px);
        bottom: 70px;
    }

    .wisechat-container.wisechat-right {
        right: 10px;
    }

    .wisechat-container.wisechat-left {
        left: 10px;
    }

    .wisechat-bubble {
        width: 54px;
        height: 54px;
    }
}

/* ---- DESIGN ALTERNATIF : BARRE ---- */
.wisechat-bar-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-radius: 24px;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    user-select: none;
}

.wisechat-bar-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22);
}

.wisechat-bar-trigger .wisechat-bar-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.wisechat-bar-trigger .wisechat-bar-status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.wisechat-bar-trigger .wisechat-bar-status-dot.offline {
    background: #94a3b8;
}

.wisechat-bar-trigger .wisechat-bubble-badge {
    position: static;
    border: none;
    margin-left: 4px;
}

/* ---- TRANSLATION NOTICE ---- */
.wisechat-translation-notice {
    font-size: 10px;
    color: #94a3b8;
    font-style: italic;
    margin-top: 2px;
    padding: 0 4px;
}

.wisechat-msg-visitor .wisechat-translation-notice {
    text-align: right;
    color: rgba(255,255,255,0.6);
}

/* ---- AGENT AVATAR IN MSG ---- */
.wisechat-msg-other .wisechat-msg-avatar {
    margin-top: 2px;
}
