/* MercalliBot - Stili per chat widget */

/* Floating button */
.btn-floating {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 28px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    transition: all 0.3s;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-floating:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.6);
}

.btn-floating .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 12px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat window */
.chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transition: all 0.3s ease;
}

.chat-window.open {
    display: flex;
}

/* Fullscreen mode */
.chat-window.fullscreen {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    z-index: 9999;
}

.chat-window.fullscreen .chat-messages {
    flex: 1;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-window.fullscreen .chat-header {
    border-radius: 0;
}

.bot-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
    font-size: 24px;
}

/* Header action buttons */
.btn-header-action {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.9;
    transition: all 0.2s;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-header-action:hover {
    opacity: 1;
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f5f5;
}

.message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

/* Fullscreen: wider bubbles */
.chat-window.fullscreen .message-bubble {
    max-width: 65%;
}

.message.bot .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.message.user .message-bubble {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-bubble strong {
    color: #667eea;
}

.message.bot .message-bubble code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* Product cards in chat */
.product-cards-container {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-card-mini {
    background: white;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.2s;
}

.product-card-mini:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    border-color: #667eea;
}

.product-card-mini img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 8px;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-brand {
    font-size: 11px;
    color: #667eea;
    font-weight: 600;
    text-transform: uppercase;
}

.product-name {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-code {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

.product-card-mini i.bi-chevron-right {
    color: #999;
    font-size: 16px;
}

/* Typing indicator */
#typingIndicator {
    display: none;
    padding: 16px;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Quick replies */
.quick-replies {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    overflow-x: auto;
    border-top: 1px solid #e0e0e0;
    background: white;
}

.quick-replies::-webkit-scrollbar {
    height: 4px;
}

.quick-replies::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

.quick-reply-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #667eea;
    background: white;
    color: #667eea;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
}

.quick-reply-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Input area */
.chat-input {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
    border-radius: 0 0 16px 16px;
}

.chat-window.fullscreen .chat-input {
    border-radius: 0;
}

.chat-input input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input input:focus {
    border-color: #667eea;
}

.chat-input button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #667eea;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-input button:hover {
    background: #764ba2;
    transform: scale(1.05);
}

.chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Scrollbar custom */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        bottom: 70px;
        right: 20px;
        left: 20px;
    }

    .btn-floating {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .chat-window {
        background: #1e1e1e;
    }

    .chat-messages {
        background: #2d2d2d;
    }

    .message.bot .message-bubble {
        background: #3d3d3d;
        color: #e0e0e0;
    }

    .chat-input input {
        background: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }

    .quick-reply-btn {
        background: #2d2d2d;
        border-color: #667eea;
    }
}
