/**
 * Live Chat Support Widget
 * Modern, Clean Design with Best Practices
 */

/* ==================== BASE WIDGET ==================== */
.live-chat-widget {
    display: none !important; /* HIDDEN - Remove this line to show widget */
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ==================== TOGGLE BUTTON ==================== */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #000;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid #fff;
}

/* ==================== CHAT WINDOW ==================== */
.chat-window,
#chatWindow {
    position: absolute !important;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px !important;
    max-height: 600px !important;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* ==================== HEADER ==================== */
.chat-header {
    background: #000;
    color: #fff;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    transition: opacity 0.2s;
}

.chat-close-btn:hover {
    opacity: 0.7;
}

/* ==================== INIT FORM ==================== */
.chat-init-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 30px;
    background: #f9f9f9;
}

.chat-init-content h4 {
    margin: 0 0 10px 0;
    color: #000;
    font-size: 20px;
    font-weight: 600;
}

.chat-init-content p {
    margin: 0 0 25px 0;
    color: #666;
    font-size: 14px;
}

.chat-init-form .form-group {
    margin-bottom: 18px;
}

.chat-init-form label {
    display: block;
    margin-bottom: 6px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.chat-init-form .form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.chat-init-form .form-control:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.chat-init-form .btn-block {
    width: 100%;
    padding: 12px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-init-form .btn-block:hover {
    background: #333;
}

/* ==================== MESSAGES AREA (SCROLLABLE) ==================== */
.chat-messages,
#chatMessages {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 20px;
    background: #f9f9f9;
    min-height: 0 !important;
    max-height: 100% !important;
}

/* SCROLLBAR */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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

/* ==================== MESSAGE BUBBLES ==================== */
.chat-message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
    flex-shrink: 0;
}

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

.chat-message.client {
    justify-content: flex-end;
}

.chat-message.manager {
    justify-content: flex-start;
}

.chat-message.system {
    justify-content: center;
}

.chat-message-content {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
}

.chat-message.client .chat-message-content {
    background: #000;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message.manager .chat-message-content {
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
    border-bottom-left-radius: 4px;
}

.chat-message.system .chat-message-content {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    text-align: center;
    font-size: 13px;
    max-width: 85%;
}

.chat-message-sender {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 4px;
    opacity: 0.85;
}

.chat-message-text {
    font-size: 14px;
    line-height: 1.4;
}

.chat-message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
}

/* ==================== INPUT AREA ==================== */
.chat-input-area {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    background: #fff;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #000;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: #333;
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -10px;
    }

    .chat-toggle-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

/* ==================== CHAT HEADER ENHANCEMENTS ==================== */
.chat-status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    opacity: 0.9;
}

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

.status-dot.offline {
    background: #dc3545;
    animation: none;
}

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

.chat-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    transition: opacity 0.2s;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-action-btn:hover {
    opacity: 0.7;
}

/* ==================== VISITOR INFO FORM ==================== */
.visitor-info-form {
    flex-shrink: 0 !important;
    padding: 20px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* If visitor form is last element */
.visitor-info-form:last-child {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.chat-input-field {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.chat-input-field:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.visitor-info-form .chat-send-btn {
    width: 100%;
    height: 44px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 5px;
}

/* ==================== MESSAGE INPUT FORM ==================== */
.message-input-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #ddd;
}

/* If message input is last element (no footer visible) */
.message-input-form:last-child {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.chat-message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    transition: border-color 0.2s;
    min-height: 40px;
}

.chat-message-input:focus {
    outline: none;
    border-color: #000;
}

/* ==================== TYPING INDICATOR ==================== */
.typing-indicator {
    flex-shrink: 0 !important;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f9f9f9;
}

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

.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(-10px);
    }
}

/* ==================== CHAT FOOTER ==================== */
.chat-footer {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    padding: 10px 20px;
    background: #f9f9f9;
    border-top: 1px solid #ddd;
    text-align: center;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* ==================== SCROLLBAR IMPROVEMENTS ==================== */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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