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

.chat-toggle {
    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;
    color: white;
    position: relative;
}

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

.chat-toggle.active {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

/* Unread notification badge */
.chat-toggle::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ff4757;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

.chat-toggle.has-unread::after {
    opacity: 1;
    transform: scale(1);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

.chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.chat-container.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    font-weight: 600;
    position: relative;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
}

.chat-header p {
    margin: 5px 0 0 0;
    font-size: 14px;
    opacity: 0.9;
}

.chat-close {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

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

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

.chat-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.visitor {
    align-items: flex-end;
}

.chat-message.admin {
    align-items: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.chat-message.visitor .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.chat-message.admin .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
}

.message-time {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
}

.chat-form {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    background: white;
}

.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.chat-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

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

.chat-input.half {
    flex: 1;
}

.message-input-row {
    display: flex;
    gap: 10px;
}

.message-input {
    flex: 1;
}

.send-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Send button loading animation */
.send-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.chat-status {
    text-align: center;
    padding: 10px;
    font-size: 12px;
    color: #6c757d;
    transition: all 0.3s ease;
}

.chat-status.success {
    color: #28a745;
}

.chat-status.error {
    color: #dc3545;
}

.typing-indicator {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: white;
    border-radius: 18px;
    margin-bottom: 10px;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
    border: 1px solid #e9ecef;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.typing-text {
    margin-right: 8px;
    font-size: 12px;
    color: #6c757d;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

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

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Online status indicator */
.online-indicator {
    position: absolute;
    bottom: 5px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    opacity: 0.8;
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Responsive Design */
@media (max-width: 768px) {
    #chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .chat-container {
        width: calc(100vw - 40px);
        right: -10px;
        bottom: 70px;
        max-width: 350px;
    }
}

@media (max-width: 480px) {
    .chat-container {
        width: calc(100vw - 20px);
        right: -10px;
        height: 400px;
    }
    
    .chat-toggle {
        width: 50px;
        height: 50px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chat-container {
        background: #2d3748;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    }
    
    .chat-messages {
        background: #1a202c;
    }
    
    .chat-message.admin .message-bubble {
        background: #4a5568;
        color: white;
        border-color: #2d3748;
    }
    
    .chat-form {
        background: #2d3748;
        border-top-color: #4a5568;
    }
    
    .chat-input {
        background: #4a5568;
        color: white;
        border-color: #2d3748;
    }
    
    .chat-input::placeholder {
        color: #a0aec0;
    }
    
    .message-time {
        color: #a0aec0;
    }
    
    .chat-status {
        color: #a0aec0;
    }
}

/* Accessibility improvements */
.chat-toggle:focus {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

.chat-input:focus {
    outline: none;
}

.send-btn:focus {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    #chat-widget {
        display: none !important;
    }
}
