#n8n-widget-root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    --primary: #FF8C42;
    --primary-dark: #FF6B00;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-light: #e2e8f0;
    --border-subtle: #334155;
}

/* Кнопка запуска — делаем её ещё сочнее */
.saas-launcher {
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, #FF8C42, #FF5C00);
    border: none;
    border-radius: 50%;
    box-shadow: 
        0 10px 30px rgba(255, 140, 66, 0.4),
        0 0 0 6px rgba(255, 140, 66, 0.15);
    cursor: pointer;
    color: white;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.saas-launcher::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.25), transparent 50%);
    opacity: 0;
    transition: opacity 0.4s;
}

.saas-launcher:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 
        0 20px 40px rgba(255, 140, 66, 0.5),
        0 0 0 8px rgba(255, 140, 66, 0.25);
}

.saas-launcher:hover::before {
    opacity: 1;
}

.saas-launcher:active {
    transform: translateY(-4px) scale(1.02);
}

/* Окно чата */
.saas-chat-window {
    display: none;
    flex-direction: column;
    width: 420px;
    height: 680px;
    max-height: 88vh;
    background: var(--bg-dark);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 
        0 30px 80px rgba(0,0,0,0.75),
        0 0 0 1px rgba(255, 140, 66, 0.15);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 140, 66, 0.18);
    animation: windowAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Шапка */
.saas-header {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 22px 28px;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 140, 66, 0.22);
    position: relative;
}

.saas-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #FF8C42, transparent);
    opacity: 0.6;
}

.saas-close-btn {
    background: rgba(255, 107, 66, 0.12);
    border: none;
    color: #cbd5e1;
    font-size: 26px;
    font-weight: 300;
    cursor: pointer;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.25s ease;
}

.saas-close-btn:hover {
    background: var(--primary);
    color: white;
    transform: rotate(90deg) scale(1.1);
}

/* Сообщения */
.saas-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: linear-gradient(to bottom, #0b1120, #0f172a);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

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

.saas-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 140, 66, 0.3);
    border-radius: 3px;
}

.saas-msg {
    max-width: 82%;
    animation: messageAppear 0.4s ease-out;
}

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

.saas-msg.user { align-self: flex-end; }
.saas-msg.bot { align-self: flex-start; }

.msg-content {
    padding: 15px 22px;
    border-radius: 22px;
    font-size: 15.8px;
    line-height: 1.55;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.saas-msg.user .msg-content {
    background: linear-gradient(135deg, #FF8C42, #FF5C00);
    color: white;
    border-bottom-right-radius: 8px;
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.saas-msg.bot .msg-content {
    background: var(--bg-card);
    color: var(--text-light);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: 8px;
}

/* Печатает... */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 14px 20px;
}

.typing-indicator span {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #64748b;
    animation: typingDots 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDots {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Поле ввода */
.saas-input-area {
    padding: 28px 32px;
    background: var(--bg-dark);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 14px;
    backdrop-filter: blur(10px);
}

#user-input {
    flex: 1;
    padding: 16px 24px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 140, 66, 0.2);
    border-radius: 50px;
    color: white;
    font-size: 15.5px;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

#user-input::placeholder {
    color: #64748b;
}

#user-input:focus {
    border-color: var(--primary);
    box-shadow: 
        0 0 0 4px rgba(255, 140, 66, 0.22),
        0 8px 25px rgba(255, 140, 66, 0.15);
    background: rgba(30, 41, 59, 0.9);
}

#send-btn {
    background: linear-gradient(135deg, #FF8C42, #FF5C00);
    color: white;
    border: none;
    padding: 0 32px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.35s ease;
    box-shadow: 0 6px 20px rgba(255, 107, 66, 0.35);
    position: relative;
    overflow: hidden;
}

#send-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(255, 107, 66, 0.45);
}

#send-btn:active {
    transform: translateY(-2px);
}

/* Мобильная адаптация (если понадобится) */
@media (max-width: 480px) {
    .saas-chat-window {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        bottom: 0;
        right: 0;
    }
    #n8n-widget-root {
        bottom: 20px;
        right: 20px;
    }
    .saas-launcher {
        width: 60px;
        height: 60px;
    }
}