.ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2147483647;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif !important;
}

.ai-chat-widget * {
    font-family: inherit !important;
    box-sizing: border-box;
}

/* Chat Toggle Button */
.ai-chat-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px 8px 8px;
    background: linear-gradient(135deg, #197bff 0%, #0056d2 100%);
    border: none;
    border-radius: 50px;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    font-size: 15px;
    font-weight: 600;
}

.ai-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #0056d2 0%, #197bff 100%);
}

.chat-icon {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    background: white;
    padding: 4px;
}

.toggle-logo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.chat-badge {
    display: flex;
    align-items: center;
    color: white;
    font-weight: 500;
}

.chat-badge-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.chat-badge-small {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 400;
}

.chat-badge-bold {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-chat-toggle .close-icon {
    display: none;
    width: 24px;
    height: 24px;
    color: white;
}

.ai-chat-widget.active .chat-icon {
    display: none;
}

.ai-chat-widget.active .chat-badge {
    display: none;
}

.ai-chat-widget.active .ai-chat-toggle {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    padding: 12px;
    width: 56px;
    height: 56px;
    justify-content: center;
}

.ai-chat-widget.active .ai-chat-toggle .close-icon {
    display: block;
}

/* Welcome Notification */
.welcome-notification {
    position: absolute;
    bottom: 65px;
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    min-width: 320px;
    max-width: 400px;
    border: 1px solid #e2e8f0;
    display: none;
    animation: notificationSlide 0.5s ease;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 99999998;
}

.welcome-notification::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 80px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 8px 0 8px;
    border-color: white transparent transparent transparent;
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.05));
}

.welcome-notification::before {
    content: '';
    position: absolute;
    bottom: -9px;
    right: 79px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 9px 9px 0 9px;
    border-color: #e2e8f0 transparent transparent transparent;
}

.welcome-notification:hover {
    transform: scale(1.02);
}

.welcome-notification.show {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

@keyframes notificationSlide {
    0% {
        opacity: 0;
        transform: translateX(100px);
    }

    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
}

.notification-emoji {
    font-size: 28px;
    animation: wave 1s ease-in-out infinite;
}

@keyframes wave {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-15deg);
    }

    75% {
        transform: rotate(15deg);
    }
}

.notification-text {
    flex: 1;
}

.notification-text strong {
    display: block;
    color: #197bff;
    font-size: 15px;
    margin-bottom: 4px;
    font-weight: 600;
}

.notification-text p {
    color: #64748b;
    font-size: 13px;
    margin: 0;
    line-height: 1.4;
}

.notification-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 24px;
    color: #94a3b8;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color 0.2s ease;
}

.notification-close:hover {
    color: #475569;
}

.ai-chat-widget.active .welcome-notification {
    display: none !important;
}

/* Chat Window */
.ai-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 400px;
    height: 600px;
    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 #d1d1d1;
    z-index: 2147483647;
}

