/* ================================================
   Mme Gayya — Chatbot Flottant
   SID GAYYA SAHEL — Financement participatif
   Thème : Vert #2ecc40 / #27ae60
   ================================================ */

/* Bouton flottant */
.gayya-fab {
    position: fixed;
    bottom: 110px;
    right: 18px;
    z-index: 10000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: none;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(46, 204, 64, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: gayya-bounce-in 0.6s ease-out;
    overflow: hidden;
    padding: 0;
}

.gayya-fab:hover {
    transform: scale(1.15) translateY(-3px);
    box-shadow: 0 8px 30px rgba(46, 204, 64, 0.55);
}

.gayya-fab.active {
    box-shadow: 0 3px 12px rgba(46, 204, 64, 0.25);
}

/* Badge notification */
.gayya-fab .gayya-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffc107;
    border: 2px solid white;
    animation: gayya-pulse 2s infinite;
}

/* Fenêtre de chat */
.gayya-window {
    position: fixed;
    bottom: 160px;
    right: 15px;
    z-index: 10001;
    width: min(400px, calc(100vw - 24px));
    min-width: 280px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 180px);
    max-height: calc(100dvh - 180px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: visible;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Pendant le resize, désactiver les transitions */
.gayya-window.gayya-resizing {
    transition: none;
    user-select: none;
}

/* Handle de redimensionnement — point latéral gauche */
.gayya-resize-handle {
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 40px;
    cursor: ew-resize;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s;
}

.gayya-window.open .gayya-resize-handle {
    opacity: 1;
}

.gayya-resize-handle::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #27ae60;
    box-shadow: 0 2px 6px rgba(39, 174, 96, 0.4);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.gayya-resize-handle:hover::before,
.gayya-resize-handle.active::before {
    transform: scale(1.6);
    background: #2ecc40;
    box-shadow: 0 0 10px rgba(46, 204, 64, 0.6);
}

/* Handle de redimensionnement vertical — point en bas */
.gayya-resize-handle-bottom {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 12px;
    cursor: ns-resize;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s;
}

.gayya-window.open .gayya-resize-handle-bottom {
    opacity: 1;
}

.gayya-resize-handle-bottom::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #27ae60;
    box-shadow: 0 2px 6px rgba(39, 174, 96, 0.4);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.gayya-resize-handle-bottom:hover::before,
.gayya-resize-handle-bottom.active::before {
    transform: scale(1.6);
    background: #2ecc40;
    box-shadow: 0 0 10px rgba(46, 204, 64, 0.6);
}

/* === Plein écran === */
.gayya-window.gayya-fullscreen {
    top: 8px !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    max-width: none !important;
    border-radius: 14px;
}

.gayya-window.gayya-fullscreen .gayya-resize-handle,
.gayya-window.gayya-fullscreen .gayya-resize-handle-bottom {
    display: none;
}

.gayya-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.gayya-header {
    background: linear-gradient(135deg, #2ecc40 0%, #27ae60 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.gayya-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.4);
    animation: gayya-avatar-float 3s ease-in-out infinite;
    overflow: hidden;
}

.gayya-header-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
}

.gayya-header-info p {
    margin: 0;
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.gayya-header-info .gayya-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ffc107;
    display: inline-block;
    animation: gayya-pulse 2s infinite;
}

.gayya-header-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
    align-items: center;
}

.gayya-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.gayya-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages area */
.gayya-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    background: #f8fafc;
    -webkit-overflow-scrolling: touch;
}

.gayya-messages::-webkit-scrollbar {
    width: 5px;
}

.gayya-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Bulles de message */
.gayya-msg {
    display: flex;
    gap: 8px;
    max-width: 90%;
    animation: gayya-msg-in 0.3s ease-out;
}

.gayya-msg.bot {
    align-self: flex-start;
}

.gayya-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.gayya-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.gayya-msg.bot .gayya-msg-avatar {
    background: none;
    border: none;
    overflow: hidden;
}

.gayya-msg.user .gayya-msg-avatar {
    background: #e2e8f0;
    color: #475569;
}

.gayya-msg-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.gayya-msg-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.gayya-msg.bot .gayya-msg-bubble {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
}

