/**
 * CARLO CHAT - Styles v2.3.0
 * Mobilificio Promessi Sposi - Colori azzurri pastello light
 */

/* PULSANTE AVATAR - PIU' IN EVIDENZA */
#carlo-chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 78px;
    height: 78px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7EC8E3 0%, #5FB3D1 100%);
    box-shadow: 0 8px 25px rgba(126, 200, 227, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    transition: all 0.3s ease;
    opacity: 0;
    border: 4px solid #fff;
}

#carlo-chat-button.carlo-show {
    opacity: 1;
    animation: slideInButton 1s ease-out forwards, carloGlow 2.8s ease-in-out 1s infinite;
}

@keyframes slideInButton {
    0% { right: -90px; transform: scale(0.8); }
    60% { right: 25px; transform: scale(1.1); }
    100% { right: 20px; transform: scale(1); }
}

@keyframes carloGlow {
    0%, 100% { box-shadow: 0 8px 25px rgba(126, 200, 227, 0.5); }
    50% { box-shadow: 0 8px 34px rgba(126, 200, 227, 0.85), 0 0 0 8px rgba(126, 200, 227, 0.15); }
}

#carlo-chat-button img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

#carlo-chat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 30px rgba(126, 200, 227, 0.7);
}

/* BADGE NOTIFICA CON NUMERO 1 */
.carlo-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4757;
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

/* FUMETTO - AGGANCIATO E ALLINEATO AL PULSANTE AVATAR */
#carlo-help-bubble {
    position: fixed;
    bottom: 32px;
    right: -360px;
    background: white;
    padding: 14px 20px;
    padding-right: 34px;
    border-radius: 18px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.15);
    z-index: 99997;
    opacity: 0;
    font-weight: 600;
    font-size: 15px;
    color: #2b2b2b;
    max-width: 230px;
    transition: all 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

#carlo-help-bubble.carlo-show {
    right: 108px;
    opacity: 1;
}

#carlo-help-bubble .bubble-icon {
    font-size: 18px;
    line-height: 1;
}

#carlo-help-bubble .bubble-text {
    line-height: 1.3;
}

/* Coda del fumetto: punta esattamente verso il pulsante avatar */
#carlo-help-bubble:after {
    content: '';
    position: absolute;
    top: 50%;
    right: -9px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-left: 10px solid white;
}

#carlo-help-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.2);
}

/* X DI CHIUSURA SUL FUMETTO - IN OVERLAY NELL'ANGOLO */
#carlo-bubble-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    z-index: 99998;
    transition: all 0.3s ease;
    line-height: 1;
}

#carlo-bubble-close:hover {
    background: #ff2f40;
    transform: scale(1.1);
}

/* CHAT CONTAINER */
#carlo-chat-widget {
    position: fixed;
    bottom: -700px;
    right: 15px;
    width: 400px;
    max-height: calc(100vh - 20px);
    z-index: 99999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#carlo-chat-widget.carlo-show {
    opacity: 1;
    animation: slideUpChat 1s ease-out forwards;
}

@keyframes slideUpChat {
    0% { bottom: -700px; transform: scale(0.8); }
    50% { bottom: 15px; transform: scale(1.05); }
    70% { bottom: 0px; transform: scale(0.98); }
    100% { bottom: 10px; transform: scale(1); }
}

#carlo-chat-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    height: 650px;
    overflow: hidden;
}

/* HEADER - AZZURRO PASTELLO COME VANNY */
#carlo-chat-header {
    background: linear-gradient(135deg, #7EC8E3 0%, #5FB3D1 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.carlo-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.carlo-header-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.carlo-header-text h3 {
    margin: 0;
    font-size: 20px;
}

.carlo-header-text p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
}

/* X DI CHIUSURA - PERFETTAMENTE TONDA */
#carlo-chat-close {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    color: white;
    min-width: 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-weight: bold;
    flex-shrink: 0;
    padding: 0;
}

#carlo-chat-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg);
}

/* MESSAGES */
#carlo-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.carlo-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.carlo-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.carlo-message-content {
    background: white;
    padding: 16px 18px;
    border-radius: 15px;
    max-width: 85%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    line-height: 1.6;
    color: #333;
}

/* INPUT CONTAINER */
.carlo-input-container {
    margin-bottom: 20px;
    animation: fadeIn 0.4s ease;
}

