/**
 * Live Chat System - CSS Styles
 * Stili per il widget di chat in tempo reale
 */

/* ===== CHAT BUTTON (FLOATING) ===== */
.live-chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    cursor: pointer;
    transform: scale(1);
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    border-radius: 50px;
    box-shadow: 0 8px 25px rgba(78, 205, 196, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatButtonBounce 3s ease-in-out infinite;
}

.live-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 35px rgba(78, 205, 196, 0.6);
}

.live-chat-button.has-unread {
    animation: chatButtonPulse 1s ease-in-out infinite;
}

.live-chat-button.has-unread::before {
    content: '';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #FF6B6B;
    border-radius: 50%;
    border: 3px solid white;
    animation: pulse 2s infinite;
}

.chat-button-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    color: white;
    font-weight: 600;
    position: relative;
}

.chat-button-content i {
    font-size: 1.5rem;
}

.chat-button-text {
    font-size: 1rem;
    white-space: nowrap;
}

.chat-button-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50px;
    background: rgba(78, 205, 196, 0.3);
    transform: translate(-50%, -50%);
    animation: pulse 2s infinite;
}

/* ===== CHAT WINDOW ===== */
.live-chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%) scale(0.8);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.live-chat-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* ===== CHAT HEADER ===== */
.chat-header {
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

.operator-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.operator-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.operator-details {
    display: flex;
    flex-direction: column;
}

.operator-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 2px;
}

.operator-status {
    font-size: 0.85rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.operator-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4AE54A;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.chat-minimize,
.chat-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chat-minimize:hover,
.chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== WELCOME FORM ===== */
.chat-welcome {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.welcome-content {
    text-align: center;
    width: 100%;
}

.welcome-icon {
    font-size: 3rem;
    color: #4ECDC4;
    margin-bottom: 1rem;
}

.welcome-content h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1.4rem;
}

.welcome-content p {
    color: #7f8c8d;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.chat-start-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-start-form .form-group {
    position: relative;
}

.chat-start-form input,
.chat-start-form textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    font-family: inherit;
    resize: none;
}

.chat-start-form input:focus,
.chat-start-form textarea:focus {
    outline: none;
    border-color: #4ECDC4;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1);
}

.btn-start-chat {
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-start-chat:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(78, 205, 196, 0.3);
}

/* ===== WAITING STATE ===== */
.chat-waiting {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.waiting-content {
    text-align: center;
}

.waiting-animation {
    margin-bottom: 2rem;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ECDC4;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

.waiting-content p {
    color: #2c3e50;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.waiting-content small {
    color: #7f8c8d;
}

/* ===== CHAT MESSAGES ===== */
.chat-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.messages-container {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 1rem;
    align-items: flex-start;
}

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
    color: white;
}

.operator-message .message-avatar {
    background: #4ECDC4;
}

.user-message .message-avatar {
    background: #7473C3;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    gap: 12px;
}

.message-sender {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2c3e50;
}

.message-time {
    font-size: 0.75rem;
    color: #95a5a6;
    white-space: nowrap;
}

.message-text {
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 16px;
    color: #2c3e50;
    line-height: 1.4;
    word-wrap: break-word;
}

.user-message .message-text {
    background: #4ECDC4;
    color: white;
    border-radius: 16px 16px 4px 16px;
}

.operator-message .message-text {
    background: #f8f9fa;
    border-radius: 16px 16px 16px 4px;
}

.system-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(78, 205, 196, 0.1);
    border-radius: 20px;
    margin: 1rem 0;
    color: #4ECDC4;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ===== CHAT INPUT ===== */
.chat-input {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e8e8e8;
    background: white;
    border-radius: 0 0 20px 20px;
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#messageTextarea {
    flex: 1;
    border: 2px solid #e8e8e8;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    transition: border-color 0.3s ease;
}

#messageTextarea:focus {
    outline: none;
    border-color: #4ECDC4;
}

.send-button {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.send-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
}

.send-button:active {
    transform: scale(0.95);
}

.chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    color: #7f8c8d;
    font-size: 0.9rem;
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background: #7f8c8d;
    border-radius: 50%;
    animation: typing 1s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.1s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.2s;
}

/* ===== CHAT STATUS ===== */
.chat-status {
    padding: 8px 16px;
    background: rgba(78, 205, 196, 0.05);
    border-top: 1px solid rgba(78, 205, 196, 0.1);
}

.status-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.status-text {
    color: #4ECDC4;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-indicator.online {
    background: #4AE54A;
    animation: pulse 2s infinite;
}

.status-indicator.offline {
    background: #95a5a6;
}

/* ===== CHAT RESTART ===== */
.chat-restart {
    text-align: center;
    margin: 1rem 0;
}

.btn-restart-chat {
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-restart-chat:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(78, 205, 196, 0.3);
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

@keyframes chatButtonBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes chatButtonPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .live-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 10px;
        right: 10px;
        left: 10px;
        border-radius: 15px;
    }
    
    .live-chat-button {
        bottom: 15px;
        right: 15px;
    }
    
    .chat-button-text {
        display: none;
    }
    
    .chat-button-content {
        padding: 15px;
    }
    
    .chat-header {
        padding: 1rem;
    }
    
    .operator-name {
        font-size: 0.9rem;
    }
    
    .chat-welcome {
        padding: 1.5rem;
    }
    
    .messages-container {
        padding: 0.75rem;
    }
    
    .chat-input {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .live-chat-window {
        width: 320px;
        height: 480px;
        bottom: 15px;
        right: 15px;
        border-radius: 15px;
        background: #f8f9fa;
        border: 2px solid #e1e8ed;
    }
    
    .live-chat-button {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        bottom: 15px;
        right: 15px;
    }
    
    .chat-header {
        background: linear-gradient(135deg, #96CEB4, #4ECDC4);
        border-radius: 15px 15px 0 0;
        padding: 0.8rem;
    }
    
    .operator-name {
        font-size: 0.9rem;
    }
    
    .chat-welcome {
        padding: 1rem;
        background: #f8f9fa;
    }
    
    .welcome-content h3 {
        color: #2c3e50;
        font-size: 1.1rem;
    }
    
    .welcome-content p {
        color: #5a6c7d;
        font-size: 0.9rem;
    }
    
    .messages-container {
        background: #f8f9fa;
        padding: 0.75rem;
    }
    
    .message-text {
        background: white;
        color: #2c3e50;
        border: 1px solid #e1e8ed;
    }
    
    .operator-message .message-text {
        background: #e8f5f3;
        color: #2c3e50;
        border: 1px solid #4ECDC4;
    }
    
    .chat-input {
        background: #f8f9fa;
        border-top: 1px solid #e1e8ed;
        padding: 0.8rem;
    }
    
    #messageTextarea {
        background: white;
        color: #2c3e50;
        border: 1px solid #e1e8ed;
        font-size: 0.9rem;
    }
    
    .chat-start-form input,
    .chat-start-form textarea {
        background: white;
        color: #2c3e50;
        border: 1px solid #e1e8ed;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .live-chat-window {
        background: #2c3e50;
        color: #ecf0f1;
    }
    
    .message-text {
        background: #34495e;
        color: #ecf0f1;
    }
    
    .operator-message .message-text {
        background: #34495e;
    }
    
    .chat-input {
        background: #2c3e50;
        border-top-color: #34495e;
    }
    
    #messageTextarea {
        background: #34495e;
        color: #ecf0f1;
        border-color: #34495e;
    }
    
    .chat-start-form input,
    .chat-start-form textarea {
        background: #34495e;
        color: #ecf0f1;
        border-color: #34495e;
    }
    
    .welcome-content p,
    .waiting-content p {
        color: #bdc3c7;
    }
    
    .message-sender {
        color: #ecf0f1;
    }
    
    .system-message {
        background: rgba(78, 205, 196, 0.2);
    }
}