/**
 * WordPress Chatbot Frontend Styles
 * 
 * Styles for the chatbot interface, contact form, and responsive design
 */

/* CSS Custom Properties for theming */
:root {
    --wp-chatbot-primary: #007cba;
    --wp-chatbot-primary-hover: #006ba6;
    --wp-chatbot-secondary: #f0f0f0;
    --wp-chatbot-text: #333333;
    --wp-chatbot-border: #e0e0e0;
    --wp-chatbot-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    --wp-chatbot-radius: 12px;
    --wp-chatbot-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Base Widget Container */
.wp-chatbot-widget {
    position: fixed;
    z-index: 999999;
    font-family: var(--wp-chatbot-font);
    font-size: 14px;
    line-height: 1.4;
    bottom: 20px;
    right: 20px;
}

/* Chat Button */
.wp-chatbot-button {
    width: 60px;
    height: 60px;
    background: var(--wp-chatbot-primary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--wp-chatbot-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    color: white;
    position: relative;
    overflow: hidden;
}

.wp-chatbot-button:hover {
    background: var(--wp-chatbot-primary-hover, #006ba6);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.wp-chatbot-button:active {
    transform: translateY(0);
}

.wp-chatbot-button .wp-chatbot-icon {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.wp-chatbot-button:hover .wp-chatbot-icon {
    transform: scale(1.1);
}

/* Pulse animation for attention */
.wp-chatbot-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: var(--wp-chatbot-primary);
    animation: chatbot-pulse 2s infinite;
    z-index: -1;
}

@keyframes chatbot-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    70% {
        transform: scale(1.4);
        opacity: 0;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* Contact Form Window */
.wp-chatbot-start {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: var(--wp-chatbot-radius);
    box-shadow: var(--wp-chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(10px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.wp-chatbot-start:not([style*="display: none"]) {
    transform: translateY(0);
    opacity: 1;
}

/* Chat Window */
.wp-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: var(--wp-chatbot-radius);
    box-shadow: var(--wp-chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(10px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.wp-chatbot-window:not([style*="display: none"]) {
    transform: translateY(0);
    opacity: 1;
}

/* Header */
.wp-chatbot-header {
    background: var(--wp-chatbot-primary);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
}

.wp-chatbot-header h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
}

.wp-chatbot-header p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.3;
}

.wp-chatbot-close,
.wp-chatbot-minimize {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    margin-left: 4px;
}

.wp-chatbot-close:hover,
.wp-chatbot-minimize:hover {
    background: rgba(255, 255, 255, 0.1);
}

.wp-chatbot-close svg,
.wp-chatbot-minimize svg {
    width: 18px;
    height: 18px;
}

/* Header Controls Container */
.wp-chatbot-header-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Status Indicator */
.wp-chatbot-status {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 20px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.status-indicator.online {
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.status-text {
    display: flex;
    flex-direction: column;
}

.status-main {
    font-weight: 500;
    font-size: 14px;
    color: var(--wp-chatbot-text);
}

.status-sub {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

/* Contact Form */
.wp-chatbot-start-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.wp-chatbot-contact-form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--wp-chatbot-text);
    font-size: 13px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--wp-chatbot-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--wp-chatbot-primary);
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.wp-chatbot-start-btn {
    background: var(--wp-chatbot-primary);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: auto;
}

.wp-chatbot-start-btn:hover {
    background: var(--wp-chatbot-primary-hover, #006ba6);
    transform: translateY(-1px);
}

.wp-chatbot-start-btn:active {
    transform: translateY(0);
}

/* Error Messages */
.wp-chatbot-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid #fecaca;
}

/* Messages Container */
.wp-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #fafafa;
    scroll-behavior: smooth;
}

.wp-chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.wp-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wp-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Message Bubbles */
.wp-chatbot-message {
    margin-bottom: 16px;
    max-width: 85%;
    animation: message-slide-in 0.3s ease-out;
}

@keyframes message-slide-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wp-chatbot-message.user {
    margin-left: auto;
}

.wp-chatbot-message.bot {
    margin-right: auto;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.wp-chatbot-message.user .message-content {
    background: var(--wp-chatbot-primary);
    color: white;
    border-bottom-right-radius: 6px;
}

.wp-chatbot-message.bot .message-content {
    background: white;
    color: var(--wp-chatbot-text);
    border: 1px solid var(--wp-chatbot-border);
    border-bottom-left-radius: 6px;
}

.wp-chatbot-message.error .message-content {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 12px;
}

.message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    text-align: right;
}

.wp-chatbot-message.bot .message-time {
    text-align: left;
}

/* Retry Button */
.retry-btn {
    background: var(--wp-chatbot-primary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 8px;
    display: inline-block;
}

.retry-btn:hover {
    background: var(--wp-chatbot-primary-hover, #006ba6);
}

/* Input Container */
.wp-chatbot-input-container {
    display: flex;
    padding: 16px;
    background: white;
    border-top: 1px solid var(--wp-chatbot-border);
    gap: 8px;
}

#wp-chatbot-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--wp-chatbot-border);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
}

#wp-chatbot-input:focus {
    border-color: var(--wp-chatbot-primary);
}

.wp-chatbot-send-btn {
    width: 40px;
    height: 40px;
    background: var(--wp-chatbot-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.wp-chatbot-send-btn:hover {
    background: var(--wp-chatbot-primary-hover, #006ba6);
    transform: scale(1.05);
}

.wp-chatbot-send-btn svg {
    width: 16px;
    height: 16px;
}

/* Typing Indicator */
.wp-chatbot-typing {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #6b7280;
    font-size: 13px;
    background: white;
    border-top: 1px solid var(--wp-chatbot-border);
}

.typing-dots {
    margin-right: 8px;
}

.typing-dots span {
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #9ca3af;
    margin-right: 2px;
    animation: typing-dot 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing-dot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .wp-chatbot-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .wp-chatbot-start,
    .wp-chatbot-window {
        width: auto;
        left: 0;
        right: 0;
        bottom: 70px;
        height: calc(100vh - 120px);
        max-height: 600px;
    }
    
    .wp-chatbot-button {
        width: 50px;
        height: 50px;
        position: fixed;
        bottom: 20px;
        right: 20px;
        left: auto;
    }
    
    .wp-chatbot-button .wp-chatbot-icon {
        width: 20px;
        height: 20px;
    }
    
    .wp-chatbot-minimized {
        right: 60px;
        bottom: 5px;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .faq-options {
        gap: 6px;
    }
    
    .faq-option {
        padding: 10px;
        font-size: 13px;
    }
}

@media (max-width: 320px) {
    .wp-chatbot-start,
    .wp-chatbot-window {
        bottom: 80px;
        height: calc(100vh - 140px);
    }
    
    .wp-chatbot-header {
        padding: 12px;
    }
    
    .wp-chatbot-start-content {
        padding: 16px;
    }
    
    .wp-chatbot-messages {
        padding: 12px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wp-chatbot-button,
    .wp-chatbot-start-btn,
    .wp-chatbot-send-btn {
        border: 2px solid currentColor;
    }
    
    .wp-chatbot-message.user .message-content {
        border: 1px solid white;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .wp-chatbot-button::before {
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .wp-chatbot-start,
    .wp-chatbot-window {
        background: #1f2937;
        border: 1px solid #374151;
    }
    
    .wp-chatbot-messages {
        background: #111827;
    }
    
    .wp-chatbot-message.bot .message-content {
        background: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
    
    .wp-chatbot-input-container {
        background: #1f2937;
        border-color: #374151;
    }
    
    #wp-chatbot-input {
        background: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
    
    .wp-chatbot-typing {
        background: #1f2937;
        border-color: #374151;
        color: #9ca3af;
    }
    
    .form-group input {
        background: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
    
    .form-group label {
        color: #f9fafb;
    }
    
    .status-main {
        color: #f9fafb;
    }
}

/* Print styles */
@media print {
    .wp-chatbot-widget {
        display: none !important;
    }
}

/* Focus styles for accessibility */
.wp-chatbot-button:focus,
.wp-chatbot-close:focus,
.wp-chatbot-start-btn:focus,
.wp-chatbot-send-btn:focus,
.retry-btn:focus {
    outline: 2px solid var(--wp-chatbot-primary);
    outline-offset: 2px;
}

/* Loading states */
.wp-chatbot-loading {
    pointer-events: none;
    opacity: 0.7;
}

.wp-chatbot-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid var(--wp-chatbot-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}