/* ================================================================
   ARRAHMA CHATBOT — CSS
   Design inspiré du chatbot promoglacons.fr
   Couleurs : vert mosquée #1a6b3a, blanc, gris doux
   ================================================================ */

/* ── Variables ── */
:root {
    --ac-green:        #1a6b3a;
    --ac-green-dark:   #145230;
    --ac-green-light:  #22874a;
    --ac-green-bg:     #e8f5ed;
    --ac-white:        #ffffff;
    --ac-gray-light:   #f4f4f4;
    --ac-gray-mid:     #e8e8e8;
    --ac-gray-text:    #888888;
    --ac-text:         #1a1a1a;
    --ac-bubble-user:  #1a6b3a;
    --ac-bubble-bot:   #f4f4f4;
    --ac-shadow:       0 8px 32px rgba(0,0,0,0.18);
    --ac-radius:       20px;
    --ac-btn-radius:   12px;
    --ac-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --ac-transition:   0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --ac-z:            999999;
}

/* ── Wrapper global ── */
#arrahma-chat-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--ac-z);
    font-family: var(--ac-font);
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

#arrahma-chat-wrapper *,
#arrahma-chat-wrapper *::before,
#arrahma-chat-wrapper *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Bouton flottant ── */
#arrahma-toggle-btn {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--ac-green);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(26, 107, 58, 0.45);
    transition: transform var(--ac-transition), box-shadow var(--ac-transition), background var(--ac-transition);
    outline: none;
    margin-left: auto;
}

#arrahma-toggle-btn:hover {
    background: var(--ac-green-light);
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(26, 107, 58, 0.55);
}

#arrahma-toggle-btn:focus-visible {
    outline: 3px solid var(--ac-green-light);
    outline-offset: 3px;
}

/* Animation pulsation */
#arrahma-toggle-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--ac-green);
    opacity: 0;
    animation: ac-pulse 2.5s ease-out infinite;
}

#arrahma-toggle-btn::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid var(--ac-green);
    opacity: 0;
    animation: ac-pulse 2.5s ease-out 0.6s infinite;
}

@keyframes ac-pulse {
    0%   { transform: scale(0.9); opacity: 0.6; }
    70%  { transform: scale(1.3); opacity: 0; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* Stop pulse quand la fenêtre est ouverte */
#arrahma-chat-wrapper.ac-open #arrahma-toggle-btn::before,
#arrahma-chat-wrapper.ac-open #arrahma-toggle-btn::after {
    animation: none;
}

/* ── Fenêtre de chat ── */
#arrahma-chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 420px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    background: var(--ac-white);
    border-radius: var(--ac-radius);
    box-shadow: var(--ac-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Animation d'ouverture/fermeture */
    transform: scale(0.88) translateY(16px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: transform var(--ac-transition), opacity var(--ac-transition);
}

#arrahma-chat-wrapper.ac-open #arrahma-chat-window {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ── */
#arrahma-header {
    position: relative;
    background: var(--ac-green);
    padding: 16px 16px 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#arrahma-header-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

#arrahma-header-info {
    flex: 1;
    min-width: 0;
}

#arrahma-header-name {
    display: block;
    color: var(--ac-white);
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#arrahma-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255,255,255,0.85);
    font-size: 12px;
    margin-top: 2px;
}

.arrahma-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
    animation: ac-blink 2s ease-in-out infinite;
}

@keyframes ac-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

#arrahma-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

#arrahma-menu-btn,
#arrahma-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--ac-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    transition: background var(--ac-transition);
    outline: none;
}

#arrahma-menu-btn:hover,
#arrahma-close-btn:hover {
    background: rgba(255,255,255,0.15);
}

#arrahma-menu-btn:focus-visible,
#arrahma-close-btn:focus-visible {
    outline: 2px solid rgba(255,255,255,0.6);
}

/* ── Dropdown menu ── */
#arrahma-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 12px;
    background: var(--ac-white);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.14);
    overflow: hidden;
    z-index: 10;
    min-width: 210px;

    transform: scale(0.9) translateY(-8px);
    transform-origin: top right;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

#arrahma-dropdown.ac-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

#arrahma-dropdown button {
    display: block;
    width: 100%;
    padding: 13px 18px;
    border: none;
    background: none;
    text-align: left;
    font-size: 13.5px;
    font-family: var(--ac-font);
    color: var(--ac-text);
    cursor: pointer;
    transition: background var(--ac-transition);
}

#arrahma-dropdown button:hover {
    background: var(--ac-gray-light);
}

#arrahma-dropdown button + button {
    border-top: 1px solid var(--ac-gray-mid);
}

/* ── Zone messages ── */
#arrahma-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    min-height: 260px;
}

#arrahma-messages::-webkit-scrollbar {
    width: 4px;
}
#arrahma-messages::-webkit-scrollbar-track {
    background: transparent;
}
#arrahma-messages::-webkit-scrollbar-thumb {
    background: var(--ac-gray-mid);
    border-radius: 4px;
}

