@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@400;500&display=swap');

/* N8N Chat Widget Styles */
.n8n-chat-widget-container {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.n8n-chat-widget-position-right {
    right: 20px;
}

.n8n-chat-widget-position-left {
    left: 20px;
}

.n8n-chat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #45d3d3;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.n8n-chat-widget-button:hover {
    background-color: #37b2b2;
    transform: scale(1.05);
}

.n8n-chat-widget-open .n8n-chat-widget-button {
    transform: scale(0.9);
}

.n8n-chat-widget-icon {
    font-size: 24px;
}

.n8n-chat-widget-button--image {
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0;
    width: auto;
    height: auto;
}

.n8n-chat-widget-button--image:hover {
    background: transparent !important;
}

.n8n-chat-widget-button-img {
    display: block;
    width: 100px;
    height: 100px;
    object-fit: contain;
}

.n8n-chat-widget-popup {
    position: absolute;
    bottom: 0;
    width: 350px;
    height: 500px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
}

.n8n-chat-widget-popup-open {
    opacity: 1;
    transform: translateY(0);
}

.n8n-chat-widget-position-right .n8n-chat-widget-popup {
    right: 0;
}

.n8n-chat-widget-position-left .n8n-chat-widget-popup {
    left: 0;
}

.n8n-chat-widget-header {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 50px;
    background-color: #45d3d3;
    color: white;
}

.n8n-chat-widget-header-image {
    height: 47px;
    object-fit: contain;
    display: block;
}

.n8n-chat-widget-close {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
    border-radius: 4px;
}

.n8n-chat-widget-close svg rect {
    fill: white;
}

.n8n-chat-widget-close:hover {
    opacity: 0.7;
}

.n8n-chat-widget-frame-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#n8n-chat-widget-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background-color: #fff;
    transform-origin: top left;
}

/* Loading indicator */
.n8n-chat-widget-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    z-index: 1;
}

.n8n-chat-widget-loading::after {
    content: "";
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #45d3d3;
    border-radius: 50%;
    animation: n8n-chat-widget-spin 1s linear infinite;
}

@keyframes n8n-chat-widget-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Launcher row (greeting + button side by side) */
.n8n-chat-widget-launcher {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    transition: opacity 0.2s ease;
}

.n8n-chat-widget-open .n8n-chat-widget-launcher {
    opacity: 0;
    pointer-events: none;
}
.n8n-chat-widget-position-left .n8n-chat-widget-launcher {
    flex-direction: row-reverse;
}

/* Greeting bubble */
.n8n-chat-widget-greeting {
    position: relative;
    width: 460px;
    background-color: #ffffff;
    color: #333333;
    border-radius: 14px;
    padding: 18px 22px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    font-size: 14px;
    line-height: 1.6;
    animation: n8n-greeting-fadein 0.3s ease;
}

@keyframes n8n-greeting-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.n8n-chat-widget-greeting-text {
    margin: 0;
    font-family: 'Roboto Condensed', 'Arial Narrow', 'Impact', sans-serif;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.55;
    letter-spacing: 0.01em;
    font-stretch: condensed;
}

/* Triangle tail: ::before = border stroke, ::after = white fill on top */
/* Points RIGHT toward button (position-right) */
.n8n-chat-widget-greeting::before {
    content: '';
    position: absolute;
    right: -11px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 10px 0 10px 10px;
    border-style: solid;
    border-color: transparent transparent transparent #e0e0e0;
}
.n8n-chat-widget-greeting::after {
    content: '';
    position: absolute;
    right: -9px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 9px 0 9px 9px;
    border-style: solid;
    border-color: transparent transparent transparent #ffffff;
}
/* Points LEFT toward button (position-left) */
.n8n-chat-widget-position-left .n8n-chat-widget-greeting::before {
    right: auto;
    left: -11px;
    border-width: 10px 10px 10px 0;
    border-color: transparent #e0e0e0 transparent transparent;
}
.n8n-chat-widget-position-left .n8n-chat-widget-greeting::after {
    right: auto;
    left: -9px;
    border-width: 9px 9px 9px 0;
    border-color: transparent #ffffff transparent transparent;
}

/* Greeting close button */
.n8n-chat-widget-greeting-close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    /* background-color set via inline PHP CSS */
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s ease;
}
.n8n-chat-widget-greeting-close:hover {
    opacity: 0.85;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .n8n-chat-widget-popup {
        width: 100%;
        height: 80vh;
        position: fixed;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 12px 12px 0 0;
    }
    
    .n8n-chat-widget-mobile .n8n-chat-widget-button {
        width: 50px;
        height: 50px;
    }
    
    .n8n-chat-widget-mobile .n8n-chat-widget-icon {
        font-size: 20px;
    }

    /* Shrink bubble to fit small screens, keep side-by-side layout */
    .n8n-chat-widget-greeting {
        width: calc(100vw - 140px);
    }
}