/* wroomy-avatar.css */

/* ─── Contenitore principale: centrato verticalmente a sinistra ─── */
#wroomy-avatar {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9999;
    font-family: 'Segoe UI', Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* ─── Trigger button ─── */
#wroomy-trigger {
    width: 72px;
    height: 72px;
    border-radius: 0 50% 50% 0;   /* tab laterale appiccicato al bordo sinistro */
    background: linear-gradient(135deg, #2563A8 0%, #ACC921 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 168, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
    position: relative;
    overflow: hidden;
    padding: 0;
}

#wroomy-trigger:hover {
    width: 80px;
    box-shadow: 0 6px 28px rgba(37, 99, 168, 0.6);
    transform: translateY(0) scale(1.05);
}

/* Anello pulse animato */
#wroomy-trigger::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    border: 2px solid rgba(172, 201, 33, 0.6);
    animation: avatarPulse 2.4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes avatarPulse {
    0%   { opacity: 1;   transform: scale(1); }
    70%  { opacity: 0;   transform: scale(1.25); }
    100% { opacity: 0;   transform: scale(1.25); }
}

#wroomy-trigger img {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: cover;
    margin-left: 4px; /* compensa il bordo piatto a sinistra */
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
    transition: transform 0.2s ease;
}

#wroomy-trigger:hover img {
    transform: scale(1.08);
}

/* ─── Tooltip "Chiedimi" accanto al trigger ─── */
#wroomy-trigger::after {
    content: 'Chiedimi!';
    position: absolute;
    left: 78px;
    background: #1B3A6B;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 20px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#wroomy-trigger:hover::after {
    opacity: 1;
}

/* ─── Pannello chat: si apre a destra del trigger ─── */
#wroomy-panel {
    position: fixed;
    left: 80px;
    top: 50%;
    transform: translateY(-50%);
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: left center;
}

#wroomy-panel[hidden] {
    display: none;
}

/* ─── Header ─── */
.wroomy-header {
    background: linear-gradient(135deg, #2563A8 0%, #ACC921 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.wroomy-avatar-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    object-fit: cover;
    border: 2px solid rgba(172, 201, 33, 0.8);
    flex-shrink: 0;
}

.wroomy-header strong {
    font-size: 15px;
    display: block;
}

.wroomy-status {
    display: block;
    font-size: 11px;
    color: #ACC921;
    margin-top: 1px;
}

#wroomy-close {
    margin-left: auto;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#wroomy-close:hover {
    background: rgba(255,255,255,0.25);
}

/* ─── Messaggi ─── */
#wroomy-messages {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    background: #F7F9FC;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wroomy-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.wroomy-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2563A8, #ACC921);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.wroomy-msg--assistant {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border: 1px solid #DDE3EE;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.typing-dots {
    animation: blink 1.4s infinite;
}

@keyframes blink {
    0%   { opacity: .2; }
    20%  { opacity: 1; }
    100% { opacity: .2; }
}

/* ─── Input area ─── */
.wroomy-input-area {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #EEF0F5;
    background: #fff;
    gap: 8px;
    flex-shrink: 0;
}

#wroomy-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #DDE3EE;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    background: #F7F9FC;
    transition: border-color 0.2s;
}

#wroomy-input:focus {
    border-color: #2563A8;
    background: #fff;
}

#wroomy-send {
    background: linear-gradient(135deg, #2563A8 0%, #ACC921 100%);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(37,99,168,0.3);
}

#wroomy-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 14px rgba(37,99,168,0.45);
}

/* ─── Annunci referenziati ─── */
.wroomy-annunci-refs {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wroomy-annuncio-card {
    display: flex;
    flex-direction: column;
    background: #EEF4FC;
    padding: 8px 10px;
    border-radius: 8px;
    border-left: 4px solid #2563A8;
    text-decoration: none;
    color: #333;
    font-size: 12px;
    transition: background 0.2s;
}

.wroomy-annuncio-card:hover {
    background: #DCE9F8;
}

/* ─── Feedback ─── */
.wroomy-feedback {
    margin-top: 6px;
    display: flex;
    gap: 5px;
}

.wroomy-feedback button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.15s;
}

