/* WP AI Chatbot Frontend Styles */

/* Force initial hidden state */
#wp-ai-chatbot-widget {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Override hidden state when widget is active */
#wp-ai-chatbot-widget.wp-ai-chatbot-active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Chatbot Widget */
.wp-ai-chatbot-widget {
    position: fixed !important;
    width: 350px !important;
    height: 500px !important;
    background: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
    z-index: 999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    transition: all 0.3s ease !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-bottom-right {
    bottom: 20px !important;
    right: 20px !important;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-dark {
    background: #1a1a1a;
    color: #ffffff;
}

/* Chatbot Toggle Button */
.wp-ai-chatbot-toggle {
    position: fixed !important;
    bottom: 20px !important;
    width: 60px !important;
    height: 60px !important;
    background: var(--wp-ai-chatbot-bubble-color, #007cba) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    z-index: 999998 !important;
    box-shadow: 0 4px 16px rgba(0, 124, 186, 0.3) !important;
    transition: all 0.3s ease !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.wp-ai-chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 124, 186, 0.4);
}

.wp-ai-chatbot-toggle.wp-ai-chatbot-bottom-right {
    bottom: 20px !important;
    right: 20px !important;
    left: auto !important;
}

.wp-ai-chatbot-toggle.wp-ai-chatbot-bottom-left {
    bottom: 20px !important;
    left: 20px !important;
    right: auto !important;
}

.wp-ai-chatbot-toggle-icon,
.wp-ai-chatbot-toggle-close {
    color: #ffffff;
    transition: opacity 0.3s ease;
}

.wp-ai-chatbot-toggle-close {
    opacity: 0;
}

.wp-ai-chatbot-toggle.active .wp-ai-chatbot-toggle-icon {
    opacity: 0;
}

.wp-ai-chatbot-toggle.active .wp-ai-chatbot-toggle-close {
    opacity: 1;
}

/* Header */
.wp-ai-chatbot-header {
    background: var(--wp-ai-chatbot-header-color, #007cba);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 12px 12px 0 0;
}

.wp-ai-chatbot-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wp-ai-chatbot-avatar {
    font-size: 20px;
}

.wp-ai-chatbot-name {
    font-weight: 600;
    font-size: 16px;
}

.wp-ai-chatbot-controls {
    display: flex;
    gap: 8px;
}

.wp-ai-chatbot-minimize,
.wp-ai-chatbot-clear,
.wp-ai-chatbot-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-ai-chatbot-minimize:hover,
.wp-ai-chatbot-clear:hover,
.wp-ai-chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Body */
.wp-ai-chatbot-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wp-ai-chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wp-ai-chatbot-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.wp-ai-chatbot-message-user {
    align-self: flex-end;
}

.wp-ai-chatbot-message-bot {
    align-self: flex-start;
}

.wp-ai-chatbot-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.wp-ai-chatbot-message-user .wp-ai-chatbot-message-content {
    background: #007cba;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.wp-ai-chatbot-message-bot .wp-ai-chatbot-message-content {
    background: #f1f3f4;
    color: #333333;
    border-bottom-left-radius: 4px;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-dark .wp-ai-chatbot-message-bot .wp-ai-chatbot-message-content {
    background: #2d2d2d;
    color: #ffffff;
}

.wp-ai-chatbot-message-time {
    font-size: 11px;
    color: #666666;
    margin-top: 4px;
    align-self: flex-end;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-dark .wp-ai-chatbot-message-time {
    color: #999999;
}

/* Typing Indicator */
.wp-ai-chatbot-typing {
    padding: 0 20px 16px;
}

.wp-ai-chatbot-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #f1f3f4;
    border-radius: 18px;
    max-width: 80px;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-dark .wp-ai-chatbot-typing-indicator {
    background: #2d2d2d;
}

.wp-ai-chatbot-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #666666;
    border-radius: 50%;
    animation: wp-ai-chatbot-typing 1.4s infinite ease-in-out;
}

.wp-ai-chatbot-typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.wp-ai-chatbot-typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes wp-ai-chatbot-typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Footer */
.wp-ai-chatbot-footer {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    background: #ffffff;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-dark .wp-ai-chatbot-footer {
    background: #1a1a1a;
    border-top-color: #333333;
}

.wp-ai-chatbot-form {
    margin: 0;
}

.wp-ai-chatbot-input-group {
    display: flex;
    align-items: center;
    background: transparent;
    border-radius: 24px;
    padding: 4px;
    border: 1px solid #e0e0e0;
    transition: border-color 0.2s ease;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-dark .wp-ai-chatbot-input-group {
    background: transparent;
    border-color: #444444;
}

.wp-ai-chatbot-input-group:focus-within {
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.wp-ai-chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 9px;
    outline: none;
    color: #333333;
    height: 40px;
    box-sizing: border-box;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-dark .wp-ai-chatbot-input {
    color: #ffffff;
}

.wp-ai-chatbot-input::placeholder {
    color: #999999;
}

.wp-ai-chatbot-send {
    background: var(--wp-ai-chatbot-send-color, #007cba);
    border: none;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-left: 8px;
    font-size: 11px;
    font-weight: 500;
    gap: 6px;
    min-width: 60px;
    height: 40px;
    box-sizing: border-box;
}

.wp-ai-chatbot-send:hover {
    background: color-mix(in srgb, var(--wp-ai-chatbot-send-color, #007cba) 80%, black) !important;
}

.wp-ai-chatbot-send:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 480px) {
    .wp-ai-chatbot-widget {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        max-height: 500px;
    }
    
    .wp-ai-chatbot-widget.wp-ai-chatbot-bottom-right,
    .wp-ai-chatbot-widget.wp-ai-chatbot-bottom-left {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .wp-ai-chatbot-toggle.wp-ai-chatbot-bottom-right,
    .wp-ai-chatbot-toggle.wp-ai-chatbot-bottom-left {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
}

/* Animation Classes */
.wp-ai-chatbot-widget.wp-ai-chatbot-hidden {
    transform: translateY(100%);
    opacity: 0;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-minimized {
    height: 60px !important;
    max-height: 60px !important;
    overflow: hidden !important;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-minimized .wp-ai-chatbot-messages {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-minimized .wp-ai-chatbot-input-group {
    display: none !important;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-minimized .wp-ai-chatbot-footer {
    display: none !important;
}

.wp-ai-chatbot-toggle.wp-ai-chatbot-hidden {
    opacity: 0;
    transform: scale(0.8);
}

/* Scrollbar Styling */
.wp-ai-chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

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

.wp-ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: #cccccc;
    border-radius: 2px;
}

.wp-ai-chatbot-widget.wp-ai-chatbot-dark .wp-ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: #666666;
}

/* Message Animation */
.wp-ai-chatbot-message {
    animation: wp-ai-chatbot-message-slide 0.3s ease-out;
}

@keyframes wp-ai-chatbot-message-slide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
