/* AI Chat Widget Styles - Responsive Version */
.ai-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Chat Window */
.ai-chat-window {
    position: fixed;
    bottom: 110px;
    right: 20px;
    width: 384px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ai-chat-window.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

/* Header */
.ai-chat-header {
    background: #3E83AF;
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #C7D2E9;
}

.ai-chat-header-text h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.ai-chat-status {
    font-size: 12px;
    color: #93c5fd;
}

.ai-chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Messages Container */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Message Bubbles */
.ai-chat-message {
    display: flex;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-message-user {
    justify-content: flex-end;
}

.ai-chat-message-bot {
    justify-content: flex-start;
}

.ai-chat-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-chat-message-user .ai-chat-message-content {
    background: #3e83af;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-chat-message-bot .ai-chat-message-content {
    background: #d2d2d2;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-chat-message-error .ai-chat-message-content {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.ai-chat-message-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-message-content a {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}

.ai-chat-message-time {
    display: block;
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

/* Typing Indicator */
.ai-chat-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.ai-chat-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.ai-chat-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chat-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Container */
.ai-chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ai-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 0;
}

.ai-chat-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ai-chat-input:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

.ai-chat-send-btn {
    width: 48px;
    height: 48px;
    background: #3E83AF;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.ai-chat-send-btn:hover:not(:disabled) {
    background: #2c6a8f;
}

.ai-chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.ai-chat-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Toggle Button */
.ai-chat-toggle-btn {
    width: 70px;
    height: 70px;
    background-color: transparent;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    transition: all 0.3s ease;
}

.ai-chat-toggle-btn:hover {
    background: #3E83AF;
    transform: scale(1.1);
}

.ai-chat-toggle-btn:active {
    transform: scale(0.95);
}

.ai-chat-toggle-btn .hidden {
    display: none;
}

.ai-chat-toggle-btn img {
    width: 70px;
    height: 70px;
}

/* Tablet Responsive */
@media (max-width: 768px) {
    .ai-chat-container {
        bottom: 16px;
        right: 16px;
    }

    .ai-chat-window {
        right: 16px;
        bottom: 100px;
        width: 360px;
        height: 550px;
    }

    .ai-chat-toggle-btn {
        width: 64px;
        height: 64px;
    }

    .ai-chat-toggle-btn img {
        width: 64px;
        height: 64px;
    }
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .ai-chat-container {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }

    .ai-chat-window {
        position: fixed;
        bottom: 90px;
        left: 16px;
        right: 16px;
        width: auto;
        height: 500px;
    }

    .ai-chat-header {
        padding: 14px 16px;
    }

    .ai-chat-header-text h3 {
        font-size: 16px;
    }

    .ai-chat-messages {
        padding: 12px;
        gap: 12px;
    }

    .ai-chat-message-content {
        max-width: 85%;
        padding: 10px 14px;
    }

    .ai-chat-input-container {
        padding: 12px;
    }

    .ai-chat-input {
        padding: 10px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .ai-chat-send-btn {
        width: 44px;
        height: 44px;
    }

    .ai-chat-toggle-btn {
        width: 60px;
        height: 60px;
    }

    .ai-chat-toggle-btn img {
        max-width: none;
    }
}

/* Small Mobile */
@media (max-width: 400px) {
    .ai-chat-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }

    .ai-chat-window {
        bottom: 80px;
        left: 12px;
        right: 12px;
        height: 450px;
    }

    .ai-chat-header {
        padding: 12px;
    }

    .ai-chat-header-text h3 {
        font-size: 15px;
    }

    .ai-chat-messages {
        padding: 10px;
        gap: 10px;
    }

    .ai-chat-message-content {
        max-width: 90%;
        padding: 10px 12px;
    }

    .ai-chat-input-container {
        padding: 10px;
    }

    .ai-chat-toggle-btn {
        width: 56px;
        height: 56px;
    }

    .ai-chat-toggle-btn img {
        width: 56px;
        height: 56px;
    }
}

/* Landscape Mobile */
@media (max-width: 900px) and (max-height: 500px) {
    .ai-chat-window {
        height: 380px;
    }

    .ai-chat-header {
        padding: 10px 12px;
    }

    .ai-chat-messages {
        padding: 8px;
    }

    .ai-chat-input-container {
        padding: 8px;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}