/**
 * Podlyft AI Customer Chatbot Frontend CSS
 * Modern, responsive styling for the chat widget
 */

/* Reset and base styles */
#podlyft-chatbot-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#podlyft-chatbot-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    direction: ltr;
    text-align: left;
}

/* Chat Toggle Button */
#chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

#chatbot-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

#chatbot-toggle.chatbot-active {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 20px rgba(245, 87, 108, 0.4);
}

#chatbot-toggle .chatbot-icon {
    font-size: 24px;
    transition: transform 0.3s ease;
}

#chatbot-toggle.chatbot-active .chatbot-icon {
    transform: rotate(180deg);
}

/* Notification Badge */
.chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Chat Container */
#chatbot-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chatbot-container.chatbot-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
#chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
    position: relative;
}

.chatbot-header-content {
    display: flex;
    align-items: center;
    flex: 1;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 12px;
}

.chatbot-info {
    display: flex;
    flex-direction: column;
}

.chatbot-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
}

.chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    margin-right: 6px;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

#chatbot-close {
    cursor: pointer;
    font-size: 24px;
    font-weight: normal;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    padding: 5px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatbot-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* Messages Area */
#chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Message Styles */
.chatbot-message {
    max-width: 85%;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    position: relative;
}

.message-text {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message-text a {
    color: inherit;
    text-decoration: underline;
}

.message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
    padding: 0 16px;
}

/* User Messages */
.user-message {
    align-self: flex-end;
}

.user-message .message-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
}

.user-message .message-time {
    text-align: right;
    color: #666;
}

/* Bot Messages */
.bot-message {
    align-self: flex-start;
}

.bot-message .message-text {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.bot-message .message-time {
    color: #666;
}

/* Message Metadata (for debugging) */
.message-metadata {
    font-size: 10px;
    opacity: 0.5;
    padding: 4px 16px;
    font-style: italic;
}

/* Typing Indicator */
#chatbot-typing {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.typing-text {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Suggestions */
#chatbot-suggestions {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.suggestion-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion-btn {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 12px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.suggestion-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
}

/* Input Area */
#chatbot-input-area {
    padding: 20px;
    background: white;
    border-radius: 0 0 20px 20px;
    border-top: 1px solid #e9ecef;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    padding: 8px;
    transition: border-color 0.2s ease;
}

.input-container:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#chatbot-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #333;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    line-height: 1.4;
    padding: 8px 12px;
}

#chatbot-input::placeholder {
    color: #999;
}

#chatbot-send {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#chatbot-send:active {
    transform: scale(0.95);
}

.send-icon {
    font-size: 16px;
    transform: rotate(-45deg);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #podlyft-chatbot-widget {
        bottom: 15px;
        right: 15px;
        left: 15px;
    }
    
    #chatbot-container {
        width: 100%;
        height: 70vh;
        max-height: 500px;
        position: fixed;
        bottom: 90px;
        right: 15px;
        left: 15px;
    }
    
    #chatbot-toggle {
        position: fixed;
        bottom: 15px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    #chatbot-container {
        height: 75vh;
        border-radius: 15px;
    }
    
    #chatbot-header {
        padding: 15px;
        border-radius: 15px 15px 0 0;
    }
    
    .chatbot-title {
        font-size: 15px;
    }
    
    #chatbot-messages {
        padding: 15px;
    }
    
    #chatbot-input-area {
        padding: 15px;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    #chatbot-toggle,
    #chatbot-container,
    .chatbot-message,
    .suggestion-btn {
        animation: none;
        transition: none;
    }
    
    .typing-indicator span {
        animation: none;
    }
    
    .chatbot-notification {
        animation: none;
    }
}

/* Focus Management */
#chatbot-input:focus {
    outline: none;
}