/* ── Bulles de messages ── */
.ac-message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: ac-msg-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ac-msg-in {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ac-message-row.ac-user {
    flex-direction: row-reverse;
}

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

.ac-message-row.ac-user .ac-msg-avatar {
    background: var(--ac-green);
    color: white;
    font-size: 13px;
    font-weight: 700;
}

.ac-bubble {
    max-width: 78%;
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ac-text);
}

.ac-message-row.ac-bot .ac-bubble {
    background: var(--ac-bubble-bot);
    border-bottom-left-radius: 5px;
}

.ac-message-row.ac-user .ac-bubble {
    background: var(--ac-bubble-user);
    color: var(--ac-white);
    border-bottom-right-radius: 5px;
}

/* ── Indicateur de frappe ── */
.ac-typing-row {
    display: flex;
    align-items: center;
    gap: 8px;
    animation: ac-msg-in 0.28s ease;
}

.ac-typing-dots {
    background: var(--ac-bubble-bot);
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.ac-typing-dots span {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--ac-gray-text);
    border-radius: 50%;
    animation: ac-dot-bounce 1.2s ease-in-out infinite;
}

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

@keyframes ac-dot-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Boutons de menu / suggestions ── */
.ac-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    width: 100%;
}

/* Spécificité maximale pour battre n'importe quel thème WordPress/Elementor */
#arrahma-chat-wrapper .ac-suggestion-btn,
#arrahma-chat-wrapper .ac-suggestion-btn:link,
#arrahma-chat-wrapper .ac-suggestion-btn:visited {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 12px 16px !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: 1.5px solid #e8e8e8 !important;
    border-radius: 12px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    color: #1a1a1a !important;
    cursor: pointer !important;
    text-align: left !important;
    text-decoration: none !important;
    box-shadow: none !important;
    transition: border-color 0.25s ease, background 0.25s ease, transform 0.15s ease !important;
    outline: none !important;
}

#arrahma-chat-wrapper .ac-suggestion-btn:hover,
#arrahma-chat-wrapper .ac-suggestion-btn:focus {
    background: #e8f5ed !important;
    background-color: #e8f5ed !important;
    border-color: #1a6b3a !important;
    color: #1a1a1a !important;
    text-decoration: none !important;
    box-shadow: none !important;
    transform: translateX(2px) !important;
}

#arrahma-chat-wrapper .ac-suggestion-btn:active {
    transform: scale(0.98) !important;
    background: #d4eddc !important;
    background-color: #d4eddc !important;
}

#arrahma-chat-wrapper .ac-suggestion-btn .ac-suggestion-icon,
#arrahma-chat-wrapper .ac-suggestion-btn:hover .ac-suggestion-icon {
    font-size: 18px !important;
    flex-shrink: 0 !important;
    line-height: 1 !important;
}

#arrahma-chat-wrapper .ac-suggestion-btn .ac-suggestion-label,
#arrahma-chat-wrapper .ac-suggestion-btn:hover .ac-suggestion-label {
    flex: 1 !important;
    color: #1a1a1a !important;
}

#arrahma-chat-wrapper .ac-suggestion-btn .ac-suggestion-arrow,
#arrahma-chat-wrapper .ac-suggestion-btn:hover .ac-suggestion-arrow {
    color: #1a6b3a !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
}


/* ── Zone de saisie ── */
#arrahma-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--ac-gray-mid);
    background: var(--ac-white);
    flex-shrink: 0;
}

#arrahma-input {
    flex: 1;
    height: 42px;
    padding: 0 14px;
    border: 1.5px solid var(--ac-gray-mid);
    border-radius: 21px;
    font-size: 13.5px;
    font-family: var(--ac-font);
    color: var(--ac-text);
    background: var(--ac-gray-light);
    outline: none;
    transition: border-color var(--ac-transition), background var(--ac-transition);
}

#arrahma-input::placeholder {
    color: #bbb;
}

#arrahma-input:focus {
    border-color: var(--ac-green);
    background: var(--ac-white);
}

#arrahma-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--ac-green);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--ac-transition), transform 0.15s ease;
    outline: none;
}

#arrahma-send-btn:hover {
    background: var(--ac-green-light);
    transform: scale(1.08);
}

#arrahma-send-btn:focus-visible {
    outline: 3px solid var(--ac-green-light);
    outline-offset: 2px;
}

#arrahma-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Powered by ── */
#arrahma-powered {
    text-align: center;
    padding: 7px 0 9px;
    font-size: 11px;
    color: var(--ac-gray-text);
    border-top: 1px solid var(--ac-gray-mid);
    flex-shrink: 0;
}

#arrahma-powered a {
    color: var(--ac-green);
    text-decoration: none;
    font-weight: 600;
}

#arrahma-powered a:hover {
    text-decoration: underline;
}

/* ── Message d'erreur ── */
.ac-error-bubble {
    background: #fff0f0;
    border: 1px solid #ffcccc;
    color: #cc2200;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    text-align: center;
}

/* ── Responsive mobile ── */
@media (max-width: 480px) {
    #arrahma-chat-wrapper {
        bottom: 16px;
        right: 12px;
        left: 12px;
    }

    #arrahma-chat-window {
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        bottom: 70px;
        max-height: calc(100vh - 100px);
        border-radius: 16px 16px 16px 16px;
    }

    #arrahma-toggle-btn {
        margin-left: auto;
    }
}