.wroomy-feedback button:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* ─── Responsive mobile: porta in basso a destra ─── */
@media (max-width: 600px) {
    #wroomy-avatar {
        left: 16px;
        right: auto;
        top: auto;
        bottom: 20px;
        transform: none;
        align-items: flex-start;
    }

    #wroomy-trigger {
        border-radius: 50%;
        width: 60px;
        height: 60px;
    }

    #wroomy-trigger::before { display: none; }
    #wroomy-trigger::after  { display: none; }

    #wroomy-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 90px;
        top: auto;
        transform: none;
        width: auto;
        height: 70vh;
    }
}

/* ─── AVATAR STATES ─── */
.state-listening .avatar-glow {
    background: radial-gradient(circle, rgba(172, 201, 33, 0.4) 0%, rgba(172, 201, 33, 0) 70%);
}

.state-analyzing .avatar-glow {
    background: radial-gradient(circle, rgba(37, 99, 168, 0.5) 0%, rgba(37, 99, 168, 0) 70%);
    animation: glowPulse 1s infinite ease-in-out;
}

.state-found .avatar-glow {
    background: radial-gradient(circle, rgba(76, 175, 80, 0.6) 0%, rgba(76, 175, 80, 0) 70%);
    animation: glowPulse 0.5s 3 ease-in-out;
}

.state-analyzing #central-avatar-img {
    animation: rotateSlow 4s infinite linear;
}

@keyframes rotateSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.scanning-line {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 2px;
    background: linear-gradient(90deg, rgba(172, 201, 33, 0) 0%, rgba(172, 201, 33, 1) 50%, rgba(172, 201, 33, 0) 100%);
    transform: translate(-50%, -50%);
    z-index: 3;
    display: none;
    pointer-events: none;
}

.state-analyzing .scanning-line {
    display: block;
    animation: scanMove 2s infinite ease-in-out;
}

@keyframes scanMove {
    0% { transform: translate(-50%, -100px); opacity: 0; }
    50% { transform: translate(-50%, 0); opacity: 1; }
    100% { transform: translate(-50%, 100px); opacity: 0; }
}

/* ─── CENTRAL HOME PAGE CHAT ─── */
.avatar-search-container {
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
}


/* ─── GLASSMORPHISM CHAT PANEL ─── */
.glass-chat-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    width: 100%;
    max-width: 500px;
    height: auto;
    max-height: 450px; /* Reduced height */
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: bubbleUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 5;
}

@keyframes bubbleUp {
    from { transform: scale(0.8) translateY(40px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.chat-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #2563A8 0%, #ACC921 100%);
    color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.chat-messages-scroll {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 150px;
    max-height: 250px; /* Reduced scroll area */
}

.chat-msg {
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 85%;
    font-size: 0.95rem;
    line-height: 1.4;
}

.chat-msg.assistant {
    background: #fff;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.chat-msg.user {
    background: #ACC921;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-input-wrapper {
    padding: 15px 20px;
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-input-wrapper input {
    flex: 1;
    background: #fff;
    border: 1px solid #ddd;
    padding: 10px 15px;
    border-radius: 25px;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input-wrapper input:focus {
    border-color: #ACC921;
}

.chat-input-wrapper button {
    background: #ACC921;
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.chat-input-wrapper button:hover {
    transform: scale(1.1);
}

/* ─── FILTERS DRAWER ─── */
.filters-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
}

.filters-drawer.open {
    display: block;
}

.drawer-content {
    position: absolute;
    top: 0;
    right: -100%;
    width: 400px;
    height: 100%;
    background: #fff;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    padding: 30px;
    overflow-y: auto;
}

.filters-drawer.open .drawer-content {
    right: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.drawer-header h3 {
    margin: 0;
    color: #333;
}

#closeDrawer {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

/* Fix for drawer form spacing */
.filters-drawer .search-form-grid {
    box-shadow: none !important;
    padding: 0 !important;
}

.filters-drawer .form-row {
    grid-template-columns: 1fr !important;
}

/* ─── MOBILE RESPONSIVE ─── */
@media (max-width: 768px) {
    .drawer-content {
        width: 90%; /* Reduced width from 100% */
        padding: 20px;
        border-radius: 20px 0 0 20px;
    }
    
    .glass-chat-panel {
        max-width: 100%;
        max-height: 50vh;
    }

    .drawer-header {
        margin-bottom: 20px;
    }

    /* Reduce font sizes inside drawers for mobile */
    .drawer-content h3 {
        font-size: 1.1rem !important;
    }
    .drawer-content p {
        font-size: 0.85rem !important;
    }
}
