/* ============================================
   VANDA AI CHAT - WORDPRESS PLUGIN STYLES
   ============================================ */

/* --- TRIGGER SECTION (Homepage) --- */
.vanda-chat-trigger-wrapper {
    max-width: 900px;
    margin: 2rem auto;
    padding: 2rem 2.5rem;
    background: #faf8f8;
    border: 1px solid #ddb5b5;
    border-radius: 12px;
}

/* Header con titolo e pulsante */
.vanda-chat-header-row {
    position: relative;
    text-align: center;
    margin-bottom: 1.5rem;
}

.vanda-chat-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1c1d1f;
    margin: 0;
    letter-spacing: 0.5px;
}

.vanda-chat-open-btn {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    background: #f8abad;
    color: #1c1d1f;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.vanda-chat-open-btn svg {
    width: 12px;
    height: 12px;
}

.vanda-chat-open-btn:hover {
    background: #E41D52;
    color: #ffffff;
}

/* Testo descrittivo */
.vanda-chat-intro {
    text-align: center;
    margin-bottom: 1.5rem;
}

.vanda-chat-intro p {
    font-size: 1.6rem;
    line-height: 1.6;
    color: #565656;
    margin-bottom: 0.75rem;
}

.vanda-chat-intro p:last-child {
    margin-bottom: 0;
}

.vanda-chat-trigger-input {
    position: relative;
    background: #ffffff;
    border: 2px solid #ddb5b5;
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.3s ease;
    min-height: 120px;
}

.vanda-chat-trigger-input:focus-within {
    border-color: #f8abad;
    box-shadow: 0 4px 12px rgba(248, 171, 173, 0.2);
}

#vandaChatTrigger {
    width: 100%;
    background: transparent;
    border: none;
    color: #565656;
    font-size: 2rem;
    font-family: inherit;
    resize: none;
    outline: none;
    height: 100%;
    min-height: 88px;
    padding-right: 50px;
    padding-bottom: 10px;
    line-height: 1.5;
}

#vandaChatTrigger::placeholder {
    color: #999;
}

.vanda-trigger-send-btn {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    background: #f8abad;
    color: #1c1d1f;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.vanda-trigger-send-btn:hover {
    background: #E41D52;
    color: #ffffff;
    transform: translateY(-2px);
}

.vanda-trigger-send-btn:active {
    transform: translateY(0);
}

/* --- OVERLAY FULLSCREEN --- */
.vanda-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease, backdrop-filter 0.4s ease;
}

.vanda-chat-overlay.active {
    opacity: 1;
    visibility: visible;
}

.vanda-chat-overlay-container {
    width: 90%;
    max-width: 900px;
    height: 90vh;
    background: #f9f5f5;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(28, 29, 31, 0.15);
    transform: scale(0.7);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.68, -0.15, 0.265, 1.15), opacity 0.4s ease;
}

.vanda-chat-overlay.active .vanda-chat-overlay-container {
    transform: scale(1);
    opacity: 1;
}

.vanda-chat-overlay.closing .vanda-chat-overlay-container {
    transform: scale(0.7);
    opacity: 0;
    transition: transform 0.4s ease-in, opacity 0.4s ease-in;
}

.vanda-chat-overlay-header {
    background: linear-gradient(180deg, #ffffff 0%, #f9f5f5 100%);
    padding: 2rem 2rem 1.5rem;
    border-bottom: 1px solid #ddb5b5;
    border-radius: 16px 16px 0 0;
    position: relative;
}

.vanda-chat-overlay-header h2 {
    color: #1c1d1f;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.vanda-chat-overlay-header .subtitle {
    color: #565656;
    font-size: 0.875rem;
    font-weight: 400;
}

.vanda-chat-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: #565656;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vanda-chat-close:hover {
    background: #f8abad;
    color: #1c1d1f;
}

/* --- CHAT STYLES (from original) --- */
* {
    box-sizing: border-box;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f9f5f5;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ddb5b5;
    border-radius: 4px;
}

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

.message {
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease-in;
}

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

.message-content {
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    line-height: 1.6;
    max-width: 85%;
}

.user-message .message-content {
    background: #f9f5f5;
    color: #1c1d1f;
    margin-left: auto;
    border: 1px solid #ddb5b5;
}

.assistant-message .message-content {
    background: rgba(248, 171, 173, 0.2);
    color: #1c1d1f;
    border: 1px solid #f8abad;
}

.assistant-message .message-content p {
    margin-bottom: 0.75rem;
}

.assistant-message .message-content p:last-child {
    margin-bottom: 0;
}

.assistant-message .message-content strong {
    color: #E41D52;
}

.message-content a {
    color: #E41D52;
    text-decoration: none;
    border-bottom: 1px solid #E41D52;
    transition: all 0.2s ease;
}

.message-content a:hover {
    color: #f8abad;
    border-bottom-color: #f8abad;
}

.message-content h2,
.message-content h3 {
    color: #1c1d1f;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
}

.message-content h2 {
    font-size: 1.25rem;
}

.message-content h3 {
    font-size: 1.1rem;
}

