/* ===== AI Chat Pro Styles ===== */

/* ===== Embedded (shortcode) widget ===== */
.ai-chat-embedded {
    margin: 20px 0;
    max-width: 100%;
}

.ai-chat-box {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    max-width: 400px;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ai-chat-log {
    height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    margin-bottom: 12px;
    border-radius: 6px;
    scroll-behavior: smooth;
}

.ai-message {
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease-in;
}

.ai-message--user {
    text-align: right;
}

.ai-message--user .ai-message-content {
    display: inline-block;
    background: #1976d2;
    color: white;
    padding: 8px 12px;
    border-radius: 18px 18px 4px 18px;
    max-width: 80%;
    word-wrap: break-word;
}

.ai-message--ai {
    text-align: left;
}

.ai-message--ai .ai-message-content {
    display: inline-block;
    background: #e0e0e0;
    color: #333;
    padding: 8px 12px;
    border-radius: 18px 18px 18px 4px;
    max-width: 80%;
    word-wrap: break-word;
}

.ai-message--err .ai-message-content {
    background: #ffebee;
    color: #d32f2f;
    border: 1px solid #ffcdd2;
}

.ai-message-time {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    opacity: 0.7;
}

.ai-message--user .ai-message-time {
    text-align: right;
}

.ai-message--ai .ai-message-time {
    text-align: left;
}

.ai-chat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    resize: vertical;
    min-height: 20px;
    max-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.ai-chat-input:focus {
    border-color: #1976d2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1);
}

.ai-chat-form .button {
    padding: 10px 20px;
    background: #1976d2;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.ai-chat-form .button:hover:not(:disabled) {
    background: #1565c0;
}

.ai-chat-form .button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Character counter */
.ai-char-counter {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    text-align: right;
}

.ai-char-counter--warning {
    color: #f57c00;
}

.ai-char-counter--error {
    color: #d32f2f;
    font-weight: bold;
}

/* Typing indicator */
.ai-typing-indicator {
    padding: 8px 0;
    text-align: left;
}

.ai-typing-dots {
    display: inline-block;
    padding: 8px 12px;
    background: #e0e0e0;
    border-radius: 18px 18px 18px 4px;
}

.ai-typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    margin: 0 1px;
    animation: aiTyping 1.4s infinite ease-in-out;
}

.ai-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes aiTyping {
    0%, 80%, 100% { 
        transform: scale(0.8); 
        opacity: 0.5; 
    }
    40% { 
        transform: scale(1); 
        opacity: 1; 
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Floating widget ===== */
.ai-chat-floating {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ai-chat-floating[data-position="left"] {
    right: auto;
    left: 20px;
}

.ai-chat-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: #1976d2;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-fab:hover {
    background: #1565c0;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.ai-chat-fab:focus {
    outline: 2px solid #90caf9;
    outline-offset: 2px;
}

.ai-chat-fab:active {
    transform: scale(0.95);
}

.ai-chat-panel {
    position: fixed;
    right: 20px;
    bottom: 90px;
    width: 350px;
    height: 500px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.ai-chat-floating[data-position="left"] .ai-chat-panel {
    right: auto;
    left: 20px;
}

.ai-chat-panel:not([hidden]) {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.ai-chat-panel[hidden] {
    display: flex !important;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.ai-chat-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.ai-chat-panel-header strong {
    font-weight: 600;
    color: #333;
}

.ai-chat-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: #666;
    transition: all 0.2s ease;
}

.ai-chat-close:hover {
    background: #e0e0e0;
    color: #333;
}

.ai-chat-panel .ai-chat-log {
    flex: 1;
    margin: 0;
    border: none;
    border-radius: 0;
    background: white;
    padding: 16px;
}

.ai-chat-panel .ai-chat-form {
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
    flex-shrink: 0;
}

/* Dark theme */
.ai-chat-floating[data-theme="dark"] .ai-chat-panel {
    background: #2d2d2d;
    color: white;
}

.ai-chat-floating[data-theme="dark"] .ai-chat-panel-header {
    background: #1a1a1a;
    border-bottom-color: #404040;
}

.ai-chat-floating[data-theme="dark"] .ai-chat-panel-header strong {
    color: white;
}

.ai-chat-floating[data-theme="dark"] .ai-chat-close {
    color: #ccc;
}

.ai-chat-floating[data-theme="dark"] .ai-chat-close:hover {
    background: #404040;
    color: white;
}

.ai-chat-floating[data-theme="dark"] .ai-chat-log {
    background: #2d2d2d;
}

.ai-chat-floating[data-theme="dark"] .ai-message--ai .ai-message-content {
    background: #404040;
    color: #e0e0e0;
}

.ai-chat-floating[data-theme="dark"] .ai-chat-input {
    background: #404040;
    border-color: #555;
    color: white;
}

.ai-chat-floating[data-theme="dark"] .ai-chat-input:focus {
    border-color: #90caf9;
}

.ai-chat-floating[data-theme="dark"] .ai-chat-form {
    background: #2d2d2d;
    border-top-color: #404040;
}

/* Responsive design */
@media (max-width: 480px) {
    .ai-chat-floating {
        right: 10px;
        bottom: 10px;
    }
    
    .ai-chat-floating[data-position="left"] {
        right: auto;
        left: 10px;
    }
    
    .ai-chat-fab {
        width: 56px;
        height: 56px;
        font-size: 20px;
    }
    
    .ai-chat-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        right: 10px;
        bottom: 76px;
        border-radius: 8px;
    }
    
    .ai-chat-floating[data-position="left"] .ai-chat-panel {
        right: auto;
        left: 10px;
    }
    
    .ai-chat-box {
        max-width: 100%;
        margin: 10px;
        padding: 12px;
    }
    
    .ai-chat-log {
        height: 250px;
    }
    
    .ai-message--user .ai-message-content,
    .ai-message--ai .ai-message-content {
        max-width: 90%;
        font-size: 14px;
    }
}

@media (max-width: 320px) {
    .ai-chat-panel {
        width: calc(100vw - 10px);
        right: 5px;
    }
    
    .ai-chat-floating[data-position="left"] .ai-chat-panel {
        right: auto;
        left: 5px;
    }
    
    .ai-chat-fab {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ai-chat-box,
    .ai-chat-panel {
        border: 2px solid #000;
    }
    
    .ai-chat-input {
        border: 2px solid #000;
    }
    
    
    .ai-chat-fab {
        border: 2px solid #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ai-chat-fab,
    .ai-chat-panel,
    .ai-message,
    .ai-typing-dots span {
        animation: none !important;
        transition: none !important;
    }
}

/* Print styles */
@media print {
    .ai-chat-floating,
    .ai-chat-fab {
        display: none !important;
    }
    
    .ai-chat-box {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
}