.suggestion-btn:focus,
#chatbot-send:focus,
#chatbot-close:focus,
#chatbot-toggle:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    #chatbot-container {
        border: 2px solid #000;
    }
    
    .bot-message .message-text {
        border: 2px solid #000;
    }
    
    .input-container {
        border: 2px solid #000;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    #chatbot-container {
        background: #2c2c2c;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    }
    
    #chatbot-messages {
        background: #1e1e1e;
    }
    
    .bot-message .message-text {
        background: #3c3c3c;
        color: #e0e0e0;
        border-color: #555;
    }
    
    .message-time {
        color: #ccc !important;
    }
    
    #chatbot-typing {
        background: #2c2c2c;
        border-color: #555;
    }
    
    #chatbot-suggestions {
        background: #2c2c2c;
        border-color: #555;
    }
    
    .suggestion-btn {
        background: #3c3c3c;
        color: #e0e0e0;
        border-color: #555;
    }
    
    .suggestion-btn:hover {
        background: #667eea;
        color: white;
    }
    
    #chatbot-input-area {
        background: #2c2c2c;
        border-color: #555;
    }
    
    .input-container {
        background: #3c3c3c;
        border-color: #555;
    }
    
    #chatbot-input {
        color: #e0e0e0;
    }
    
    #chatbot-input::placeholder {
        color: #999;
    }
}

/* Loading States */
.chatbot-loading {
    opacity: 0.6;
    pointer-events: none;
}

.chatbot-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Error States */
.chatbot-error .message-text {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* Success States */
.chatbot-success .message-text {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

/* Offline Indicator */
.chatbot-offline::after {
    content: "⚠️ You're offline";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #ffc107;
    color: #212529;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    white-space: nowrap;
    margin-top: 5px;
}

/* Custom Scrollbar for Firefox */
#chatbot-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

/* Print Styles */
@media print {
    #podlyft-chatbot-widget {
        display: none !important;
    }
}

/* RTL Support */
[dir="rtl"] #podlyft-chatbot-widget {
    left: 20px;
    right: auto;
}

[dir="rtl"] #chatbot-container {
    left: 0;
    right: auto;
}

[dir="rtl"] .user-message {
    align-self: flex-start;
}

[dir="rtl"] .bot-message {
    align-self: flex-end;
}

[dir="rtl"] .user-message .message-text {
    margin-right: auto;
    margin-left: 0;
}

/* Animation Classes for JavaScript */
.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

.slide-out-right {
    animation: slideOutRight 0.3s ease-in;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Bounce Animation for Notifications */
.bounce {
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 20%, 60%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    80% {
        transform: translateY(-5px);
    }
}

/* Shake Animation for Errors */
.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Fade Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

.fade-out {
    animation: fadeOut 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Widget States */
.chatbot-minimized #chatbot-container {
    height: 60px;
    overflow: hidden;
}

.chatbot-minimized #chatbot-messages,
.chatbot-minimized #chatbot-input-area,
.chatbot-minimized #chatbot-suggestions,
.chatbot-minimized #chatbot-typing {
    display: none;
}

/* Tooltip Styles */
.chatbot-tooltip {
    position: relative;
}

.chatbot-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
}

.chatbot-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* Custom Properties for Theming */
:root {
    --chatbot-primary-color: #667eea;
    --chatbot-secondary-color: #764ba2;
    --chatbot-accent-color: #f093fb;
    --chatbot-success-color: #2ecc71;
    --chatbot-error-color: #e74c3c;
    --chatbot-warning-color: #f39c12;
    --chatbot-text-color: #333;
    --chatbot-bg-color: #fff;
    --chatbot-border-color: #e9ecef;
    --chatbot-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --chatbot-border-radius: 20px;
    --chatbot-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Override with custom properties */
#podlyft-chatbot-widget {
    --primary: var(--chatbot-primary-color, #667eea);
    --secondary: var(--chatbot-secondary-color, #764ba2);
    --accent: var(--chatbot-accent-color, #f093fb);
    --success: var(--chatbot-success-color, #2ecc71);
    --error: var(--chatbot-error-color, #e74c3c);
    --warning: var(--chatbot-warning-color, #f39c12);
    --text: var(--chatbot-text-color, #333);
    --bg: var(--chatbot-bg-color, #fff);
    --border: var(--chatbot-border-color, #e9ecef);
    --shadow: var(--chatbot-shadow, 0 10px 40px rgba(0, 0, 0, 0.15));
    --radius: var(--chatbot-border-radius, 20px);
    --font: var(--chatbot-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif);
}