/* ======= Flora — Assistente AI PhytoItalia ======= */

/* --- Bottone flottante --- */
#flora-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(76, 145, 86, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s;
}

#flora-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(76, 145, 86, 0.5);
}

#flora-toggle.flora-toggle-hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

#flora-toggle .flora-icon {
    font-size: 26px;
    line-height: 1;
}

/* Pulsino notifica */
#flora-toggle .flora-pulse {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: floraPulse 2s infinite;
}

@keyframes floraPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* --- Overlay --- */
#flora-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: background 0.3s;
}

#flora-overlay.flora-overlay-show {
    background: rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

/* --- Sidebar --- */
#flora-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100%;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#flora-sidebar.flora-open {
    right: 0;
}

/* --- Header --- */
.flora-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    flex-shrink: 0;
}

.flora-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

.flora-header-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.flora-header-info small {
    opacity: 0.8;
    font-size: 12px;
}

#flora-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

#flora-close:hover {
    color: #fff;
}

/* --- Area messaggi --- */
#flora-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

/* --- Messaggio base --- */
.flora-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
    animation: floraFadeIn 0.3s ease;
}

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

/* Bot (sinistra) */
.flora-msg-bot {
    align-self: flex-start;
}

.flora-msg-bot .flora-bubble {
    background: #f0f2f5;
    color: #333;
    border-radius: 16px 16px 16px 4px;
}

/* User (destra) */
.flora-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.flora-msg-user .flora-bubble {
    background: var(--primary);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
}

/* Bubble */
.flora-bubble {
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Avatar bot */
.flora-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

/* --- Typing indicator --- */
.flora-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}

.flora-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #999;
    animation: floraBounce 1.4s infinite;
}

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

@keyframes floraBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* --- Product cards --- */
.flora-products {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 4px 36px;
    animation: floraFadeIn 0.3s ease;
}

.flora-product-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    font-size: 12px;
    transition: all 0.2s;
    max-width: 100%;
}

.flora-product-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(76, 145, 86, 0.15);
    color: var(--primary);
}

.flora-product-img {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    object-fit: contain;
    flex-shrink: 0;
    background: #f9f9f9;
}

.flora-product-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.flora-product-price {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    margin-left: auto;
}

/* --- Clear chat bar --- */
.flora-clear-bar {
    text-align: center;
    padding: 8px 16px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.flora-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #999;
    text-decoration: none;
    padding: 4px 14px;
    border-radius: 16px;
    transition: all 0.2s;
    background: #f8f8f8;
}

.flora-clear-btn:hover {
    color: #dc3545;
    background: #fef2f2;
}

.flora-clear-btn i {
    font-size: 13px;
}

/* --- Input area --- */
.flora-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    flex-shrink: 0;
}

#flora-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#flora-input:focus {
    border-color: var(--primary);
}

#flora-input::placeholder {
    color: #aaa;
}

.flora-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: background 0.2s;
}

.flora-send-btn:hover {
    background: var(--primary-hover);
}

/* --- Responsive --- */
@media (max-width: 480px) {
    #flora-sidebar {
        width: 100%;
        right: -100%;
    }

    #flora-toggle {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 991px) {
    #flora-sidebar {
        width: 100% !important;
        right: -100%;
    }

    #flora-sidebar.flora-open {
        right: 0;
    }
}
