.ai-chat-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 15px;
    background: linear-gradient(135deg, #00c6ff, #0072ff);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 114, 255, 0.2);
    z-index: 1003;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transform-origin: center;
}

.ai-chat-icon:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 114, 255, 0.25);
}

.ai-chat-icon.active {
    animation: suckIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.ai-chat-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: rgba(255, 255, 255, 0.95); 
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    display: none; 
    flex-direction: column;
    z-index: 1002;
    opacity: 0;
    visibility: hidden; 
    transform-origin: bottom right;
    border: none;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-style: preserve-3d;
    backface-visibility: hidden;
    perspective: 1000px;
    will-change: transform, opacity;
    transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
}

.ai-chat-container.opening {
    animation: flipOpen 0.7s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    visibility: visible;
    display: flex; 
    background: rgba(255, 255, 255, 0.95);
}

.ai-chat-container.closing {
    animation: flipClose 0.7s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    display: flex; 
}

@keyframes flipOpen {
    0% {
        transform: rotate3d(1, 1, 0, 90deg) scale(0.2);
        opacity: 0.3;
        visibility: visible;
    }
    50% {
        transform: rotate3d(1, 1, 0, -20deg) scale(1.1);
        opacity: 0.8;
    }
    80% {
        transform: rotate3d(1, 1, 0, 5deg) scale(0.95);
        opacity: 0.9;
    }
    100% {
        transform: rotate3d(1, 1, 0, 0deg) scale(1);
        opacity: 1;
        visibility: visible;
        display: flex; 
    }
}

@keyframes flipClose {
    0% {
        transform: rotate3d(1, 1, 0, 0deg) scale(1);
        opacity: 1;
    }
    20% {
        transform: rotate3d(1, 1, 0, 5deg) scale(0.95);
        opacity: 0.9;
    }
    50% {
        transform: rotate3d(1, 1, 0, -20deg) scale(1.1);
        opacity: 0.5;
    }
    100% {
        transform: rotate3d(1, 1, 0, 90deg) scale(0.2);
        opacity: 0;
        visibility: hidden;
    }
}

@keyframes suckIn {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(0.8);
    }
}

.ai-chat-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    display: flex; 
}

.ai-chat-header {
    padding: 15px;
    background-color: #007bff;
    color: white;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 999999; 
}

.ai-chat-header span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.online-status {
    width: 8px;
    height: 8px;
    background-color: #2ecc71;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.2);
    position: relative; 
    z-index: 2; 
}

.ai-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.ai-chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    height: calc(100% - 120px);
    backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform;
    z-index: 999997; 
}

.ai-message {
    max-width: 80%;
    padding: 10px 15px;
    margin: 5px 0;
    border-radius: 15px;
    word-wrap: break-word;
    position: relative; 
    z-index: 1; 
}

.ai-message.user {
    background-color: #007bff;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.ai-message.bot {
    background-color: #f0f0f0;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.ai-message.welcome {
    font-size: 1.1em;
    background-color: rgba(0, 123, 255, 0.1);
    color: #007bff;
    border: 1px solid rgba(0, 123, 255, 0.2);
    padding: 15px 20px;
    margin-bottom: 15px;
}


.ai-message a {
    color: #007bff;
    text-decoration: none;
    border-bottom: 1px dotted #007bff;
    transition: all 0.2s ease;
    font-weight: 500;
}

.ai-message a:hover {
    color: #0056b3;
    border-bottom: 1px solid #0056b3;
}


.ai-message.bot a {
    color: #007bff;
}

.ai-message.bot a:hover {
    color: #0056b3;
}


.ai-message.user a {
    color: #ffffff;
    border-bottom: 1px dotted #ffffff;
}

.ai-message.user a:hover {
    color: #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}


[data-theme="dark"] .ai-message.bot a {
    color: #3498db;
    border-bottom: 1px dotted #3498db;
}

[data-theme="dark"] .ai-message.bot a:hover {
    color: #5dade2;
    border-bottom: 1px solid #5dade2;
}

[data-theme="dark"] .ai-message.user a {
    color: #ffffff;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .ai-message.user a:hover {
    color: #ffffff;
    border-bottom: 1px solid #ffffff;
}

.ai-chat-input {
    display: none;
}

.ai-chat-input input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
}

.ai-chat-input button {
    background-color: #007bff;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.ai-chat-input button:hover {
    background-color: #0056b3;
}

[data-theme="dark"] .ai-chat-container {
    background: #383838;
    border: none;
}

[data-theme="dark"] .ai-chat-container.opening {
    background: #383838;
}

[data-theme="dark"] .ai-chat-messages {
    background-color: #2a2a2a;
}

