/* ========================================
   Live Chat Widget Styles
   ======================================== */

/* Chat Toggle Button */
.chat-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.chat-toggle-btn:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.5);
}

.chat-toggle-btn:active {
    transform: scale(1);
}

.chat-toggle-btn::after {
    content: attr(data-unread);
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chat-toggle-btn.has-unread::after {
    opacity: 1;
}

.chat-toggle-btn.hide {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 120px;
    right: 30px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideIn 0.3s ease;
}

.chat-window.show {
    display: flex;
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 15px 15px 0 0;
}

.chat-header .chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
}

.chat-header .chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
}

.chat-header .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #27ae60;
}

.chat-header .status-dot.offline {
    background: #95a5a6;
}

.chat-header .chat-actions {
    display: flex;
    gap: 10px;
}

.chat-header .chat-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.chat-header .chat-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: messageFadeIn 0.3s ease;
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.visitor {
    align-self: flex-start;
    background: #e9ecef;
    color: #333;
    border-bottom-left-radius: 5px;
}

.message.admin {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 5px;
}

.message .message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
    display: block;
}

.message .message-name {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 3px;
    display: block;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    background: #e9ecef;
    border-radius: 18px;
    align-self: flex-start;
    max-width: 80%;
}

.typing-indicator.active {
    display: flex;
}

.typing-indicator span {
    display: inline-block;
    width: 5px;
    height: 5px;
    background: #999;
    border-radius: 50%;
    margin: 0 2px;
    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); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Chat Input Area */
.chat-input {
    display: flex;
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    gap: 10px;
}

.chat-input .chat-input-field {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    resize: none;
    min-height: 40px;
    max-height: 120px;
}

.chat-input .chat-input-field:focus {
    border-color: #667eea;
}

.chat-input .chat-input-field:placeholder-shown {
    color: #999;
}

.chat-input .chat-send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input .chat-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.chat-input .chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Chat Welcome Screen */
.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    color: #666;
}

.chat-welcome .welcome-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.chat-welcome h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 10px;
}

.chat-welcome p {
    font-size: 13px;
    line-height: 1.5;
}

/* Visitor Info Form (shown before first message) */
.chat-visitor-info {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.chat-visitor-info .visitor-name-input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.3s ease;
}

.chat-visitor-info .visitor-name-input:focus {
    border-color: #667eea;
}

.chat-visitor-info .visitor-start-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.chat-visitor-info .visitor-start-btn:hover {
    transform: translateY(-2px);
}

/* Tawk.to Custom Styles */
#tawkchat-container {
    z-index: 9998 !important;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-toggle-btn {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
        font-size: 24px;
    }

    .chat-window {
        bottom: 100px;
        right: 20px;
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
    }

    .message {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .chat-toggle-btn {
        bottom: 15px;
        right: 15px;
        width: 55px;
        height: 55px;
        font-size: 22px;
    }

    .chat-window {
        bottom: 90px;
        right: 15px;
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
    }
}

/* Notification Badge */
.chat-notification {
    position: fixed;
    top: 20px;
    right: 30px;
    background: #667eea;
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    font-size: 14px;
    max-width: 300px;
    display: none;
}

.chat-notification.show {
    display: block;
    animation: notificationSlide 0.3s ease;
}

@keyframes notificationSlide {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.chat-notification .notification-title {
    font-weight: 600;
    margin-bottom: 5px;
}

.chat-notification .notification-message {
    font-size: 13px;
    opacity: 0.9;
}