.gayya-msg.user .gayya-msg-bubble {
    background: linear-gradient(135deg, #2ecc40, #27ae60);
    color: white;
    border-bottom-right-radius: 6px;
}

/* Markdown dans les messages bot */
.gayya-msg.bot .gayya-msg-bubble a {
    color: #2ecc40 !important;
    text-decoration: underline !important;
    font-weight: 600;
    cursor: pointer !important;
    pointer-events: auto !important;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.gayya-msg.bot .gayya-msg-bubble a:hover {
    color: #27ae60 !important;
}

.gayya-msg.bot .gayya-msg-bubble strong {
    font-weight: 700;
    color: #0f172a;
}

.gayya-msg.bot .gayya-msg-bubble ul,
.gayya-msg.bot .gayya-msg-bubble ol {
    margin: 6px 0;
    padding-left: 18px;
}

.gayya-msg.bot .gayya-msg-bubble li {
    margin-bottom: 3px;
}

.gayya-msg.bot .gayya-msg-bubble p {
    margin: 0 0 8px 0;
}

.gayya-msg.bot .gayya-msg-bubble p:last-child {
    margin-bottom: 0;
}

/* Typing indicator */
.gayya-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 18px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    width: fit-content;
}

.gayya-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: gayya-typing-dot 1.4s infinite ease-in-out;
}

.gayya-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.gayya-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Input area */
.gayya-input-area {
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: white;
    flex-shrink: 0;
}

.gayya-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 22px;
    padding: 9px 16px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 80px;
    min-height: 40px;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.gayya-input:focus {
    border-color: #2ecc40;
}

.gayya-input::placeholder {
    color: #94a3b8;
}

.gayya-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2ecc40, #27ae60);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 17px;
    transition: all 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.gayya-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(46, 204, 64, 0.4);
}

.gayya-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Suggestions rapides */
.gayya-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    max-width: 100%;
}

.gayya-suggestion {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #475569;
    white-space: normal;
    word-break: break-word;
    max-width: 100%;
    text-align: left;
    line-height: 1.3;
}

.gayya-suggestion:hover {
    background: #2ecc40;
    color: white;
    border-color: #2ecc40;
}

/* Footer */
.gayya-footer {
    text-align: center;
    padding: 5px;
    font-size: 9px;
    color: #94a3b8;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

/* === Bot Avatar SVG === */
.gayya-bot-svg {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* Blink */
.gayya-bot-svg .gayya-svg-eyes {
    transform-box: fill-box;
    transform-origin: center;
    animation: gayya-blink-anim 4s ease-in-out infinite;
}

@keyframes gayya-blink-anim {
    0%, 43%, 48%, 100% { transform: scaleY(1); }
    45%, 46% { transform: scaleY(0.08); }
}

/* Mouth transitions */
.gayya-bot-svg .gayya-svg-smile,
.gayya-bot-svg .gayya-svg-mouth-o {
    transition: opacity 0.15s;
}

.gayya-bot-svg .gayya-svg-mouth-o {
    transform-box: fill-box;
    transform-origin: center;
}

/* Talking state */
.gayya-talking .gayya-svg-smile {
    opacity: 0 !important;
}

.gayya-talking .gayya-svg-mouth-o {
    opacity: 1 !important;
    animation: gayya-mouth-anim 0.3s ease-in-out infinite alternate;
}

@keyframes gayya-mouth-anim {
    0% { transform: scaleY(0.5) scaleX(0.85); }
    100% { transform: scaleY(1.3) scaleX(1.1); }
}

/* FAB breathing */
.gayya-fab .gayya-bot-svg {
    animation: gayya-breathe 3.5s ease-in-out infinite;
}

@keyframes gayya-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.07); }
}

/* FAB hover glow */
.gayya-fab:hover .gayya-bot-svg {
    filter: drop-shadow(0 0 6px rgba(46, 204, 64, 0.5));
    animation: none;
    transform: scale(1);
}

/* Greeting wave */
.gayya-greeting .gayya-bot-svg {
    animation: gayya-greet 1.2s ease-in-out !important;
}

@keyframes gayya-greet {
    0%, 100% { transform: rotate(0deg) scale(1); }
    10% { transform: rotate(12deg) scale(1.1); }
    20% { transform: rotate(-10deg) scale(1.08); }
    30% { transform: rotate(12deg) scale(1.1); }
    40% { transform: rotate(-8deg) scale(1.05); }
    50% { transform: rotate(6deg) scale(1.03); }
    60% { transform: rotate(0deg) scale(1); }
}

