/* ==========================================================================
   MARIE — AI CHATBOT SKIN v2 — "THE MARIE TAB"
   PFCA Standard · Kinshasa Golden Hour palette
   Terracotta #C04000 · Gold #FFB347 · Charcoal #1A1A1A · Cream #FAF0E6
   Design: unmissable right-edge tab + premium chat window.
   Targets the exact DOM built by js/marie-chatbot.js
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. TRIGGER — "THE MARIE TAB" (right edge, vertically upper-middle)
   -------------------------------------------------------------------------- */
.chat-trigger {
    position: fixed;
    top: 42%;
    right: 0;
    z-index: 999990;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: linear-gradient(135deg, #C04000 0%, #8A2E00 100%);
    color: #FFFFFF;
    border: none;
    border-left: 3px solid #FFB347;
    border-radius: 60px 0 0 60px;
    padding: 1.15rem 1.5rem 1.15rem 1.35rem;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: -8px 10px 34px rgba(192, 64, 0, 0.45);
    transition: padding 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
    animation: marieTabIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) 1.5s backwards;
    /* armor against any stale rules: never let this stretch */
    bottom: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
}

.chat-trigger-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}

@keyframes marieTabIn {
    from { transform: translateX(110%); }
    to   { transform: translateX(0); }
}

.chat-trigger:hover {
    padding-right: 2.1rem;
    box-shadow: -12px 16px 44px rgba(192, 64, 0, 0.55);
}

