/* Renor Chatbot Styles */

/* Chat Launcher */
.renor-chat-launcher {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    color: white;
}

.renor-chat-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.renor-chat-launcher svg {
    width: 28px;
    height: 28px;
}

/* Pulse animation for attention */
.renor-chat-launcher.pulse-once {
    animation: renoR-pulse 0.5s ease-out;
}

@keyframes renoR-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.renor-chat-box {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.renor-chat-box.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Chat Header */
.renor-chat-header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.renor-chat-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.renor-chat-subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
    display: block;
}

.renor-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.renor-chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

/* Messages Container */
.renor-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-anchor: none; /* evita scroll anchoring che può bloccare l'autoscroll durante il typing */
}

/* Custom scrollbar */
.renor-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.renor-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.renor-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.renor-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Messages */
.renor-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.4;
    font-size: 14px;
    word-wrap: break-word;
    animation: none !important;
}

.renor-message.user {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.renor-message.bot {
    background: #f8f9fa;
    color: #2c3e50;
    align-self: flex-start;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.renor-message.typing {
    display: flex;
    align-items: center;
    padding: 12px 16px;
}

.renor-typing-dots {
    display: flex;
    gap: 4px;
}

.renor-typing-dot {
    width: 8px;
    height: 8px;
    background: #3498db;
    border-radius: 50%;
    animation: none !important; /* no blinking */
    opacity: 0.5;
}

/* Chat Form */
.renor-chat-form {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 16px 16px;
    background: white;
}

.renor-input-container {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.renor-chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 22px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
}

.renor-chat-input:focus {
    border-color: #3498db;
}

/* Floating placeholder */
.renor-floating-placeholder {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 14px;
    pointer-events: none;
    transition: all 0.2s ease;
    background: white;
    padding: 0 4px;
}

.renor-floating-placeholder.active {
    top: 0;
    transform: translateY(-50%);
    font-size: 12px;
    color: #3498db;
}

.renor-chat-send {
    width: 44px;
    height: 44px;
    background: #e9ecef;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #6c757d;
    flex-shrink: 0;
}

.renor-chat-send:hover,
.renor-chat-send.has-text {
    background: #3498db;
    color: white;
    transform: scale(1.05);
}

.renor-chat-send svg {
    width: 18px;
    height: 18px;
}

/* reCAPTCHA info */
.renor-recaptcha-info {
    text-align: center;
    margin-top: 10px;
    font-size: 11px;
    color: #6c757d;
}

.renor-recaptcha-info a {
    color: #3498db;
    text-decoration: none;
}

/* Contact links styling */
.contact-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.contact-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

.email-link:before {
    content: "📧 ";
}

.website-link:before {
    content: "🌐 ";
}

/* Typewriter effect */
.typewriter-text {
    overflow: hidden;
    border-right: 2px solid #3498db;
    animation: renor-blink-caret 1s step-end infinite;
}

/* Ensure smooth wrapping while typing */
.typewriter-text {
    white-space: pre-wrap; /* preserve line breaks while allowing wrapping */
    word-break: break-word;
}
.typewriter-text.complete {
    white-space: normal;
}

.typewriter-text.complete {
    border-right: none;
    animation: none;
}

@keyframes renor-blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: #3498db; }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .renor-chat-launcher {
        bottom: 15px;
        left: 15px;
        width: 56px;
        height: 56px;
    }
    
    .renor-chat-box {
        bottom: 15px;
        left: 15px;
        right: 15px;
        width: auto;
        height: 70vh;
        max-height: 500px;
    }
    
    .renor-chat-header {
        padding: 16px;
    }
    
    .renor-chat-messages {
        padding: 16px;
    }
    
    .renor-chat-form {
        padding: 16px;
    }
    
    .renor-chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Focus styles for accessibility */
.renor-chat-launcher:focus,
.renor-chat-close:focus,
.renor-chat-send:focus,
.renor-chat-input:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .renor-message.bot {
        border: 2px solid #2c3e50;
    }
    
    .renor-chat-input {
        border-width: 2px;
    }
}

/* CTA bubble near launcher */
.renor-chat-cta {
    position: fixed;
    bottom: 28px;
    left: 92px; /* launcher is left:20px; width:60px; gap:12px */
    max-width: 260px;
    padding: 10px 14px;
    background: #ffffff;
    color: #1d2327;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border: 1px solid #e5e7eb;
    font-size: 12px; /* was 14px */
    line-height: 1.25;
    z-index: 9999;
    cursor: pointer;
    transition: transform .2s ease, opacity .2s ease;
}
.renor-chat-cta:hover { transform: translateY(-1px); }
.renor-chat-cta.hidden { display: none; }

@media (max-width: 480px) {
    .renor-chat-cta { left: 88px; max-width: 200px; font-size: 11px; /* was 13px */ }
}

/* Contact Links Styling */
.contact-link {
    color: #3498db !important;
    text-decoration: none !important;
    font-weight: 600;
    transition: all 0.2s ease;
    border-radius: 3px;
    padding: 1px 3px;
}

.contact-link:hover {
    background-color: #3498db;
    color: white !important;
    text-decoration: none !important;
}

.contact-link.email-link:before {
    content: "📧 ";
    margin-right: 2px;
}

.contact-link.website-link:before {
    content: "🌐 ";
    margin-right: 2px;
}

.contact-link.phone-link:before {
    content: "📞 ";
    margin-right: 2px;
}