/* Marrison Assistant Site Agent CSS - Modern Design */

.marrison-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    --marrison-mobile-viewport-height: 100vh;
    --marrison-mobile-viewport-top: 0px;
}

/* Posizioni */
.marrison-bottom-right {
    bottom: 20px;
    right: 20px;
}

.marrison-bottom-left {
    bottom: 20px;
    left: 20px;
}

.marrison-top-right {
    top: 20px;
    right: 20px;
}

.marrison-top-left {
    top: 20px;
    left: 20px;
}

/* Chat Button - Modern Design */
.marrison-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    /* Il colore arriva dalle impostazioni tramite la variabile sul widget.
       !important evita che il tema del sito sovrascriva l'icona flottante. */
    background: var(--marrison-icon-color, linear-gradient(135deg, #667eea 0%, #764ba2 100%)) !important;
    border: none;
    outline: none;
}

.marrison-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.marrison-chat-button:active {
    transform: scale(0.95);
}

.marrison-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

.marrison-chat-help-bubble {
    position: absolute;
    right: 72px;
    bottom: 10px;
    min-width: 240px;
    max-width: min(420px, calc(100vw - 120px));
    padding: 10px 14px;
    border-radius: 14px;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-sizing: border-box;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    hyphens: none;
    -webkit-hyphens: none;
    -ms-hyphens: none;
    text-align: left;
}

.marrison-chat-help-bubble::after {
    content: '';
    position: absolute;
    right: -6px;
    bottom: 16px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    transform: rotate(-45deg);
}

.marrison-bottom-left .marrison-chat-help-bubble,
.marrison-top-left .marrison-chat-help-bubble {
    right: auto;
    left: 72px;
}

.marrison-bottom-left .marrison-chat-help-bubble::after,
.marrison-top-left .marrison-chat-help-bubble::after {
    right: auto;
    left: -6px;
    border-right: 0;
    border-bottom: 0;
    border-left: 1px solid #e2e8f0;
    border-top: 1px solid #e2e8f0;
}

.marrison-chat-button.show-help-bubble .marrison-chat-help-bubble {
    opacity: 1;
    transform: translateY(0);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Chat Window - Modern Design */
.marrison-chat-window {
    position: absolute;
    bottom: 80px;
    width: 520px;
    height: calc(100vh - 200px);
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 200px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.marrison-chat-window.expanded {
    width: min(520px, calc(100vw - 40px));
    height: calc(100vh - 200px);
    max-height: calc(100vh - 200px);
}

/* La modalità ridotta non è più prevista: la chat usa sempre l'altezza desktop disponibile. */
.marrison-chat-expand {
    display: none !important;
}

/* Full-screen desktop: modal chat estesa a tutta la viewport */
@media (min-width: 481px) {
    body.marrison-chat-fullscreen-open {
        overflow: hidden !important;
    }

    #marrison-chat-widget.marrison-fullscreen-active {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 2147483647 !important;
        pointer-events: none;
    }

    #marrison-chat-widget.marrison-fullscreen-active .marrison-chat-button {
        display: none !important;
    }

    #marrison-chat-widget.marrison-fullscreen-active .marrison-chat-window,
    .marrison-chat-window.fullscreen {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        min-width: 100vw !important;
        min-height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
        transform: none !important;
        animation: none !important;
        transform-origin: center !important;
        z-index: 2147483647 !important;
        pointer-events: auto;
    }
}

.marrison-bottom-right .marrison-chat-window {
    right: 0;
    transform-origin: bottom right;
}

.marrison-bottom-left .marrison-chat-window {
    left: 0;
    transform-origin: bottom left;
}

.marrison-top-right .marrison-chat-window {
    right: 0;
    top: 80px;
    bottom: auto;
    transform-origin: top right;
}

.marrison-top-left .marrison-chat-window {
    left: 0;
    top: 80px;
    bottom: auto;
    transform-origin: top left;
}

.marrison-chat-window.open {
    display: flex;
    animation: chatOpen 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.marrison-chat-window.closing {
    animation: chatClose 0.32s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes chatOpen {
    0%   { opacity: 0; transform: scale(0.35); }
    60%  { opacity: 1; transform: scale(1.04); }
    80%  { transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes chatClose {
    0%   { opacity: 1; transform: scale(1); }
    20%  { transform: scale(1.03); }
    100% { opacity: 0; transform: scale(0.35); }
}

/* Header - Clean Card Design */
.marrison-chat-header {
    padding: 14px 16px 14px 16px;
    background: #ffffff;
    color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f1f5f9;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    flex-shrink: 0;
}

/* Avatar circle — usa il colore testata configurato */
.marrison-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.marrison-header-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.marrison-avatar-img {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    object-fit: contain;
}

/* Pallino verde online sull'avatar */
.marrison-avatar-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 11px;
    height: 11px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px rgba(34,197,94,0.3);
    animation: avatarPulse 2.5s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(34,197,94,0.3); }
    50%       { box-shadow: 0 0 0 4px rgba(34,197,94,0.15); }
}

/* Testo header */
.marrison-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.marrison-header-name {
    font-weight: 700;
    font-size: 15px;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.marrison-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #94a3b8;
}

.marrison-status-dot {
    display: none;
}

.marrison-guest-label {
    opacity: 0.75;
}

/* Close button — minimal */
.marrison-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

#marrison-chat-widget .marrison-header-actions .marrison-chat-control {
    appearance: none !important;
    -webkit-appearance: none !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border: 0 !important;
    box-shadow: none !important;
    color: #64748b !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 26px !important;
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    min-height: 26px !important;
    max-width: 26px !important;
    max-height: 26px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 5px !important;
    font-size: 0 !important;
    line-height: 0 !important;
    text-indent: 0 !important;
    text-shadow: none !important;
    transition: color 0.15s ease, background-color 0.15s ease !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-action-icon {
    width: 15px !important;
    height: 15px !important;
    display: block !important;
    fill: none;
    stroke: currentColor !important;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
    opacity: 1 !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-chat-new {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 94px !important;
    max-width: 116px !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    padding: 0 9px !important;
    gap: 5px !important;
    border: 1px solid rgba(15, 118, 110, 0.22) !important;
    border-radius: 999px !important;
    background: #f8fafc !important;
    color: #0f766e !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-chat-new .marrison-action-icon {
    width: 14px !important;
    height: 14px !important;
    flex: 0 0 14px !important;
    stroke-width: 2 !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-chat-new-label {
    display: inline-block !important;
    max-width: 74px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 12px !important;
    line-height: 1 !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-chat-new-label-short {
    display: none !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-chat-close .marrison-action-icon {
    width: 16px !important;
    height: 16px !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-icon-close,
#marrison-chat-widget .marrison-header-actions .marrison-chat-expand.is-active .marrison-icon-open,
#marrison-chat-widget .marrison-header-actions .marrison-chat-fullscreen.is-active .marrison-icon-open {
    display: none !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-chat-expand.is-active .marrison-icon-close,
#marrison-chat-widget .marrison-header-actions .marrison-chat-fullscreen.is-active .marrison-icon-close {
    display: block !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-chat-control:hover {
    color: #475569 !important;
    background-color: #f1f5f9 !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-chat-new:hover {
    color: #0f766e !important;
    background-color: #ecfdf5 !important;
    border-color: rgba(15, 118, 110, 0.36) !important;
    box-shadow: 0 1px 5px rgba(15, 118, 110, 0.16) !important;
}

#marrison-chat-widget .marrison-header-actions .marrison-chat-control:focus-visible {
    outline: 2px solid #cbd5e1;
    outline-offset: 2px;
}

/* Messages Area - Modern Design */
.marrison-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    scroll-behavior: smooth;
}

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

.marrison-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.marrison-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Message Bubbles - Modern Design */
.marrison-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.3s ease;
}

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

.marrison-message.marrison-bot {
    align-items: flex-start;
}

.marrison-message.marrison-user {
    align-items: flex-end;
}

.marrison-message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.marrison-message-image {
    margin: 14px 0 16px;
    max-width: 100%;
}

.marrison-message-content .marrison-message-image:first-child {
    margin-top: 0;
}

.marrison-message-content .marrison-message-image + br {
    display: none;
}

.marrison-message-image img {
    display: block;
    max-width: 100%;
    width: auto;
    max-height: 220px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    object-fit: cover;
}

.marrison-bot .marrison-message-content {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.marrison-user .marrison-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.marrison-message-time {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
    padding: 0 4px;
}

.marrison-user .marrison-message-time {
    text-align: right;
}

/* Product results are regular chat bubbles, not nested cards. */
.marrison-product-message .marrison-message-content {
    border-left: 3px solid var(--marrison-button-color, #667eea) !important;
}

.marrison-product-message .marrison-message-content strong {
    color: #0f172a;
}

.marrison-product-message .marrison-message-image img {
    max-height: 180px;
}

.marrison-product-message .marrison-message-content > a:last-child {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 7px 11px;
    border: 1px solid var(--marrison-button-color, #667eea) !important;
    border-radius: 999px;
    background: var(--marrison-button-color, #667eea) !important;
    color: #ffffff !important;
    font-size: 12px;
    font-weight: 700 !important;
    line-height: 1.2;
    text-decoration: none !important;
}

.marrison-product-message .marrison-message-content > a:last-child:hover {
    background: var(--marrison-button-color-hover, #5a67d8) !important;
    color: #ffffff !important;
}

/* Links in messages */
.marrison-message-content a {
    color: var(--marrison-button-color, #667eea);
    text-decoration: underline;
    font-weight: 500;
}

.marrison-message-content a:hover {
    color: var(--marrison-button-color-hover, #5a67d8);
}

/* Product result card: keeps the product visually separate from the answer. */
.marrison-product-card {
    display: grid;
    grid-template-columns: 1fr;
    gap: 13px;
    align-items: stretch;
    margin: 2px 0 12px;
    padding: 10px;
    border: 1px solid #dbe5e1;
    border-radius: 14px;
    background: linear-gradient(135deg, #f8fffc 0%, #f1f8f5 100%);
    box-shadow: 0 3px 10px rgba(15, 118, 110, 0.08);
}

.marrison-product-card-media {
    display: block;
    min-width: 0;
    overflow: hidden;
    border-radius: 10px;
    background: #e7efe9;
    text-decoration: none !important;
}

.marrison-product-card-media img {
    display: block;
    width: 100%;
    height: 160px;
    min-height: 0;
    max-height: none;
    object-fit: cover;
    border: 0 !important;
    border-radius: 10px;
}

.marrison-product-card-body {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
}

.marrison-product-card-no-image .marrison-product-card-body {
    grid-column: 1;
}

.marrison-product-card-title {
    display: block;
    color: #0f172a !important;
    font-size: 16px;
    font-weight: 700 !important;
    line-height: 1.25;
    text-decoration: none !important;
}

.marrison-product-card-title:hover {
    color: #0f172a !important;
    text-decoration: underline !important;
}

.marrison-product-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.marrison-product-card-category,
.marrison-product-card-price {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
}

.marrison-product-card-category {
    color: #365c52;
    background: #e1f1e9;
}

.marrison-product-card-price {
    color: #14532d;
    background: #dcfce7;
}

.marrison-product-card-description {
    color: #334155;
    font-size: 12px;
    line-height: 1.45;
}

.marrison-product-card-components {
    color: #475569;
    font-size: 11px;
    line-height: 1.4;
}

.marrison-product-card-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    padding: 6px 10px;
    border: 1px solid var(--marrison-button-color, #667eea) !important;
    border-radius: 999px;
    background: var(--marrison-button-color, #667eea) !important;
    color: #ffffff !important;
    font-size: 11px;
    font-weight: 700 !important;
    line-height: 1.2;
    text-decoration: none !important;
}

.marrison-product-card-button:hover {
    background: var(--marrison-button-color-hover, #5a67d8) !important;
    color: #ffffff !important;
}

@media (min-width: 481px) {
    .marrison-chat-window.expanded .marrison-product-card {
        grid-template-columns: 164px minmax(0, 1fr);
        gap: 16px;
        padding: 12px;
    }

    .marrison-chat-window.expanded .marrison-product-card-media img {
        height: 164px;
    }

    #marrison-chat-widget.marrison-fullscreen-active .marrison-product-card {
        grid-template-columns: 220px minmax(0, 1fr);
        gap: 20px;
        padding: 16px;
        border-radius: 18px;
    }

    #marrison-chat-widget.marrison-fullscreen-active .marrison-product-card-media img {
        height: 220px;
    }

    #marrison-chat-widget.marrison-fullscreen-active .marrison-product-card-title {
        font-size: 19px;
    }

    #marrison-chat-widget.marrison-fullscreen-active .marrison-product-card-description {
        font-size: 14px;
    }

    #marrison-chat-widget.marrison-fullscreen-active .marrison-product-card-components {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .marrison-product-card {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 8px;
    }

    .marrison-product-card-media img {
        height: 150px;
    }

    .marrison-product-card-title {
        font-size: 14px;
    }

    .marrison-product-card-description {
        font-size: 11px;
    }
}

/* Typing Indicator - Modern Design */
.marrison-typing {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 80px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.marrison-typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

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

.marrison-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Input Area - Design Semplice e Funzionale */
.marrison-chat-input {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.marrison-chat-textarea {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    resize: none;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
    min-height: 44px;
    max-height: 120px;
    background: white;
    outline: none;
    color: #333;
    box-sizing: border-box;
}

.marrison-chat-textarea:focus {
    border-color: var(--marrison-button-color, #667eea);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.marrison-chat-textarea::placeholder {
    color: #999;
    opacity: 1;
}

.marrison-send-button {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: none;
    background: var(--marrison-button-color, #667eea);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 16px;
}

.marrison-send-button:hover {
    background: var(--marrison-button-color-hover, #5a67d8);
}

.marrison-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive Design — Mobile full-screen */
@media (max-width: 480px) {
    /* Bottone: rimane nel suo angolo, contenitore non si allarga */
    body.marrison-chat-widget-open {
        overflow: hidden !important;
        width: 100%;
        overscroll-behavior: contain;
    }

    .marrison-bottom-right { bottom: 14px; right: 14px; left: auto; }
    .marrison-bottom-left  { bottom: 14px; left: 14px;  right: auto; }
    .marrison-top-right    { top: 14px;    right: 14px; left: auto; }
    .marrison-top-left     { top: 14px;    left: 14px;  right: auto; }

    .marrison-chat-button {
        width: 48px;
        height: 48px;
    }

    .marrison-chat-button > svg {
        width: 26px;
        height: 26px;
    }

    .marrison-chat-badge {
        top: -1px;
        right: -1px;
        width: 18px;
        height: 18px;
        border-width: 2px;
        font-size: 10px;
    }

    .marrison-chat-help-bubble {
        display: none !important;
    }

    .marrison-bottom-left .marrison-chat-help-bubble,
    .marrison-top-left .marrison-chat-help-bubble {
        left: 58px;
        right: auto;
    }

    /* Finestra chat: full-screen */
    .marrison-chat-window,
    .marrison-bottom-right .marrison-chat-window,
    .marrison-bottom-left  .marrison-chat-window,
    .marrison-top-right    .marrison-chat-window,
    .marrison-top-left     .marrison-chat-window {
        position: fixed !important;
        top: var(--marrison-mobile-viewport-top, 0px);
        left: 0;
        right: 0;
        bottom: auto;
        width: 100vw;
        height: var(--marrison-mobile-viewport-height, 100dvh);
        max-width: 100vw;
        max-height: var(--marrison-mobile-viewport-height, 100dvh);
        border-radius: 0;
        transform-origin: center bottom;
        overflow: hidden;
    }

    .marrison-chat-window.expanded {
        width: 100vw;
        height: var(--marrison-mobile-viewport-height, 100dvh);
        max-height: var(--marrison-mobile-viewport-height, 100dvh);
    }

    /* Su mobile la chat è già full-screen: il comando non serve. */
    #marrison-chat-widget .marrison-header-actions .marrison-chat-fullscreen {
        display: none !important;
    }

    .marrison-chat-messages {
        padding: 14px 16px;
    }

    .marrison-chat-input {
        padding: 10px 12px;
        gap: 8px;
        /* safe area per iPhone notch/home bar */
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .marrison-message-content {
        max-width: 88%;
        font-size: 14px;
    }

    .marrison-chat-header {
        padding: 12px 16px;
        /* safe area per iPhone status bar */
        padding-top: max(12px, env(safe-area-inset-top));
        gap: 8px;
    }

    .marrison-header-left {
        gap: 8px;
    }

    .marrison-header-avatar {
        width: 38px;
        height: 38px;
    }

    .marrison-avatar-img {
        width: 22px;
        height: 22px;
    }

    #marrison-chat-widget .marrison-header-actions .marrison-chat-new {
        min-width: 72px !important;
        max-width: 80px !important;
        height: 30px !important;
        padding: 0 8px !important;
    }

    #marrison-chat-widget .marrison-header-actions .marrison-chat-new-label-full {
        display: none !important;
    }

    #marrison-chat-widget .marrison-header-actions .marrison-chat-new-label-short {
        display: inline-block !important;
        max-width: 44px !important;
    }
}

/* Welcome Message Special Styling */
.marrison-welcome-message {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    border: 1px solid #0ea5e9 !important;
    color: #0c4a6e !important;
}

.marrison-tip-message {
    background: linear-gradient(135deg, #fefce8 0%, #fef3c7 100%) !important;
    border: 1px solid #f59e0b !important;
    color: #92400e !important;
}

/* Loading States */
.marrison-loading {
    pointer-events: none;
    opacity: 0.7;
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .marrison-chat-window {
        background: #1e293b;
        border-color: #334155;
    }
    
    .marrison-chat-messages {
        background: #0f172a;
    }
    
    .marrison-chat-input {
        background: #1e293b;
        border-color: #334155;
    }
    
    .marrison-chat-textarea {
        background: #0f172a;
        border-color: #334155;
        color: #e2e8f0;
    }
    
    .marrison-bot .marrison-message-content {
        background: #334155;
        color: #e2e8f0;
        border-color: #475569;
    }

    .marrison-intent-btn {
        background: #1e293b;
        color: var(--marrison-button-color, #667eea);
        border-color: var(--marrison-button-color, #667eea);
    }
}

/* Bottoni routing categoria (quick-reply) */
.marrison-intent-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0 10px 0;
}

.marrison-intent-btn {
    background: #f1f5f9;
    border: 1.5px solid var(--marrison-button-color, #667eea);
    color: var(--marrison-button-color, #667eea);
    border-radius: 14px;
    padding: 5px 11px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    line-height: 1.3;
    white-space: nowrap;
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Hover solo su dispositivi che supportano hover reale (no touch stuck) */
@media (hover: hover) {
    .marrison-intent-btn:hover {
        background: var(--marrison-button-color, #667eea);
        color: #ffffff;
    }
}

.marrison-intent-btn:active {
    background: var(--marrison-button-color, #667eea);
    color: #ffffff;
    opacity: 0.85;
}

/* Privacy policy notice */
.marrison-privacy-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 12px;
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
    flex-shrink: 0;
}

.marrison-privacy-notice a {
    color: var(--marrison-button-color, #667eea);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.marrison-privacy-notice a:hover {
    opacity: 0.8;
}

.marrison-privacy-close {
    background: transparent !important;
    background-image: none !important;
    border: none;
    box-shadow: none !important;
    cursor: pointer;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.marrison-privacy-close:hover {
    color: inherit;
}
