/* =============================================
   LIVE CHAT WIDGET STYLES
   ============================================= */

/* Chat Widget Container */
.livechat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Chat Button */
.livechat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color, #0066cc), var(--primary-hover, #0052a3));
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
}

.livechat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.livechat-button-text {
    display: none;
}

.livechat-icon {
    width: 28px;
    height: 28px;
}

/* Unread Badge */
.livechat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    background: #ff3b30 !important;
    color: white !important;
    border-radius: 11px;
    display: none; /* Hidden by default, shown via JS */
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    padding: 0 6px;
    border: 2px solid white;
    animation: pulse-badge 2s infinite;
    z-index: 10;
}

.livechat-unread-badge[style*="display: flex"] {
    display: flex !important;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Window */
.livechat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--bg-primary, #ffffff);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.livechat-header {
    background: linear-gradient(135deg, var(--primary-color, #0066cc), var(--primary-hover, #0052a3));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.livechat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.livechat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.livechat-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.livechat-header-title {
    font-size: 16px;
    font-weight: 600;
}

.livechat-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.livechat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4cd964;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.livechat-header-actions {
    display: flex;
    gap: 8px;
}

.livechat-minimize,
.livechat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    color: white;
}

.livechat-minimize:hover,
.livechat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Pre-chat Form */
.livechat-prechat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.livechat-prechat-content {
    width: 100%;
    max-width: 320px;
}

.livechat-prechat-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary, #000000);
}

.livechat-prechat-subtitle {
    font-size: 14px;
    color: var(--text-secondary, #666666);
    margin-bottom: 24px;
}

.livechat-form-group {
    margin-bottom: 16px;
}

.livechat-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary, #000000);
}

.livechat-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color, #dddddd);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-primary, #000000);
    transition: border 0.2s;
}

.livechat-input:focus {
    outline: none;
    border-color: var(--primary-color, #0066cc);
}

.livechat-submit-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-color, #0066cc);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.livechat-submit-btn:hover {
    background: var(--primary-hover, #0052a3);
    transform: translateY(-1px);
}

.livechat-prechat-note {
    font-size: 12px;
    color: var(--text-secondary, #666666);
    text-align: center;
    margin-top: 12px;
}

/* Messages Area */
.livechat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-secondary, #f5f5f5);
    display: flex;
    flex-direction: column;
}

.livechat-messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubble */
.livechat-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.livechat-message.message-visitor {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.livechat-message.message-admin,
.livechat-message.message-ai {
    align-self: flex-start;
}

.livechat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.message-visitor .livechat-message-avatar {
    background: var(--primary-color, #0066cc);
    color: white;
}

.message-admin .livechat-message-avatar,
.message-ai .livechat-message-avatar {
    background: #6366f1;
    color: white;
}

.livechat-message-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.livechat-message-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #666666);
    padding: 0 4px;
}

.livechat-message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-visitor .livechat-message-bubble {
    background: var(--primary-color, #0066cc);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-admin .livechat-message-bubble,
.message-ai .livechat-message-bubble {
    background: var(--bg-secondary, #f8f9fa);
    color: var(--text-primary, #000000);
    border: 1px solid var(--border-color, #dddddd);
    border-bottom-left-radius: 4px;
}

.livechat-message-bubble a {
    color: inherit;
    text-decoration: underline;
}

.message-visitor .livechat-message-bubble a {
    color: rgba(255, 255, 255, 0.9);
}

.message-admin .livechat-message-bubble a,
.message-ai .livechat-message-bubble a {
    color: var(--primary-color, #0066cc);
    font-weight: 500;
}

.livechat-message-time {
    font-size: 10px;
    color: var(--text-secondary, #999999);
    padding: 0 4px;
}

/* Typing Indicator */
.livechat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    align-self: flex-start;
    margin-top: 8px;
}

.livechat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary, #666666);
    animation: typing-dot 1.4s infinite;
}

.livechat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.livechat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-dot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

.livechat-typing-text {
    font-size: 12px;
    color: var(--text-secondary, #666666);
}

/* Input Area */
.livechat-input-area {
    padding: 16px;
    background: var(--bg-primary, #ffffff);
    border-top: 1px solid var(--border-color, #dddddd);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.livechat-message-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.livechat-message-form textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color, #dddddd);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 45px;
    max-height: 100px;
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-primary, #000000);
}

.livechat-message-form textarea:focus {
    outline: none;
    border-color: var(--primary-color, #0066cc);
}

.livechat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color, #0066cc);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.livechat-send-btn:hover {
    background: var(--primary-hover, #0052a3);
    transform: scale(1.05);
}

.livechat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.livechat-powered-by {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary, #999999);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .livechat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .livechat-widget {
        bottom: 10px;
        right: 10px;
    }
}
