/**
 * Frontend Styles
 * WP Content Chatbot
 */

/* Chat Widget Container */
.wpcb-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Chat Button */
.wpcb-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.wpcb-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.wpcb-chat-button:active {
    transform: scale(1.05);
}

.wpcb-chat-button svg {
    width: 28px;
    height: 28px;
    color: #ffffff;
    position: relative;
    z-index: 1;
}

.wpcb-chat-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0);
    border-radius: 50%;
    transition: transform 0.6s ease;
}

.wpcb-chat-button:hover::before {
    transform: scale(1);
}

/* Chat Window */
.wpcb-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wpcb-slide-up 0.3s ease;
}

@keyframes wpcb-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.wpcb-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wpcb-chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 16px;
}

.wpcb-chat-title svg {
    width: 24px;
    height: 24px;
}

.wpcb-close-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.wpcb-close-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.wpcb-close-button svg {
    width: 18px;
    height: 18px;
    color: #ffffff;
}

/* Chat Messages */
.wpcb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.wpcb-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.wpcb-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.wpcb-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message Bubbles */
.wpcb-message {
    margin-bottom: 16px;
    display: flex;
    animation: wpcb-fade-in 0.3s ease;
}

@keyframes wpcb-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wpcb-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.wpcb-message-bot .wpcb-message-content {
    background: #ffffff;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wpcb-message-user {
    justify-content: flex-end;
}

.wpcb-message-user .wpcb-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* Message Sources */
.wpcb-message-sources {
    margin-top: 8px;
    padding-top: 0;
    border-top: none;
    font-size: 11px;
    line-height: 1.4;
    display: block;
}

.wpcb-source-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    font-size: 11px;
    display: inline-block;
    margin-top: 5px;
    transition: color 0.2s ease;
}

.wpcb-source-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* Typing Indicator */
.wpcb-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wpcb-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    animation: wpcb-typing 1.4s infinite;
}

.wpcb-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.wpcb-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes wpcb-typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* Chat Input Container */
.wpcb-chat-input-container {
    display: flex;
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    gap: 12px;
}

.wpcb-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.wpcb-chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.wpcb-send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.wpcb-send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.wpcb-send-button:active {
    transform: scale(0.95);
}

.wpcb-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wpcb-send-button:disabled:hover {
    transform: none;
    box-shadow: none;
}

.wpcb-send-button svg {
    width: 20px;
    height: 20px;
    color: #ffffff;
}

/* Error Message */
.wpcb-error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    text-align: center;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .wpcb-chat-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .wpcb-chat-window {
        width: 100%;
        max-width: 380px;
        height: 500px;
        bottom: 80px;
        right: 0;
    }
    
    .wpcb-chat-button {
        width: 56px;
        height: 56px;
    }
    
    .wpcb-chat-button svg {
        width: 24px;
        height: 24px;
    }
}

@media screen and (max-width: 480px) {
    .wpcb-chat-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .wpcb-chat-window {
        width: calc(100vw - 30px);
        max-width: 380px;
        height: 500px;
        bottom: 80px;
        right: 0;
    }
    
    .wpcb-chat-button {
        width: 56px;
        height: 56px;
    }
    
    .wpcb-chat-button svg {
        width: 24px;
        height: 24px;
    }
    
    .wpcb-message-content {
        max-width: 85%;
    }
}

@media screen and (max-width: 375px) {
    .wpcb-chat-widget {
        bottom: 12px;
        right: 12px;
    }
    
    .wpcb-chat-button {
        width: 52px;
        height: 52px;
    }
}

/* Accessibility */
.wpcb-chat-button:focus,
.wpcb-close-button:focus,
.wpcb-send-button:focus,
.wpcb-chat-input:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Debug Panel Styles */
.wpcb-debug-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #ffffff;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.wpcb-debug-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.wpcb-debug-panel {
    background: #1e1e1e;
    border-top: 1px solid #333;
    max-height: 200px;
    overflow-y: auto;
    flex-shrink: 0;
}

.wpcb-debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #2d2d2d;
    border-bottom: 1px solid #444;
}

.wpcb-debug-header strong {
    color: #ffc107;
    font-size: 12px;
    font-weight: 600;
}

.wpcb-debug-clear-btn {
    background: #dc3545;
    color: #ffffff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wpcb-debug-clear-btn:hover {
    background: #c82333;
}

.wpcb-debug-content {
    padding: 8px;
    max-height: 150px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 11px;
}

.wpcb-debug-content::-webkit-scrollbar {
    width: 6px;
}

.wpcb-debug-content::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.wpcb-debug-content::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.wpcb-debug-content::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.wpcb-debug-entry {
    padding: 6px 8px;
    margin-bottom: 6px;
    border-radius: 4px;
    border-left: 3px solid;
    background: #2d2d2d;
    animation: wpcb-debug-fade-in 0.3s ease;
}

@keyframes wpcb-debug-fade-in {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wpcb-debug-entry.wpcb-debug-info {
    border-left-color: #667eea;
    color: #a0b0ff;
}

.wpcb-debug-entry.wpcb-debug-success {
    border-left-color: #28a745;
    color: #90ee90;
}

.wpcb-debug-entry.wpcb-debug-warning {
    border-left-color: #ffc107;
    color: #ffd966;
}

.wpcb-debug-entry.wpcb-debug-error {
    border-left-color: #dc3545;
    color: #ff9999;
}

.wpcb-debug-time {
    color: #888;
    font-size: 10px;
    margin-right: 6px;
}

.wpcb-debug-icon {
    margin-right: 6px;
}

.wpcb-debug-entry strong {
    color: inherit;
    font-weight: 600;
}

.wpcb-debug-data {
    margin: 6px 0 0 0;
    padding: 8px;
    background: #1a1a1a;
    border-radius: 3px;
    font-size: 10px;
    color: #c0c0c0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Adjust chat window when debug panel is visible */
.wpcb-chat-window.wpcb-debug-active {
    height: 600px;
}

/* Print Styles */
@media print {
    .wpcb-chat-widget {
        display: none !important;
    }
}