.carlo-user-message {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.carlo-user-message-content {
    background: linear-gradient(135deg, #7EC8E3 0%, #5FB3D1 100%);
    color: white;
    padding: 12px 18px;
    border-radius: 15px;
    max-width: 70%;
    box-shadow: 0 2px 8px rgba(126, 200, 227, 0.3);
}

/* TYPING INDICATOR */
.carlo-typing-indicator {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.carlo-typing-dots {
    background: white;
    padding: 15px 20px;
    border-radius: 15px;
    display: flex;
    gap: 5px;
}

.carlo-typing-dots span {
    width: 8px;
    height: 8px;
    background: #7EC8E3;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.carlo-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.carlo-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* OPTIONS - AZZURRO PASTELLO */
.carlo-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.carlo-options.carlo-family-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.carlo-option-btn {
    background: linear-gradient(135deg, #E8F4F8 0%, #D4EBF3 100%);
    border: 2px solid #7EC8E3;
    color: #1a1a1a;
    padding: 14px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.carlo-option-btn:hover {
    background: linear-gradient(135deg, #7EC8E3 0%, #5FB3D1 100%);
    color: white;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(126, 200, 227, 0.4);
}

.carlo-option-icon {
    font-size: 20px;
}

/* MULTISELECT */
.carlo-multiselect {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.carlo-multiselect-option {
    background: linear-gradient(135deg, #F0F8FB 0%, #E3F2F7 100%);
    border: 2px solid #B8DEEB;
    color: #1a1a1a;
    padding: 14px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.carlo-multiselect-option:hover {
    border-color: #7EC8E3;
    background: linear-gradient(135deg, #D4EBF3 0%, #C5E4EE 100%);
    transform: translateX(3px);
}

.carlo-multiselect-option.selected {
    background: linear-gradient(135deg, #7EC8E3 0%, #5FB3D1 100%);
    border-color: #7EC8E3;
    color: white;
}

.carlo-multiselect-hint {
    font-size: 13px;
    color: #666;
    margin-top: 8px;
    font-style: italic;
    text-align: center;
}

/* INPUTS - PIÙ ARIOSI E SPAZIOSI */
.carlo-input-field {
    width: 100%;
    padding: 18px 20px;
    border: 2px solid #7EC8E3;
    border-radius: 12px;
    font-size: 15px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    background-color: #ffffff;
    color: #333333;
    font-weight: 500;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.carlo-input-field::placeholder {
    color: #999999;
    font-weight: 400;
}

.carlo-input-field:focus {
    outline: none;
    border-color: #5FB3D1;
    box-shadow: 0 0 0 3px rgba(126, 200, 227, 0.15);
}

.carlo-submit-btn {
    background: linear-gradient(135deg, #7EC8E3 0%, #5FB3D1 100%);
    color: white;
    border: none;
    padding: 18px 28px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s ease;
}

.carlo-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(126, 200, 227, 0.4);
}

.carlo-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* CHECKBOX - PIÙ ARIOSO E SPAZIATO */
.carlo-checkbox-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 18px 0;
    text-align: left;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 10px;
}

.carlo-checkbox-wrapper input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.carlo-checkbox-wrapper label {
    font-size: 14px;
    color: #555;
    cursor: pointer;
    line-height: 1.6;
}

/* PRIVACY TEXT */
.carlo-privacy-text {
    font-size: 12px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 16px;
    text-align: center;
}

.carlo-privacy-text a {
    color: #7EC8E3;
    text-decoration: none;
    font-weight: 600;
}

.carlo-privacy-text a:hover {
    text-decoration: underline;
}

/* SUCCESS & ERROR */
.carlo-success-message {
    background: #4caf50;
    color: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    font-size: 16px;
    line-height: 1.6;
    animation: fadeIn 0.5s ease;
}

.carlo-error {
    background: #ff4757;
    color: white;
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 12px;
    text-align: center;
}

/* LOADING */
.carlo-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* SCROLLBAR */
#carlo-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#carlo-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#carlo-chat-messages::-webkit-scrollbar-thumb {
    background: #7EC8E3;
    border-radius: 3px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    #carlo-chat-widget {
        width: calc(100% - 20px);
        right: 10px;
        left: 10px;
        bottom: -100vh;
    }

    #carlo-chat-widget.carlo-show {
        animation: slideUpMobile 0.8s ease-out forwards;
    }

    @keyframes slideUpMobile {
        100% { bottom: 5px; }
    }

    #carlo-chat-container {
        height: calc(100vh - 20px);
        max-height: none;
    }

    #carlo-chat-button {
        bottom: 15px;
        right: 15px;
        width: 68px;
        height: 68px;
    }

    #carlo-help-bubble {
        bottom: 26px;
        right: -300px;
        max-width: 190px;
        font-size: 14px;
        padding: 12px 16px;
        padding-right: 30px;
    }

    #carlo-help-bubble.carlo-show {
        right: 92px;
    }
}