/**
 * Tiny Lux AI Assistant Widget Styles
 *
 * Modern, responsive chat widget for WooCommerce
 */

:root {
    --ai-primary-color: #007cba;
    --ai-secondary-color: #f8f9fa;
    --ai-text-color: #333;
    --ai-border-radius: 12px;
    --ai-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --ai-transition: all 0.3s ease;
}

/* Main Widget Container */
.tinylux-ai-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: var(--ai-border-radius);
    box-shadow: var(--ai-shadow);
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    transition: var(--ai-transition);
    display: none;
    overflow: hidden;
}

/* Close Button */
.ai-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: var(--ai-transition);
    font-size: 18px;
    line-height: 1;
}

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

.close-icon {
    font-size: 20px;
    font-weight: bold;
}

/* Floating Icon State */
/* Open Chat State */
.tinylux-ai-widget.open {
    width: 350px;
    height: 500px;
    border-radius: var(--ai-border-radius);
    opacity: 1;
    transform: translateY(0) scale(1);
    display: flex;
    flex-direction: column;
}

.tinylux-ai-widget.open .ai-widget-header {
    display: flex;
}

.tinylux-ai-widget.open .ai-chat-container {
    display: block;
}

.tinylux-ai-widget.open .ai-input-container {
    display: block;
}

.tinylux-ai-widget.open .ai-chat-container,
.tinylux-ai-widget.open .ai-input-container {
    opacity: 1;
}

.tinylux-ai-widget.is-hidden {
    display: none;
}

/* Launcher Button */
.tinylux-ai-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 0;
    background: linear-gradient(135deg, var(--ai-primary-color), #005a87);
    border-radius: 50%;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
    color: #fff;
    cursor: pointer;
    transition: var(--ai-transition);
    z-index: 999998;
}

.tinylux-ai-launcher:hover,
.tinylux-ai-launcher:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

.tinylux-ai-launcher:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

.tinylux-ai-launcher .launcher-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.tinylux-ai-launcher.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

.tinylux-ai-launcher .launcher-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Widget Header */
.ai-widget-header {
    background: linear-gradient(135deg, var(--ai-primary-color), #005a87);
    color: white;
    padding: 16px;
    border-radius: var(--ai-border-radius) var(--ai-border-radius) 0 0;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-icon {
    font-size: 20px;
}

.ai-icon-small {
    font-size: 16px;
}

.ai-info {
    flex: 1;
}

.ai-name {
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

.ai-status {
    font-size: 12px;
    opacity: 0.8;
    margin: 4px 0 0 0;
}

.ai-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: var(--ai-transition);
}

.ai-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Container */
.ai-chat-container {
    height: calc(100% - 72px);
    display: flex;
    flex-direction: column;
}

/* Messages Area */
.ai-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: var(--ai-secondary-color);
    max-height: calc(500px - 140px);
}

.ai-message {
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
}

.ai-message-bot {
    justify-content: flex-start;
}

.ai-message-user {
    justify-content: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    flex-shrink: 0;
    margin-top: 4px;
}

.message-content {
    max-width: 70%;
}

.message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    margin: 0;
}

.ai-message-user .message-text {
    background: var(--ai-primary-color);
    color: white;
}

.message-time {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    text-align: right;
}

.ai-message-user .message-time {
    text-align: left;
}

/* Input Container */
.ai-input-container {
    border-top: 1px solid #e1e5e9;
    background: white;
    border-radius: 0 0 var(--ai-border-radius) var(--ai-border-radius);
}

.ai-input-wrapper {
    padding: 16px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-message-input {
    flex: 1;
    border: 2px solid #e1e5e9;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    min-height: 20px;
    max-height: 80px;
    outline: none;
    transition: var(--ai-transition);
}

.ai-message-input:focus {
    border-color: var(--ai-primary-color);
}

.ai-send-button {
    width: 40px;
    height: 40px;
    background: var(--ai-primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ai-transition);
    flex-shrink: 0;
}

.ai-send-button:hover {
    background: #005a87;
    transform: scale(1.05);
}

.ai-send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Typing Indicator */
.ai-typing-indicator {
    padding: 16px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.ai-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Error Messages */
.ai-message.error .message-text {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

/* Responsive Design */
@media (max-width: 480px) {
    .tinylux-ai-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }

    .tinylux-ai-widget.minimized {
        right: 10px;
        left: auto;
        width: auto;
    }

    .ai-messages {
        max-height: calc(100vh - 200px);
    }
}

/* Animation for widget appearance */
.tinylux-ai-widget.show {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Scrollbar styling */
.ai-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* Focus states for accessibility */
.ai-message-input:focus,
.ai-send-button:focus,
.ai-toggle:focus {
    outline: 2px solid var(--ai-primary-color);
    outline-offset: 2px;
}

/* Loading states */
.ai-send-button.loading {
    position: relative;
}

.ai-send-button.loading .send-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Hide widget on print */
@media print {
    .tinylux-ai-widget {
        display: none !important;
    }
}