/* === Animations === */
@keyframes gayya-bounce-in {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes gayya-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes gayya-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.gayya-animate {
    animation: gayya-msg-in 0.3s ease-out;
}

@keyframes gayya-typing-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes gayya-avatar-float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-4px) scale(1.02); }
}

/* Clip du contenu interne (le window est overflow:visible pour le handle) */
.gayya-window > .gayya-header,
.gayya-window > .gayya-input-area,
.gayya-window > .gayya-footer {
    overflow: hidden;
}

/* Cacher les handles en mobile (pas utile touch) */
@media (max-width: 480px) {
    .gayya-resize-handle { display: none !important; }
    .gayya-resize-handle-bottom { display: none !important; }
}

/* === Responsive === */

/* Tablette */
@media (max-width: 768px) {
    .gayya-window {
        width: min(380px, calc(100vw - 20px));
        bottom: 155px;
    }

    .gayya-header {
        padding: 14px 16px;
        gap: 10px;
    }

    .gayya-avatar {
        width: 40px;
        height: 40px;
    }
}

/* Mobile standard */
@media (max-width: 480px) {
    .gayya-window {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 158px;
        max-height: calc(100vh - 170px);
        max-height: calc(100dvh - 170px);
        border-radius: 16px;
    }

    .gayya-fab {
        bottom: 108px;
        right: 14px;
        width: 42px;
        height: 42px;
    }

    .gayya-header {
        padding: 10px 12px;
        gap: 8px;
    }

    .gayya-avatar {
        width: 34px;
        height: 34px;
    }

    .gayya-header-info h4 {
        font-size: 13px;
    }

    .gayya-header-info p {
        font-size: 10px;
    }

    .gayya-header-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .gayya-messages {
        padding: 12px 10px;
        gap: 10px;
    }

    .gayya-msg {
        max-width: 92%;
        gap: 6px;
    }

    .gayya-msg-avatar {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .gayya-msg-bubble {
        padding: 8px 12px;
        font-size: 13px;
        border-radius: 16px;
    }

    .gayya-msg.bot .gayya-msg-bubble {
        border-bottom-left-radius: 4px;
    }

    .gayya-msg.user .gayya-msg-bubble {
        border-bottom-right-radius: 4px;
    }

    .gayya-msg.bot .gayya-msg-bubble ul,
    .gayya-msg.bot .gayya-msg-bubble ol {
        padding-left: 14px;
    }

    .gayya-input-area {
        padding: 8px 10px;
        gap: 6px;
    }

    .gayya-input {
        padding: 8px 14px;
        font-size: 14px;
        min-height: 38px;
        border-radius: 20px;
    }

    .gayya-send-btn {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }

    .gayya-suggestion {
        font-size: 11px;
        padding: 5px 10px;
    }

    .gayya-typing {
        padding: 8px 14px;
    }

    .gayya-typing span {
        width: 6px;
        height: 6px;
    }

    .gayya-footer {
        padding: 4px;
        font-size: 8px;
    }
}

/* Très petit mobile — fullscreen */
@media (max-width: 380px) {
    .gayya-window {
        width: 100vw;
        right: 0;
        bottom: 154px;
        max-height: calc(100vh - 162px);
        max-height: calc(100dvh - 162px);
        border-radius: 14px 14px 0 0;
    }

    .gayya-fab {
        bottom: 106px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
}

/* Paysage mobile */
@media (max-height: 500px) {
    .gayya-window {
        top: 4px;
        bottom: 4px;
        max-height: none;
        height: calc(100vh - 8px);
        height: calc(100dvh - 8px);
        border-radius: 14px;
    }

    .gayya-header {
        padding: 8px 12px;
    }

    .gayya-avatar {
        width: 30px;
        height: 30px;
    }

    .gayya-header-info h4 {
        font-size: 12px;
    }

    .gayya-header-info p {
        display: none;
    }

    .gayya-messages {
        padding: 8px;
        gap: 6px;
    }

    .gayya-msg-bubble {
        padding: 6px 10px;
        font-size: 12px;
    }

    .gayya-input-area {
        padding: 6px 8px;
    }

    .gayya-input {
        min-height: 34px;
        padding: 6px 12px;
        font-size: 13px;
    }

    .gayya-send-btn {
        width: 34px;
        height: 34px;
    }

    .gayya-footer {
        display: none;
    }
}
