/**
 * AI Automation Toolkit - Frontend Styles
 * Version: 2.1.0
 */

/* Widget Container */
.aiat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.aiat-widget-container.position-bottom-left {
    right: auto;
    left: 20px;
}

/* Widget Button */
.aiat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #667eea;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    border: none;
    position: relative;
}

.aiat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.aiat-widget-button svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.aiat-widget-button .notification-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Widget Window */
.aiat-widget-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.aiat-widget-window.active {
    display: flex;
}

.aiat-widget-container.position-bottom-left .aiat-widget-window {
    right: auto;
    left: 20px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Widget Header */
.aiat-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.aiat-widget-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.aiat-widget-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.aiat-widget-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Widget Body */
.aiat-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
}

/* Chat Messages */
.aiat-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.aiat-message {
    max-width: 80%;
    word-wrap: break-word;
    animation: fadeInMessage 0.3s ease;
}

@keyframes fadeInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aiat-message.bot {
    align-self: flex-start;
}

.aiat-message.user {
    align-self: flex-end;
}

.aiat-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
}

.aiat-message.bot .aiat-message-bubble {
    background: #fff;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.aiat-message.user .aiat-message-bubble {
    background: #667eea;
    color: #fff;
}

.aiat-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 18px;
    border: 1px solid #e5e7eb;
    width: fit-content;
}

.aiat-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.aiat-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.aiat-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Widget Footer / Input Area */
.aiat-widget-footer {
    padding: 20px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

.aiat-input-group {
    display: flex;
    gap: 10px;
}

.aiat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.aiat-input:focus {
    border-color: #667eea;
}

.aiat-send-button {
    background: #667eea;
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.aiat-send-button:hover {
    background: #5b21b6;
    transform: scale(1.05);
}

.aiat-send-button:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* Lead Form Styles */
.aiat-lead-form-shortcode {
    max-width: 600px;
    margin: 20px auto;
    padding: 30px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.aiat-lead-form-shortcode h3 {
    margin: 0 0 20px;
    color: #1f2937;
    font-size: 24px;
    text-align: center;
}

.aiat-shortcode-form p {
    margin-bottom: 15px;
}

.aiat-input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.aiat-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.aiat-input::placeholder {
    color: #9ca3af;
}

textarea.aiat-input {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.aiat-button {
    background: #667eea;
    color: #fff;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    width: 100%;
    transition: all 0.2s;
}

.aiat-button:hover {
    background: #5b21b6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.aiat-button:active {
    transform: translateY(0);
}

.aiat-button:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

/* Checkbox Styling */
.aiat-shortcode-form label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
    color: #4b5563;
    cursor: pointer;
    margin-bottom: 15px;
}

.aiat-shortcode-form input[type="checkbox"] {
    margin-top: 2px;
    cursor: pointer;
}

/* Result Messages */
.aiat-result {
    margin-top: 15px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.aiat-result.ok {
    background: #ecfeff;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.aiat-result.err {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Social Generator Shortcode */
.aiat-social-generator-shortcode {
    padding: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    text-align: center;
    color: #fff;
}

.aiat-social-generator-shortcode p {
    margin: 0;
    font-size: 16px;
}

/* Email Signup */
.aiat-email-signup {
    padding: 30px;
    background: #f9fafb;
    border-radius: 8px;
    border: 2px dashed #e5e7eb;
    text-align: center;
}

.aiat-email-signup p {
    color: #6b7280;
    margin: 0;
}

/* Loading Spinner */
.aiat-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Quick Actions Menu */
.aiat-quick-actions {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.aiat-quick-action {
    flex: 1;
    padding: 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color: #4b5563;
}

.aiat-quick-action:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.2);
}

.aiat-quick-action svg {
    width: 24px;
    height: 24px;
    margin-bottom: 5px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .aiat-widget-window {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
    }
    
    .aiat-widget-button {
        width: 56px;
        height: 56px;
    }
    
    .aiat-lead-form-shortcode {
        padding: 20px;
    }
    
    .aiat-quick-actions {
        flex-direction: column;
    }
}

/* Accessibility */
.aiat-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Styles */
.aiat-widget-button:focus,
.aiat-widget-close:focus,
.aiat-send-button:focus,
.aiat-button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .aiat-widget-container {
        display: none;
    }
}