.message-content ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin: 0.25rem 0;
}

.message-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    display: block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.message-image:hover {
    transform: scale(1.02);
    cursor: pointer;
}

.image-wrapper {
    margin: 1rem 0;
}

.image-error {
    background: #2d2d2d;
    border: 1px solid #ff6b6b;
    border-radius: 8px;
    padding: 1rem;
    color: #ff6b6b;
    text-align: center;
}

.image-error a {
    color: #74c0fc;
    text-decoration: underline;
}

.chat-input-container {
    padding: 1.5rem 2rem 2rem;
    background: #ffffff;
    border-top: 1px solid #ddb5b5;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    background: #f9f5f5;
    border: 1px solid #ddb5b5;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    transition: border-color 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: #f8abad;
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    color: #565656;
    font-size: 2rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.5;
    -webkit-appearance: none;
    appearance: none;
}

#userInput::placeholder {
    color: #565656;
}

#userInput::-webkit-scrollbar {
    width: 6px;
}

#userInput::-webkit-scrollbar-track {
    background: transparent;
}

#userInput::-webkit-scrollbar-thumb {
    background: #ddb5b5;
    border-radius: 3px;
}

#sendButton {
    background: #f8abad;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#sendButton:hover:not(:disabled) {
    background: #E41D52;
    transform: translateY(-1px);
}

#sendButton:active:not(:disabled) {
    transform: translateY(0);
}

#sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.typing-indicator {
    opacity: 0.7;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

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

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

.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;
    }
}

/* --- LIGHTBOX --- */
.vanda-image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.vanda-image-lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    cursor: default;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 40px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 10;
    line-height: 1;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 10;
}

.lightbox-caption {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    max-width: 80%;
    text-align: center;
    z-index: 10;
    line-height: 1.4;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .vanda-chat-trigger-wrapper {
        padding: 1.5rem 1rem;
        max-width: 100%;
    }

    /* Header mobile */
    .vanda-chat-header-row {
        margin-bottom: 1.25rem;
    }

    .vanda-chat-title {
        font-size: 1.25rem;
    }

    .vanda-chat-open-btn {
        width: 20px;
        height: 20px;
    }

    .vanda-chat-open-btn svg {
        width: 10px;
        height: 10px;
    }

    .vanda-chat-intro {
        margin-bottom: 1.25rem;
    }

    .vanda-chat-intro p {
        font-size: 0.9rem;
    }

    .vanda-chat-trigger-input {
        min-height: 100px;
        padding: 0.75rem;
    }

    #vandaChatTrigger {
        min-height: 68px;
        font-size: 16px; /* Previene zoom su iOS */
    }

    .vanda-trigger-send-btn {
        width: 36px;
        height: 36px;
        bottom: 0.625rem;
        right: 0.625rem;
    }

    .vanda-trigger-send-btn svg {
        width: 18px;
        height: 18px;
    }

    .vanda-chat-overlay-container {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .vanda-chat-overlay-header {
        padding: 1rem 1rem 0.75rem;
        border-radius: 0;
    }

    .vanda-chat-overlay-header h2 {
        font-size: 1.25rem;
    }

    .vanda-chat-overlay-header .subtitle {
        font-size: 0.8rem;
    }

    .vanda-chat-close {
        top: 1rem;
        right: 1rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .message-content {
        max-width: 95%;
        padding: 0.875rem 1rem;
        font-size: 0.9375rem;
    }

    .chat-input-container {
        padding: 0.75rem 1rem;
    }

    .input-wrapper {
        padding: 0.625rem 0.75rem;
        gap: 0.75rem;
    }

    #userInput {
        font-size: 1.5rem; /* Più grande ma adeguato per mobile */
        min-height: 20px;
    }

    #sendButton {
        width: 36px;
        height: 36px;
    }

    #sendButton svg {
        width: 20px;
        height: 20px;
    }

    /* Lightbox mobile */
    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 30px;
    }

    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-counter {
        font-size: 12px;
        padding: 6px 12px;
        bottom: 60px;
    }

    .lightbox-caption {
        font-size: 12px;
        padding: 8px 12px;
        max-width: 90%;
        bottom: 10px;
    }
}

/* ============================================
   IMAGES GRID & COLOR SWATCHES
   ============================================ */

.image-wrapper {
    display: inline-block;
    margin: 4px 8px 4px 0;
    border-radius: 8px;
    overflow: hidden;
    vertical-align: middle;
    line-height: 0;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin: 15px 0;
    padding: 0;
}

.images-grid .image-wrapper {
    margin: 0;
    width: 100%;
    display: block;
    line-height: 0;
}

.images-grid .message-image {
    width: 100%;
    height: 150px;
    max-width: none !important;
    object-fit: cover;
    margin: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.3s ease-in;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: block;
}

.images-grid .message-image:hover {
    transform: scale(1.05);
}

.color-swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    vertical-align: middle;
    margin: 0 4px;
    cursor: help;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 768px) {
    .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 5px;
    }

    .images-grid .message-image {
        height: 90px;
    }

    .message-image {
        max-width: 120px;
    }
}
