/* ==========================================================================
   Widget Chatbot — Hôtel Idou Anfa  |  Design Luxury Moderne
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=DM+Sans:wght@300;400;500&display=swap');

#iac-chat-widget {
    --gold: #b7995d;
    --gold-dark: #927b52;
    --gold-light: #d4b87a;
    --gold-glow: rgba(183, 153, 93, 0.35);
    --dark: #1e1a14;
    --dark-2: #2d2519;
    --bg: #f8f6f1;
    --white: #ffffff;
    --text: #2d2519;
    --text-soft: #8a7a62;
    --font-title: 'Cormorant Garamond', Georgia, serif;
    --font-ui: 'DM Sans', system-ui, sans-serif;
    font-family: var(--font-ui);
}

/* ── Bouton flottant ──────────────────────────────────────────────── */
#iac-chat-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(145deg, var(--gold-light), var(--gold-dark));
    color: #fff;
    font-size: 20px;
    box-shadow: 0 4px 20px var(--gold-glow), 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(.34, 1.56, .64, 1), box-shadow 0.2s;
}

#iac-chat-toggle::before {
    content: '';
    position: absolute;
    inset: -7px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    opacity: 0;
    animation: iac-pulse-ring 2.8s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

#iac-chat-toggle:hover {
    transform: scale(1.09);
    box-shadow: 0 6px 28px var(--gold-glow), 0 3px 12px rgba(0, 0, 0, 0.22);
}

#iac-chat-widget.iac-open #iac-chat-toggle::before {
    animation: none;
    opacity: 0;
}

#iac-chat-toggle .iac-icon-close {
    display: none;
}

#iac-chat-widget.iac-open #iac-chat-toggle .iac-icon-open {
    display: none;
}

#iac-chat-widget.iac-open #iac-chat-toggle .iac-icon-close {
    display: inline-block;
}

@keyframes iac-pulse-ring {
    0% {
        transform: scale(0.9);
        opacity: 0.7;
    }

    70% {
        transform: scale(1.2);
        opacity: 0;
    }

    100% {
        opacity: 0;
    }
}

/* ── Badge ────────────────────────────────────────────────────────── */
#iac-chat-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #e05c4a;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    text-align: center;
    padding: 0 4px;
    box-shadow: 0 0 0 2.5px #fff;
    animation: iac-pop 0.4s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes iac-pop {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* ── Fenêtre de chat ──────────────────────────────────────────────── */
#iac-chat-window {
    position: fixed;
    right: 24px;
    bottom: 88px;
    width: 340px;
    max-width: calc(100vw - 32px);
    height: 470px;
    max-height: calc(100vh - 130px);
    background: var(--white);
    border-radius: 22px;
    box-shadow: 0 24px 64px rgba(30, 26, 20, 0.22), 0 4px 16px rgba(183, 153, 93, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    opacity: 0;
    transform: translateY(22px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.25s cubic-bezier(.34, 1.56, .64, 1);
}

#iac-chat-widget.iac-open #iac-chat-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ───────────────────────────────────────────────────────── */
#iac-chat-header {
    background: linear-gradient(140deg, var(--dark) 0%, var(--dark-2) 100%);
    color: #fff;
    padding: 16px 14px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
}

#iac-chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--gold) 50%, transparent 100%);
}

.iac-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--gold-light), var(--gold-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: -0.5px;
    color: #fff;
    box-shadow: 0 2px 10px rgba(183, 153, 93, 0.45);
}

.iac-title-block {
    flex: 1;
    min-width: 0;
}

.iac-title {
    font-family: var(--font-title);
    font-weight: 600;
    font-size: 17px;
    line-height: 1.2;
    letter-spacing: 0.04em;
}

.iac-subtitle {
    font-size: 11.5px;
    opacity: 0.68;
    line-height: 1.3;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.iac-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 7px #4ade80;
    flex-shrink: 0;
    animation: iac-dot-pulse 2.2s ease-in-out infinite;
}

@keyframes iac-dot-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.45;
    }
}

#iac-chat-close {
    background: rgba(255, 255, 255, 0.09);
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

#iac-chat-close:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

/* ── Zone messages ────────────────────────────────────────────────── */
#iac-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg);
    scroll-behavior: smooth;
}

#iac-chat-messages::-webkit-scrollbar {
    width: 4px;
}

#iac-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#iac-chat-messages::-webkit-scrollbar-thumb {
    background: #d6c9b0;
    border-radius: 4px;
}

/* ── Bulles de message ────────────────────────────────────────────── */
.iac-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.52;
    white-space: pre-wrap;
    word-wrap: break-word;
    animation: iac-msg-in 0.22s cubic-bezier(.34, 1.4, .64, 1) both;
}

@keyframes iac-msg-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }

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

.iac-msg-bot {
    align-self: flex-start;
    background: var(--white);
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px rgba(30, 26, 20, 0.08);
}

.iac-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 12px rgba(146, 123, 82, 0.38);
}

