/* Chat Widget Styles */

/* Chat Launcher Button */
.chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0066cc, #004499);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 102, 204, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 102, 204, 0.5);
}

.chat-launcher svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.chat-launcher .notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #e53935;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chat-window.open {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #0066cc, #004499);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.chat-header-text h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-header-text p {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-actions button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s;
}

.chat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-header-actions svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Status Indicator */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-indicator.online {
    background: #4caf50;
}

.status-indicator.offline {
    background: #9e9e9e;
}

.status-indicator.busy {
    background: #ff9800;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

/* Message Bubble */
.chat-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.chat-message.visitor {
    align-self: flex-end;
}

.chat-message.ai,
.chat-message.agent,
.chat-message.system {
    align-self: flex-start;
}

.chat-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.visitor .chat-message-content {
    background: linear-gradient(135deg, #0066cc, #004499);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.ai .chat-message-content,
.chat-message.agent .chat-message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.chat-message.system .chat-message-content {
    background: #e3f2fd;
    color: #1565c0;
    text-align: center;
    font-size: 13px;
    font-style: italic;
    border-radius: 8px;
    align-self: center;
    max-width: 90%;
}

.chat-message-meta {
    font-size: 11px;
    color: #9e9e9e;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-message.visitor .chat-message-meta {
    justify-content: flex-end;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    max-width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9e9e9e;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.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(-6px); }
}

/* Chat Input Area */
.chat-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #0066cc;
}

.chat-input::placeholder {
    color: #9e9e9e;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0066cc;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
    background: #004499;
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Quick Actions */
.chat-quick-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.chat-quick-action {
    padding: 6px 14px;
    border: 1px solid #0066cc;
    border-radius: 16px;
    background: white;
    color: #0066cc;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-quick-action:hover {
    background: #0066cc;
    color: white;
}

/* Inline Contact Form (shown after wait timeout) */
.chat-contact-form {
    background: #f0f7ff;
    border: 1px solid #bbdefb;
    border-radius: 12px;
    padding: 16px;
    max-width: 100%;
}

.contact-form-header {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: #1565c0;
    margin-bottom: 8px;
    font-size: 14px;
}

.chat-contact-form p {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

.chat-contact-form a {
    color: #0066cc;
    font-weight: 600;
    text-decoration: none;
}

.chat-contact-form a:hover {
    text-decoration: underline;
}

.contact-form-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contact-form-fields input {
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.contact-form-fields input:focus {
    border-color: #0066cc;
}

.contact-form-fields button {
    padding: 10px 16px;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.contact-form-fields button:hover {
    background: #004499;
}

.chat-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-form-group label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.chat-form-group input {
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-form-group input:focus {
    border-color: #0066cc;
}

.chat-start-btn {
    padding: 12px;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-start-btn:hover {
    background: #004499;
}

/* Rating Form */
.chat-rating-form {
    padding: 20px;
    text-align: center;
}

.chat-rating-form h5 {
    margin: 0 0 16px 0;
    font-size: 16px;
}

.chat-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.chat-star {
    font-size: 32px;
    cursor: pointer;
    color: #e0e0e0;
    transition: color 0.2s, transform 0.2s;
}

.chat-star:hover,
.chat-star.active {
    color: #ffc107;
    transform: scale(1.1);
}

.chat-feedback-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    min-height: 60px;
    margin-bottom: 12px;
}

/* Custom Confirm Modal */
.chat-confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chat-confirm-modal.show {
    opacity: 1;
}

.chat-confirm-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.chat-confirm-dialog {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 28px 32px;
    max-width: 320px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.2s ease;
}

.chat-confirm-modal.show .chat-confirm-dialog {
    transform: scale(1);
}

.chat-confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: #fff3e0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-confirm-icon svg {
    width: 32px;
    height: 32px;
    fill: #ff9800;
}

.chat-confirm-dialog h5 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.chat-confirm-dialog p {
    margin: 0 0 24px 0;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.chat-confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.chat-confirm-cancel,
.chat-confirm-ok {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.chat-confirm-cancel {
    background: #f5f5f5;
    color: #666;
}

.chat-confirm-cancel:hover {
    background: #e0e0e0;
}

.chat-confirm-ok {
    background: #dc3545;
    color: white;
}

.chat-confirm-ok:hover {
    background: #c82333;
}

/* Conversation Ended Message */
.chat-conversation-ended {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 1px solid #a5d6a7;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    margin: 10px 0;
}

.chat-conversation-ended .ended-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: #4caf50;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-conversation-ended .ended-icon svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.chat-conversation-ended h5 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #2e7d32;
}

.chat-conversation-ended p {
    margin: 0;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

.chat-new-conversation-btn {
    margin-top: 16px;
    padding: 10px 24px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-new-conversation-btn:hover {
    background: #388e3c;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chat-launcher {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chat-messages {
        background: #1a1a2e;
    }

    .chat-message.ai .chat-message-content,
    .chat-message.agent .chat-message-content {
        background: #16213e;
        color: #e0e0e0;
        border-color: #333;
    }

    .chat-message.system .chat-message-content {
        background: #1a237e;
        color: #90caf9;
    }

    .chat-input-area {
        background: #0f0f1a;
        border-color: #333;
    }

    .chat-input {
        background: #1a1a2e;
        color: #e0e0e0;
        border-color: #333;
    }

    .chat-prechat-form {
        background: #1a1a2e;
    }

    .chat-prechat-form h5 {
        color: #e0e0e0;
    }

    .chat-prechat-form p {
        color: #9e9e9e;
    }
}
