/**
 * Groll AI Chat Widget - Stili Completi
 * NOMI CLASSI CORRETTI per widget.js
 */

/* ============================================
   WIDGET CONTAINER
============================================ */
.groll-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.groll-widget[data-position="bottom-right"] {
    bottom: 20px;
    right: 20px;
}

.groll-widget[data-position="bottom-left"] {
    bottom: 20px;
    left: 20px;
}

.groll-widget[data-position="top-right"] {
    top: 80px;
    right: 20px;
}

.groll-widget[data-position="top-left"] {
    top: 80px;
    left: 20px;
}

/* ============================================
   CHAT BUTTON
============================================ */
.groll-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color, #8000ff);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
}

.groll-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.groll-chat-button svg {
    width: 28px;
    height: 28px;
}

/* ============================================
   CHAT WINDOW
============================================ */
.groll-chat-window {
    position: fixed;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: groll-slide-up 0.3s ease-out;
}

@keyframes groll-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.groll-widget[data-position="bottom-right"] .groll-chat-window {
    bottom: 90px;
    right: 20px;
}

.groll-widget[data-position="bottom-left"] .groll-chat-window {
    bottom: 90px;
    left: 20px;
}

.groll-widget[data-position="top-right"] .groll-chat-window {
    top: 90px;
    right: 20px;
}

.groll-widget[data-position="top-left"] .groll-chat-window {
    top: 90px;
    left: 20px;
}

/* ============================================
   CHAT HEADER
============================================ */
.groll-chat-header {
    background: var(--primary-color, #8000ff);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 80px;
    flex-shrink: 0;
}

.groll-chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.groll-chat-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: 18px;
    font-weight: 600;
    flex-shrink: 0;
}

.groll-chat-name {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.3;
}

.groll-chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.groll-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.groll-chat-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.groll-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.groll-chat-close svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   MESSAGES AREA
============================================ */
.groll-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.groll-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.groll-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.groll-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.groll-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ============================================
   MESSAGE BUBBLES
============================================ */
.groll-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: groll-fade-in 0.3s ease-out;
}

@keyframes groll-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.groll-message-bot {
    align-self: flex-start;
    flex-direction: row;
}

.groll-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.groll-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color, #8000ff);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.groll-message-user .groll-message-avatar {
    background: #6b7280;
}

.groll-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.groll-message-text {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
    word-break: break-word;
}

.groll-message-bot .groll-message-text {
    background: white;
    color: #1f2937;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 4px;
}

.groll-message-user .groll-message-text {
    background: var(--primary-color, #8000ff);
    color: white;
    border-bottom-right-radius: 4px;
}

.groll-message-time {
    font-size: 11px;
    color: #9ca3af;
    padding: 0 16px;
}

/* ============================================
   TYPING INDICATOR
============================================ */
.groll-typing {
    display: flex;
    gap: 10px;
    max-width: 85%;
    align-self: flex-start;
}

.groll-typing-indicator {
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.groll-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: groll-bounce 1.4s infinite ease-in-out both;
}

.groll-typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.groll-typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes groll-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   INPUT AREA
============================================ */
.groll-chat-input {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
    align-items: center;
    flex-shrink: 0;
}

.groll-chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.groll-chat-input input:focus {
    border-color: var(--primary-color, #8000ff);
}

.groll-chat-input input::placeholder {
    color: #9ca3af;
}

.groll-chat-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color, #8000ff);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.groll-chat-input button:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(128, 0, 255, 0.3);
}

.groll-chat-input button:active {
    transform: scale(0.95);
}

.groll-chat-input button svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   FOOTER
============================================ */
.groll-chat-footer {
    text-align: center;
    padding: 12px;
    font-size: 11px;
    color: #6b7280;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

/* ============================================
   ICON VISIBILITY
============================================ */
.groll-icon-open,
.groll-icon-close {
    transition: all 0.3s ease;
}

/* ============================================
   MOBILE RESPONSIVE
============================================ */
@media (max-width: 480px) {
    .groll-chat-window {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
    }
    
    .groll-widget[data-position="bottom-right"],
    .groll-widget[data-position="bottom-left"],
    .groll-widget[data-position="top-right"],
    .groll-widget[data-position="top-left"] {
        bottom: 16px;
        right: 16px;
    }
    
    .groll-chat-button {
        width: 56px;
        height: 56px;
    }
    
    .groll-chat-button svg {
        width: 24px;
        height: 24px;
    }
}

/* ============================================
   LOADING STATE
============================================ */
.groll-loading {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

/* ============================================
   ERROR STATE
============================================ */
.groll-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 16px;
    border-radius: 8px;
    margin: 20px;
    text-align: center;
}