.ai-chat-widget.active .ai-chat-window {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, #197bff 0%, #0056d2 100%);
    color: white;
    gap: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
    background: white;
    padding: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-text {
    flex: 1;
}

.header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.header-text .status {
    margin: 1px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

.header-text .status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.ai-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

.ai-chat-close svg {
    width: 18px;
    height: 18px;
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    position: relative;
}

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

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

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

/* User Info Form */
.user-info-form {
    text-align: center;
    padding: 30px 20px 20px;
    background: #ffffff;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #e5e7eb;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-info-form.show {
    opacity: 1;
    transform: translateY(0);
}

.user-info-form h4 {
    margin: 16px 0 24px 0;
    font-size: 20px;
    color: #197bff;
    font-weight: 600;
}

.user-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-input {
    padding: 14px 18px;
    border: 2px solid #cbd5e1;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    outline: none;
    background: #f8f9fa;
}

.form-input:focus {
    border-color: #197bff;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(25, 123, 255, 0.1);
}

.form-input::placeholder {
    color: #9ca3af;
}

.form-submit {
    padding: 14px 24px;
    background: linear-gradient(135deg, #197bff 0%, #0056d2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.form-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(25, 123, 255, 0.4);
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 30px 20px 20px;
    background: #ffffff;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.welcome-message.hiding {
    opacity: 0;
    transform: scale(0.95);
}

.welcome-logo {
    width: 100px;
    height: auto;
    margin: 0 auto 10px;
    display: block;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.welcome-content {
    margin-bottom: 24px;
}

.welcome-content h4 {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: #197bff;
    font-weight: 600;
}

.welcome-content p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.quick-action {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    padding: 10px 8px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    color: #374151;
    font-weight: 500;
    text-align: left;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.quick-action .icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    stroke: #197bff;
    transition: stroke 0.3s ease;
}

.quick-action:hover .icon {
    stroke: white;
}

.quick-action:hover {
    background: linear-gradient(135deg, #197bff 0%, #0056d2 100%);
    color: white;
    border-color: #197bff;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(25, 123, 255, 0.3);
}

/* Message Styles */
.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
    clear: both;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ai-message,
.assistant-message {
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.message-bubble {
    display: inline-block;
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 20px;
    word-wrap: break-word;
    word-break: break-word;
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #197bff 0%, #0056d2 100%);
    color: white;
    border-bottom-right-radius: 4px;
    text-align: left;
    box-shadow: 0 3px 12px rgba(25, 123, 255, 0.3);
}

.ai-message .message-bubble,
.assistant-message .message-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.message-bubble a {
    color: #197bff !important;
    text-decoration: underline !important;
    word-break: break-all;
}

.user-message .message-bubble a {
    color: #ffffff !important;
    text-decoration: underline !important;
}

.message-bubble a:hover {
    opacity: 0.8;
}

.message-time {
    display: inline-block;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 6px;
    padding: 0 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-block;
    padding: 10px 14px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-10px);
    }
}

/* Input Area */
.ai-chat-input-wrapper {
    padding: 7px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.ai-chat-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ai-chat-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.ai-chat-input:focus {
    border-color: #197bff;
}

.ai-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #197bff 0%, #0056d2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-chat-send:hover {
    background: linear-gradient(135deg, #0056d2 0%, #197bff 100%);
    transform: scale(1.05);
}

.ai-chat-send svg {
    width: 20px;
    height: 20px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-chat-widget.active .ai-chat-toggle {
        display: none;
    }

    .ai-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        z-index: 2147483647;
    }

    .ai-chat-header {
        padding: 12px 16px;
        position: sticky;
        top: 0;
        z-index: 10;
        border-radius: 0;
    }

    .ai-chat-messages {
        height: calc(100% - 130px);
        padding: 16px;
        padding-bottom: 80px;
    }

    .ai-chat-input-wrapper {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        background: white;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .welcome-logo {
        width: 150px;
    }

    .welcome-content h4 {
        font-size: 18px;
    }

    .welcome-content p {
        font-size: 13px;
    }

    .quick-actions {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .quick-action {
        padding: 12px 8px;
        font-size: 12px;
        flex-direction: column;
        text-align: center;
        gap: 6px;
    }

    .quick-action .icon {
        width: 20px;
        height: 20px;
    }

    .message-bubble {
        max-width: 85%;
        font-size: 14px;
    }

    .ai-chat-widget.active .welcome-notification {
        display: none !important;
    }

    .welcome-notification {
        bottom: 70px;
        left: auto;
        right: 10px;
        width: auto;
        max-width: calc(100% - 20px);
        min-width: 320px;
        box-sizing: border-box;
    }

    .welcome-notification::after {
        right: 40px;
    }

    .welcome-notification::before {
        right: 39px;
    }

    .ai-chat-toggle {
        padding: 8px 16px 8px 8px;
        font-size: 14px;
    }

    .chat-icon {
        width: 32px;
        height: 32px;
    }

    .chat-badge-small {
        font-size: 10px;
    }

    .chat-badge-bold {
        font-size: 12px;
    }
}

/* Confirmation Modal */
.chat-confirm-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2147483647;
    animation: fadeIn 0.2s ease;
    border-radius: 16px;
}

.chat-confirm-modal.show {
    display: flex !important;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 320px;
    width: 85%;
    text-align: center;
    animation: slideUp 0.3s ease;
}

.modal-content h3 {
    margin: 0 0 20px 0;
    font-size: 22px;
    color: #1e293b;
    font-weight: 600;
}

.modal-content p {
    margin: 0 0 30px 0;
    font-size: 16px;
    color: #64748b;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 8px 25px;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.modal-btn-primary {
    background: #ef4444;
    color: white;
}

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.modal-btn-secondary {
    background: white;
    color: #64748b;
    border: 2px solid #e2e8f0;
}

.modal-btn-secondary:hover {
    background: #e2e8f0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}