[data-theme="dark"] .ai-message.bot {
    background-color: #383838;
    color: #fff;
}

[data-theme="dark"] .ai-message.welcome {
    background-color: rgba(0, 123, 255, 0.15);
    border-color: rgba(0, 123, 255, 0.3);
    color: #3498db;
}

[data-theme="dark"] .ai-chat-input {
    border-top: 1px solid #444;
}

[data-theme="dark"] .ai-chat-input input {
    background-color: #383838;
    border: 1px solid #444;
    color: #fff;
}

@media (max-width: 480px) {
    .ai-chat-container {
        width: calc(100% - 40px);
        height: calc(100vh - 140px); 
        max-height: 600px; 
        bottom: 80px;
        margin: 0 auto; 
        right: 20px;
    }

    .ai-chat-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-width: 768px) {
    .ai-chat-container {
        width: 370px;
        height: min(540px, calc(100vh - 200px)); 
        bottom: 80px;
        max-height: calc(100vh - 180px); 
    }

    .ai-chat-icon {
        bottom: 117px;
        right: 10px;
        width: 32px;
        height: 56px;
        border-radius: 14px;
        font-size: 16px;
        padding: 2px;
        background: linear-gradient(to right, #2c3e50, #3498db);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        border: 1px solid #2ecc71;
        transition: all 0.3s ease;
    }

    .ai-chat-icon.active {
        background: linear-gradient(to right, #34495e, #2980b9);
        border: 1px solid #2ecc71;
        color: white;
    }

    .ai-chat-icon:hover {
        transform: none;
        background: linear-gradient(to right, #2c3e50, #3498db);
        border: 1px solid #2ecc71;
    }
}

@media (max-width: 380px) {
    .ai-chat-container {
        width: calc(100% - 20px);
        height: min(495px, calc(100vh - 120px)); 
        right: 10px;
        bottom: 70px;
        max-height: calc(100vh - 120px); 
    }

    .ai-chat-messages {
        padding: 8px;
        height: calc(100% - 100px);
    }

    .ai-chat-header {
        padding: 10px;
    }

    .ai-chat-icon {
        right: 10px;
        bottom: 100px;
        width: 32px;
        height: 56px;
        font-size: 16px;
        border: 1px solid #2ecc71;
    }

    .ai-suggestion-bubble {
        padding: 6px 10px;
        font-size: 12px;
        width: 100%;
        max-width: 100%;
        border-radius: 15px;
    }

    .ai-suggestions {
        padding: 8px;
        gap: 6px;
    }

    .ai-message {
        padding: 8px 12px;
        font-size: 13px;
        margin: 3px 0;
    }

    .typing-indicator {
        padding: 8px 12px;
    }

    .typing-dot {
        width: 6px;
        height: 6px;
    }
}


@media (max-height: 600px) {
    .ai-chat-container {
        height: calc(100vh - 100px);
        bottom: 60px;
    }

    .ai-chat-messages {
        height: calc(100% - 100px);
    }

    .ai-suggestions {
        padding: 8px;
    }
}

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

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

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

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

.ai-suggestions {
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
    background: white;
    border-top: 1px solid #eee;
    position: sticky;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 999997; 
}

[data-theme="dark"] .ai-suggestions {
    background: #383838;
    border-top: 1px solid #444;
}

.ai-suggestion-bubble {
    background-color: #fff;
    border: 1px solid #007bff;
    color: #007bff;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    margin: 0;
    backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform;
}

.ai-suggestion-bubble:hover {
    background-color: #007bff;
    color: white;
    transform: translateY(-2px);
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
    background: #f0f0f0;
    border-radius: 15px;
    align-self: flex-start;
    margin: 5px 0;
    backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: typingBounce 1s infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

[data-theme="dark"] .ai-suggestions {
    background: #383838;
    border-top: 1px solid #444;
}

[data-theme="dark"] .ai-suggestion-bubble {
    background-color: #2a2a2a;
    border-color: #3498db;
    color: #3498db;
}

[data-theme="dark"] .ai-suggestion-bubble:hover {
    background-color: #3498db;
    color: white;
}

[data-theme="dark"] .typing-indicator {
    background: #383838;
}

[data-theme="dark"] .typing-dot {
    background: #999;
}

[data-theme="dark"] .ai-chat-icon {
    border-color: #2ecc71;
    background: rgba(0, 0, 0, 0.4);
    background: linear-gradient(to right, #1a1a1a, #2c3e50);
}

[data-theme="dark"] .ai-chat-icon:hover {
    background: linear-gradient(to right, #2c3e50, #3498db);
}
