/* Chat Widget Styles */

/* Chat Button */
#chat-widget-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

#chat-widget-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

#chat-widget-button .chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    display: none;
}

/* Chat Window */
#chat-widget-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: width 0.3s ease, height 0.3s ease, bottom 0.3s ease, right 0.3s ease;
}

#chat-widget-window.open {
    display: flex;
    animation: slideUp 0.3s ease;
}

/* Expanded/Maximized state */
#chat-widget-window.expanded {
    width: 600px;
    height: 700px;
    bottom: 20px;
    right: 20px;
}

@media (max-width: 768px) {
    #chat-widget-window.expanded {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-header-title .status {
    font-size: 12px;
    opacity: 0.9;
}

.chat-header-title .status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-expand-btn,
.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-expand-btn:hover,
.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
}

.chat-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.bot,
.chat-message.admin {
    align-items: flex-start;
}

.chat-message .message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.bot .message-content {
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-message.admin .message-content {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    border-bottom-left-radius: 4px;
}

.chat-message .message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-message .message-sender {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 4px;
    font-weight: 500;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

/* Chat Input */
.chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    max-height: 100px;
    font-family: inherit;
}

.chat-input:focus {
    border-color: #667eea;
}

.chat-send-btn {
    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: transform 0.2s, opacity 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Quick Actions */
.chat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.quick-action-btn {
    padding: 8px 14px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

/* Waiting for Human */
.waiting-for-human {
    text-align: center;
    padding: 16px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 12px;
    margin: 12px 0;
}

.waiting-for-human p {
    margin: 0;
    color: #92400e;
    font-size: 14px;
}

.waiting-for-human .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #fcd34d;
    border-top-color: #f59e0b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #chat-widget-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 10px;
        left: 10px;
        border-radius: 12px;
    }
    
    #chat-widget-button {
        bottom: 15px;
        right: 15px;
        width: 56px;
        height: 56px;
    }
}

/* Dark Mode Support */
.dark-mode #chat-widget-window {
    background: #1f1f1f;
}

.dark-mode .chat-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.dark-mode .chat-messages {
    background: #0f0f0f;
}

.dark-mode .chat-message.bot .message-content {
    background: #2a2a2a;
    color: #e8e8e8;
    border-color: #3a3a3a;
}

.dark-mode .chat-message.admin .message-content {
    background: #14532d;
    color: #bbf7d0;
    border-color: #22c55e;
}

.dark-mode .chat-message .message-time {
    color: #a0a0a0;
}

.dark-mode .chat-message .message-sender {
    color: #d0d0d0;
}

.dark-mode .typing-indicator {
    background: #2a2a2a;
    border-color: #3a3a3a;
}

.dark-mode .typing-indicator span {
    background: #a0a0a0;
}

.dark-mode .chat-input-container {
    background: #1f1f1f;
    border-top-color: #3a3a3a;
}

.dark-mode .chat-input {
    background: #0f0f0f;
    color: #e8e8e8;
    border-color: #3a3a3a;
}

.dark-mode .chat-input:focus {
    border-color: #3b82f6;
}

.dark-mode .chat-input::placeholder {
    color: #888;
}

.dark-mode .chat-send-btn {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.dark-mode .chat-quick-actions {
    background: #1f1f1f;
    border-top-color: #3a3a3a;
}

.dark-mode .quick-action-btn {
    background: #2a2a2a;
    border-color: #3a3a3a;
    color: #e8e8e8;
}

.dark-mode .quick-action-btn:hover {
    background: #333;
    border-color: #444;
}

.dark-mode .waiting-for-human {
    background: #78350f;
    border-color: #fbbf24;
}

.dark-mode .waiting-for-human p {
    color: #fde68a;
}

.dark-mode .waiting-for-human .spinner {
    border-color: #fbbf24;
    border-top-color: #f59e0b;
}

.dark-mode #chat-widget-button {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
}

.dark-mode #chat-widget-button:hover {
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}
