/**
 * Style officiel du Widget de Chat Front-end Je Travel
 * Conforme au Brand Book officiel Je Travel (v5.0)
 */

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

/* --- STRUCTURE PRINCIPALE --- */
#jt-support-chat-root {
    --jt-blue: #1CA3DD;
    --jt-blue-hover: #1276A8;
    --jt-blue-pale: #E3F6FD;
    --jt-yellow: #F8B400;
    --jt-yellow-pale: #FEF6DC;
    --jt-red: #E63946;
    --jt-red-pale: #FEF0F1;
    --jt-navy: #0B2545;
    --jt-gray-bg: #F5F7FA;
    --jt-gray-text: #333333;
    --jt-gray-muted: #64748B;
    --jt-white: #FFFFFF;
    --jt-border: #E2E8F0;
    --jt-whatsapp: #25D366;

    font-family: 'Poppins', 'Trebuchet MS', Arial, sans-serif;
    color: var(--jt-gray-text);
    z-index: 999999;
}

#jt-support-chat-root .jt-hidden {
    display: none !important;
}

/* --- BULLE FLOTTANTE (TRIGGER) --- */
.jt-chat-bubble {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--jt-blue);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(28, 163, 221, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 999999;
}

.jt-chat-bubble:hover {
    background-color: var(--jt-blue-hover);
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(18, 118, 168, 0.55);
}

.jt-chat-icon {
    font-size: 26px;
    color: var(--jt-white);
    line-height: 1;
}

/* --- PANNEAU DE DISCUSSION (WINDOW) --- */
.jt-chat-window {
    position: fixed;
    bottom: 95px;
    right: 25px;
    width: 375px;
    height: 560px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 120px);
    border-radius: 16px;
    background-color: var(--jt-white);
    box-shadow: 0 10px 35px rgba(11, 37, 69, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: jtSlideIn 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 999999;
    border: 1px solid var(--jt-border);
}

/* Positionnement à gauche (si activé dans les réglages) */
#jt-support-chat-root.jt-pos-left .jt-chat-bubble {
    right: auto;
    left: 25px;
}

#jt-support-chat-root.jt-pos-left .jt-chat-window {
    right: auto;
    left: 25px;
}

@keyframes jtSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- EN-TÊTE (HEADER) --- */
.jt-chat-header {
    background-color: var(--jt-navy);
    color: var(--jt-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--jt-blue);
    flex-shrink: 0;
}

.jt-chat-title-group {
    display: flex;
    flex-direction: column;
}

.jt-chat-title {
    font-family: 'Montserrat', 'Trebuchet MS', Arial, sans-serif;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.3px;
    color: var(--jt-white);
}

.jt-chat-status {
    font-size: 11px;
    color: var(--jt-blue-pale);
    margin-top: 3px;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 6px;
}

.jt-chat-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #2EC4B6;
}

/* Statuts d'escalade */
.jt-chat-status.jt-status-escalated {
    color: #FFD1D5;
}

.jt-chat-status.jt-status-escalated::before {
    background-color: var(--jt-red);
    box-shadow: 0 0 6px var(--jt-red);
    animation: jtPulse 1.5s infinite;
}

@keyframes jtPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.jt-chat-close-btn {
    background: none;
    border: none;
    color: var(--jt-white);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.jt-chat-close-btn:hover {
    opacity: 1;
}

/* --- CARTE CAPTURE D'IDENTITÉ INVITÉ (Brand Book v5.0) --- */
.jt-chat-guest-card {
    background: var(--jt-blue-pale);
    border-bottom: 1px solid rgba(28, 163, 221, 0.3);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    animation: jtFadeIn 0.25s ease-out;
}

@keyframes jtFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.jt-guest-card-header {
    font-family: 'Montserrat', sans-serif;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--jt-navy);
}

.jt-guest-card-text {
    font-size: 11.5px;
    color: var(--jt-gray-text);
    margin: 0;
    line-height: 1.35;
}

.jt-guest-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 2px;
}

.jt-guest-fields input {
    border: 1px solid var(--jt-border);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 12px;
    font-family: 'Poppins', sans-serif;
    outline: none;
    background: var(--jt-white);
}

.jt-guest-fields input:focus {
    border-color: var(--jt-blue);
    box-shadow: 0 0 0 1px var(--jt-blue);
}