.iac-msg-error {
    align-self: flex-start;
    background: #fff5f5;
    color: #a33a2c;
    border: 1px solid #fcd5ce;
    border-radius: 14px;
    font-size: 13px;
}

/* ── Typing indicator ────────────────────────────────────────────── */
.iac-typing {
    align-self: flex-start;
    display: flex;
    gap: 5px;
    padding: 13px 16px;
    background: var(--white);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px rgba(30, 26, 20, 0.08);
    animation: iac-msg-in 0.22s both;
}

.iac-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gold);
    opacity: 0.45;
    animation: iac-bounce 1.3s infinite ease-in-out;
}

.iac-typing span:nth-child(2) {
    animation-delay: 0.18s;
}

.iac-typing span:nth-child(3) {
    animation-delay: 0.36s;
}

@keyframes iac-bounce {

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

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

/* ── Quick replies ───────────────────────────────────────────────── */
.iac-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0 6px;
    animation: iac-msg-in 0.3s 0.12s both;
}

.iac-qr-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    background: var(--white);
    color: var(--text);
    border: 1.5px solid var(--gold);
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 12.5px;
    font-family: var(--font-ui);
    line-height: 1.3;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.12s, box-shadow 0.12s;
}

.iac-qr-ico {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    flex-shrink: 0;
    color: var(--gold);
    font-size: 13px;
    transition: color 0.15s;
}

/* "P" cerclé — FontAwesome 4.1 ne fournit pas d'icône parking */
.iac-qr-p {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--gold);
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.iac-qr-btn:hover {
    background: var(--gold);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--gold-glow);
}

.iac-qr-btn:hover .iac-qr-ico {
    color: #fff;
}

.iac-qr-btn:hover .iac-qr-p {
    background: #fff;
    color: var(--gold-dark);
}

/* ── Zone de saisie ─────────────────────────────────────────────── */
#iac-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid #ede8df;
    flex-shrink: 0;
    background: var(--white);
}

#iac-chat-input {
    flex: 1;
    border: 1.5px solid #e0d8cb;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 13.5px;
    outline: none;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    font-family: var(--font-ui);
}

#iac-chat-input::placeholder {
    color: #b0a48c;
}

#iac-chat-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(183, 153, 93, 0.13);
    background: #fff;
}

#iac-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, var(--gold-light), var(--gold-dark));
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    box-shadow: 0 2px 10px rgba(183, 153, 93, 0.38);
}

#iac-chat-send:not(:disabled):hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(183, 153, 93, 0.55);
}

#iac-chat-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

/* ── Footer ─────────────────────────────────────────────────────── */
#iac-chat-footer {
    text-align: center;
    font-family: var(--font-title);
    font-size: 12px;
    font-weight: 500;
    color: #c4b89a;
    padding: 0 0 9px;
    background: var(--white);
    letter-spacing: 0.08em;
    flex-shrink: 0;
}

/* ── Responsive mobile ───────────────────────────────────────────── */
@media (max-width: 600px) {

    /* Bouton flottant — caché quand le widget est ouvert */
    #iac-chat-toggle {
        right: 14px;
        bottom: 89px;
        width: 52px;
        height: 52px;
        font-size: 20px;
    }

    #iac-chat-widget.iac-open #iac-chat-toggle {
        display: none;
    }

    /* Fenêtre — presque plein écran avec marge en haut */
    #iac-chat-window {
        position: fixed;
        top: 52px;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: none;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(.32, 1, .32, 1), opacity 0.2s ease;
    }

    #iac-chat-widget.iac-open #iac-chat-window {
        transform: translateY(0);
        opacity: 1;
    }

    /* Header touch-friendly */
    #iac-chat-header {
        padding: 16px 14px 15px;
        border-radius: 20px 20px 0 0;
    }

    .iac-avatar {
        width: 44px;
        height: 44px;
        font-size: 14px;
    }

    .iac-title {
        font-size: 17px;
    }

    .iac-subtitle {
        font-size: 12px;
        margin-top: 3px;
    }

    #iac-chat-close {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    /* Zone messages */
    #iac-chat-messages {
        padding: 14px 12px 6px;
        gap: 9px;
    }

    .iac-msg {
        font-size: 14px;
        max-width: 88%;
        padding: 10px 13px;
    }

    .iac-quick-replies {
        gap: 6px;
    }

    .iac-qr-btn {
        font-size: 12.5px;
        padding: 8px 14px;
    }

    /* Zone saisie — collée au bas, respecte safe area iPhone */
    #iac-chat-input-area {
        padding: 8px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        gap: 8px;
    }

    #iac-chat-input {
        font-size: 15px;
        padding: 10px 15px;
    }

    #iac-chat-send {
        width: 42px;
        height: 42px;
        font-size: 15px;
        flex-shrink: 0;
    }

    /* Footer caché sur mobile — pas de place */
    #iac-chat-footer {
        display: none;
    }

    /* Handle visuel en haut du bottom sheet */
    #iac-chat-header::before {
        content: '';
        position: absolute;
        top: -10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.35);
        border-radius: 4px;
    }
}