.chat-trigger-icon {
    font-size: 1.5rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.chat-trigger-text {
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Gold breathing pulse ring */
.chat-trigger-pulse {
    position: absolute;
    inset: -5px;
    border-radius: 60px 0 0 60px;
    border: 2px solid rgba(255, 179, 71, 0.75);
    animation: mariePulse 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes mariePulse {
    0%   { transform: scale(1);    opacity: 0.9; }
    70%  { transform: scale(1.12); opacity: 0; }
    100% { transform: scale(1.12); opacity: 0; }
}

.chat-unread-badge {
    display: none;
    position: absolute;
    top: -8px;
    left: -8px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: #FFB347;
    color: #1A1A1A;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    animation: marieBadgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes marieBadgePop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

.chat-unread-badge:empty,
.chat-unread-badge[data-count="0"] {
    display: none;
}


/* --------------------------------------------------------------------------
   2. CHAT WINDOW — premium panel, bottom-right, slides up on open
   -------------------------------------------------------------------------- */
.chat-window {
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 2147483000;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 610px;
    max-height: calc(100vh - 60px);
    background: #FAF0E6;
    border-radius: 22px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 179, 71, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0) scale(1);
    transform-origin: bottom right;
    transition: opacity 0.32s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.32s;
}

.chat-window[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.chat-window[aria-hidden="true"] {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
    visibility: hidden;
    pointer-events: none;
}


/* --------------------------------------------------------------------------
   3. HEADER — charcoal band, gold name, status dot
   -------------------------------------------------------------------------- */
.chat-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: linear-gradient(135deg, #1A1A1A 0%, #2A2020 100%);
    padding: 1.05rem 1.15rem;
    border-bottom: 2px solid rgba(255, 179, 71, 0.4);
    flex-shrink: 0;
}

.chat-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #C04000, #8A2E00);
    border-radius: 50%;
    font-size: 1.6rem;
    border: 2px solid rgba(255, 179, 71, 0.6);
    box-shadow: 0 4px 12px rgba(192, 64, 0, 0.4);
}

.chat-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #3ECF6A;
    border: 2px solid #1A1A1A;
    border-radius: 50%;
}

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

.chat-name {
    margin: 0;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #FFB347;
    line-height: 1.1;
}

.chat-status {
    font-size: 0.74rem;
    color: rgba(250, 240, 230, 0.65);
    letter-spacing: 0.03em;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-lang-toggle {
    display: flex;
    border: 1px solid rgba(255, 179, 71, 0.45);
    border-radius: 30px;
    overflow: hidden;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

.chat-lang-toggle span {
    padding: 0.3rem 0.62rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: rgba(250, 240, 230, 0.6);
    transition: all 0.2s ease;
}

.chat-lang-toggle span.active,
.chat-lang-toggle span:first-child {
    background: #C04000;
    color: #FFFFFF;
}

.chat-close {
    background: transparent;
    border: none;
    color: rgba(250, 240, 230, 0.7);
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.chat-close:hover {
    color: #FFB347;
    transform: scale(1.15) rotate(90deg);
}


/* --------------------------------------------------------------------------
   4. MESSAGES AREA
   -------------------------------------------------------------------------- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.15rem 1.05rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background:
        radial-gradient(circle at 85% 8%, rgba(255, 179, 71, 0.1), transparent 45%),
        #FAF0E6;
    scrollbar-width: thin;
    scrollbar-color: rgba(192, 64, 0, 0.35) transparent;
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(192, 64, 0, 0.3);
    border-radius: 10px;
}

.chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: 88%;
    animation: marieMsgIn 0.3s ease;
}

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

.chat-msg.msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg.msg-assistant {
    align-self: flex-start;
}

.msg-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #C04000, #8A2E00);
    border-radius: 50%;
    font-size: 1.05rem;
}

.msg-bubble {
    padding: 0.7rem 0.9rem;
    border-radius: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.55;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.msg-assistant .msg-bubble {
    background: #FFFFFF;
    color: #1A1A1A;
    border-bottom-left-radius: 4px;
}

.msg-user .msg-bubble {
    background: linear-gradient(135deg, #C04000, #A03000);
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
}

.msg-text { display: block; }

.msg-time {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.62rem;
    opacity: 0.55;
    letter-spacing: 0.02em;
}


/* --------------------------------------------------------------------------
   5. TYPING INDICATOR — three dancing terracotta dots
   -------------------------------------------------------------------------- */
#chat-typing,
.chat-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.2rem;
}

#chat-typing .dot,
.chat-typing .dot,
#chat-typing span,
.chat-typing span {
    width: 7px;
    height: 7px;
    background: #C04000;
    border-radius: 50%;
    animation: marieDot 1.2s ease-in-out infinite;
}

#chat-typing span:nth-child(2), .chat-typing span:nth-child(2) { animation-delay: 0.15s; }
#chat-typing span:nth-child(3), .chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes marieDot {
    0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
    30%           { transform: translateY(-5px); opacity: 1; }
}


/* --------------------------------------------------------------------------
   6. QUICK REPLIES — pill row
   -------------------------------------------------------------------------- */
.chat-quick-replies {
    display: flex;
    gap: 0.45rem;
    padding: 0.65rem 0.95rem;
    overflow-x: auto;
    flex-shrink: 0;
    background: rgba(250, 240, 230, 0.9);
    border-top: 1px solid rgba(192, 64, 0, 0.12);
    scrollbar-width: none;
}

.chat-quick-replies::-webkit-scrollbar { display: none; }
.chat-quick-replies:empty { display: none; }

.chat-quick-btn {
    flex-shrink: 0;
    appearance: none;
    background: #FFFFFF;
    border: 1px solid rgba(192, 64, 0, 0.4);
    color: #C04000;
    border-radius: 40px;
    padding: 0.45rem 0.95rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chat-quick-btn:hover {
    background: #C04000;
    color: #FFFFFF;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(192, 64, 0, 0.3);
}


/* --------------------------------------------------------------------------
   7. FOOTER — input + send
   -------------------------------------------------------------------------- */
.chat-footer {
    flex-shrink: 0;
    background: #FFFFFF;
    border-top: 1px solid rgba(192, 64, 0, 0.15);
    padding: 0.8rem 0.95rem;
}

.chat-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.chat-input {
    flex: 1;
    border: 1px solid rgba(26, 26, 26, 0.15);
    background: #FAF0E6;
    border-radius: 40px;
    padding: 0.7rem 1.05rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: #1A1A1A;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input:focus {
    border-color: #C04000;
    box-shadow: 0 0 0 3px rgba(192, 64, 0, 0.12);
}

.chat-send {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #C04000, #A03000);
    color: #FFFFFF;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-send:hover {
    transform: scale(1.1) rotate(-8deg);
    box-shadow: 0 6px 16px rgba(192, 64, 0, 0.45);
}

.chat-send svg {
    width: 19px;
    height: 19px;
    display: block;
}

.chat-send svg line,
.chat-send svg polygon {
    stroke: #FFFFFF;
    fill: none;
}

.chat-send svg polygon {
    fill: #FFFFFF;
}


/* --------------------------------------------------------------------------
   8. WHATSAPP ESCALATION
   -------------------------------------------------------------------------- */
.chat-whatsapp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
    width: 100%;
    padding: 0.6rem;
    background: rgba(34, 139, 34, 0.08);
    color: #1A6B1A;
    border: 1px solid rgba(34, 139, 34, 0.3);
    border-radius: 40px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-whatsapp-btn:hover {
    background: #1A6B1A;
    color: #FFFFFF;
}


/* --------------------------------------------------------------------------
   9. MOBILE — tab becomes corner circle, window becomes bottom sheet
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
    .chat-trigger {
        top: auto;
        bottom: 18px;
        right: 18px;
        border-radius: 50%;
        border-left: none;
        padding: 1rem;
        box-shadow: 0 10px 30px rgba(192, 64, 0, 0.45);
    }
    .chat-trigger:hover { padding-right: 1rem; }
    .chat-trigger-text { display: none; }
    .chat-trigger-icon { font-size: 1.55rem; }
    .chat-trigger-pulse { border-radius: 50%; }

    .chat-window {
        right: 8px;
        left: 8px;
        bottom: 8px;
        width: auto;
        max-width: none;
        height: 72vh;
        border-radius: 20px;
    }
}