.jt-guest-btn {
    background-color: var(--jt-yellow) !important;
    color: var(--jt-navy) !important;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.jt-guest-btn:hover {
    background-color: #E0A300 !important;
}

/* --- QUICK REPLIES (BOUTONS D'ACTION RAPIDE) --- */
.jt-chat-quick-replies {
    background: var(--jt-white);
    padding: 8px 12px;
    border-bottom: 1px solid var(--jt-border);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

.jt-quick-btn {
    background: var(--jt-gray-bg);
    border: 1px solid var(--jt-border);
    color: var(--jt-navy);
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex: 1 1 auto;
}

.jt-quick-btn:hover {
    background: var(--jt-blue-pale);
    border-color: var(--jt-blue);
    color: var(--jt-blue-hover);
}

.jt-quick-btn-wa {
    background: #E8F9EE;
    border-color: #B5EAC5;
    color: #128C7E;
    flex: 1 1 100%;
}

.jt-quick-btn-wa:hover {
    background: #D4F4DF;
    color: #075E54;
}

/* --- ZONE DE MESSAGES --- */
.jt-chat-messages {
    flex: 1;
    padding: 16px;
    background-color: var(--jt-gray-bg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jt-chat-loading {
    text-align: center;
    color: var(--jt-gray-muted);
    font-size: 12.5px;
    margin-top: 15px;
}

/* --- BULLES DE MESSAGE --- */
.jt-message-container {
    display: flex;
    flex-direction: column;
    max-width: 86%;
}

.jt-align-right {
    align-self: flex-end;
}

.jt-align-left {
    align-self: flex-start;
}

.jt-message-label {
    font-size: 10px;
    color: var(--jt-gray-muted);
    margin-bottom: 3px;
    padding-left: 6px;
    font-weight: 600;
}

.jt-message-bubble {
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* Message Utilisateur */
.jt-message-user {
    background-color: var(--jt-blue-pale);
    color: var(--jt-gray-text);
    border-radius: 14px 14px 0 14px;
    border: 1px solid rgba(28, 163, 221, 0.2);
}

/* Message IA */
.jt-message-ai {
    background-color: var(--jt-white);
    color: var(--jt-gray-text);
    border-radius: 14px 14px 14px 0;
    border: 1px solid var(--jt-border);
}

/* Message Agent Humain */
.jt-message-agent {
    background-color: var(--jt-yellow-pale);
    color: var(--jt-gray-text);
    border-radius: 14px 14px 14px 0;
    border: 1px solid rgba(248, 180, 0, 0.3);
}

.jt-message-text {
    word-break: break-word;
}

/* Encart d'action WhatsApp dans le message */
.jt-message-whatsapp-cta {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.jt-btn-inchat-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: var(--jt-whatsapp);
    color: var(--jt-white) !important;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(37, 211, 102, 0.3);
    transition: background-color 0.15s ease;
}

.jt-btn-inchat-whatsapp:hover {
    background-color: #1EBE5D;
}

/* --- PIED DE PAGE & SAISIE --- */
.jt-chat-footer {
    background-color: var(--jt-white);
    padding: 12px 16px;
    border-top: 1px solid var(--jt-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

/* Bouton Escalade */
.jt-chat-escalate-btn {
    width: 100%;
    background-color: var(--jt-blue);
    color: var(--jt-white);
    border: none;
    padding: 8px;
    font-family: 'Montserrat', 'Trebuchet MS', Arial, sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.jt-chat-escalate-btn:hover {
    background-color: var(--jt-blue-hover);
}

.jt-chat-escalate-btn:disabled,
.jt-chat-escalate-btn.jt-escalated-active {
    background-color: var(--jt-gray-bg) !important;
    color: var(--jt-gray-muted) !important;
    border: 1px solid var(--jt-border) !important;
    cursor: not-allowed;
}

/* Zone d'écriture */
.jt-chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--jt-gray-bg);
    border: 1px solid var(--jt-border);
    border-radius: 20px;
    padding: 4px 8px 4px 14px;
}

.jt-chat-input-row:focus-within {
    border-color: var(--jt-blue);
    background-color: var(--jt-white);
    box-shadow: 0 0 0 1px var(--jt-blue);
}

#jt-chat-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    resize: none;
    max-height: 70px;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    padding: 4px 0;
    color: var(--jt-gray-text);
    line-height: 1.35;
}

#jt-chat-input::placeholder {
    color: var(--jt-gray-muted);
}

/* Bouton Envoyer (Jaune contrasté avec Bleu Marine) */
.jt-chat-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--jt-yellow);
    color: var(--jt-navy); /* Règle impérative: texte/icône marine sur fond jaune */
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.jt-chat-send-btn:hover {
    background-color: #E0A300;
    transform: scale(1.05);
}

.jt-chat-send-btn:active {
    transform: scale(0.92);
}

/* Erreurs de session */
.jt-chat-error {
    background-color: var(--jt-red-pale);
    color: var(--jt-red);
    border: 1px solid rgba(230, 57, 70, 0.3);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    text-align: center;
    font-weight: 500;
}

/* --- SCROLLBAR CUSTOM --- */
.jt-chat-messages::-webkit-scrollbar,
.jt-chat-quick-replies::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.jt-chat-messages::-webkit-scrollbar-track,
.jt-chat-quick-replies::-webkit-scrollbar-track {
    background: transparent;
}

.jt-chat-messages::-webkit-scrollbar-thumb,
.jt-chat-quick-replies::-webkit-scrollbar-thumb {
    background: rgba(11, 37, 69, 0.15);
    border-radius: 3px;
}

/* --- ADAPTATION MOBILE --- */
@media screen and (max-width: 480px) {
    .jt-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
    
    .jt-chat-bubble {
        bottom: 20px;
        right: 20px;
    }
}
