/**
 * Necta Chat Widget Styles
 *
 * @package Necta
 * @since   1.0.0
 */

#necta-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Chat Bubble */
.necta-chat-bubble {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.necta-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.necta-chat-bubble svg {
    width: 28px;
    height: 28px;
}

/* Badge */
.necta-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 12px;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
}

/* Chat Window */
.necta-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.necta-chat-open .necta-chat-window {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

.necta-chat-closed .necta-chat-window {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
}

/* Header */
.necta-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 10px;
}

.necta-chat-header-content {
    flex: 1;
    min-width: 0;
}

.necta-chat-header-content h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.necta-chat-header-content p {
    margin: 4px 0 0 0;
    font-size: 13px;
    opacity: 0.9;
}

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

.necta-chat-end,
.necta-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.necta-chat-end:hover {
    background: rgba(255, 71, 87, 0.8);
}

.necta-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Chat Body */
.necta-chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f5f7fb;
    min-height: 0;
}

/* Pre-chat Form */
.necta-pre-chat-form {
    padding: 40px 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.necta-pre-chat-form h4 {
    font-size: 22px;
    margin: 0 0 10px 0;
    color: #333;
}

.necta-pre-chat-form p {
    margin: 0 0 30px 0;
    font-size: 14px;
    color: #888;
}

.necta-form-group {
    margin-bottom: 15px;
}

.necta-pre-chat-form input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    box-sizing: border-box;
}

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

.necta-chat-button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.necta-chat-button:hover {
    opacity: 0.9;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.necta-pre-chat-form .necta-chat-error {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 15px;
    text-align: center;
    animation: shake 0.4s;
}

/* Messages Container */
.necta-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    scroll-behavior: smooth;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

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

.necta-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* Welcome Message */
.necta-chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.necta-chat-welcome h4 {
    font-size: 24px;
    margin: 0 0 10px 0;
    color: #333;
}

.necta-chat-welcome p {
    margin: 0;
    font-size: 14px;
    color: #999;
}

/* Message */
.necta-chat-message {
    display: flex;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.necta-chat-message:not(.necta-chat-message-animate) {
    opacity: 1;
}

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

.necta-chat-message-content {
    max-width: 75%;
}

.necta-chat-message-text {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.necta-chat-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 8px;
}

/* Customer Message */
.necta-chat-message-customer {
    justify-content: flex-end;
}

.necta-chat-message-customer .necta-chat-message-content {
    margin-left: auto;
}

.necta-chat-message-customer .necta-chat-message-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.necta-chat-message-customer .necta-chat-message-time {
    text-align: right;
}

/* Admin Message */
.necta-chat-message-admin {
    justify-content: flex-start;
}

.necta-chat-message-admin .necta-chat-message-text {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Typing Indicator */
.necta-chat-typing {
    display: flex;
    align-items: center;
    padding: 0 20px 10px 20px;
    background: #f5f7fb;
    gap: 8px;
}

.necta-typing-indicator {
    background: white;
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

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

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

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

.necta-typing-text {
    font-size: 12px;
    color: #999;
}

/* Input Wrapper */
.necta-chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 16px;
    background: white;
    border-top: 1px solid #e8ecf1;
    flex-shrink: 0;
}

.necta-chat-input {
    flex: 1;
    border: 1px solid #e8ecf1;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.2s;
    line-height: 1.5;
    min-height: 40px;
    max-height: 120px;
}

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

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

.necta-chat-send:hover:not(:disabled) {
    background: #5568d3;
    transform: scale(1.05);
}

.necta-chat-send:disabled {
    background: #ddd;
    cursor: not-allowed;
}

/* Error Message */
.necta-chat-error {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
    animation: shake 0.4s;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

/* Conversation closed notification */
.necta-chat-closed-notification {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    text-align: center;
    flex-shrink: 0;
}

.necta-chat-closed-content p {
    margin: 10px 0;
    color: #495057;
}

.necta-chat-closed-content p:first-child {
    font-size: 16px;
    color: #212529;
}

.necta-end-chat-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

.necta-end-chat-btn:hover {
    background: #c82333;
}

/* End chat confirmation */
.necta-chat-end-confirm {
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 0;
    padding: 15px;
    background: #fff3cd;
    border-bottom: 2px solid #ffc107;
    text-align: center;
    flex-shrink: 0;
}

.necta-chat-end-confirm-content p {
    margin: 0 0 10px 0;
    color: #856404;
    font-size: 14px;
}

.necta-chat-end-confirm-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.necta-confirm-yes,
.necta-confirm-no {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.necta-confirm-yes {
    background: #dc3545;
    color: white;
}

.necta-confirm-yes:hover {
    background: #c82333;
}

.necta-confirm-no {
    background: #6c757d;
    color: white;
}

.necta-confirm-no:hover {
    background: #5a6268;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #necta-chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .necta-chat-window {
        width: 100%;
        max-width: 100%;
        height: 500px;
        bottom: 70px;
    }

    .necta-chat-bubble {
        margin-left: auto;
    }
}

/* Animation for new messages */
.necta-chat-message-animate {
    animation: slideIn 0.3s ease forwards;
}

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