/**
 * CenterChat Widget Styles
 */

/* CSS Variables */
:root {
    --centerchat-primary: #667eea;
    --centerchat-primary-dark: #5a6fd6;
    --centerchat-text: #333;
    --centerchat-text-light: #666;
    --centerchat-bg: #fff;
    --centerchat-bg-light: #f8f9fa;
    --centerchat-border: #e0e0e0;
    --centerchat-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
}

/* Widget Container */
#centerchat-widget-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

#centerchat-widget-container.bottom-right {
    bottom: 20px;
    right: 20px;
}

#centerchat-widget-container.bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.centerchat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--centerchat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--centerchat-shadow);
    transition: all 0.3s ease;
    position: relative;
}

.centerchat-toggle:hover {
    transform: scale(1.1);
    background: var(--centerchat-primary-dark);
}

.centerchat-toggle svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: all 0.3s ease;
}

.centerchat-toggle.open svg.chat-icon {
    display: none;
}

.centerchat-toggle.open svg.close-icon {
    display: block;
}

.centerchat-toggle svg.close-icon {
    display: none;
}

/* Unread Badge */
.centerchat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.centerchat-badge:empty {
    display: none;
}

/* Chat Window */
.centerchat-window {
    position: absolute;
    bottom: 80px;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--centerchat-bg);
    border-radius: 16px;
    box-shadow: var(--centerchat-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: centerchat-slide-up 0.3s ease;
}

.bottom-right .centerchat-window {
    right: 0;
}

.bottom-left .centerchat-window {
    left: 0;
}

.centerchat-window.open {
    display: flex;
}

@keyframes centerchat-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.centerchat-header {
    background: var(--centerchat-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.centerchat-header-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.centerchat-header-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.centerchat-header-info {
    flex: 1;
}

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

.centerchat-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.centerchat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
}

.centerchat-status-dot.offline {
    background: #95a5a6;
}

/* Messages Container */
.centerchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--centerchat-bg-light);
}

/* Message Bubble */
.centerchat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
}

.centerchat-message.visitor {
    background: var(--centerchat-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.centerchat-message.agent {
    background: white;
    color: var(--centerchat-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.centerchat-message.system {
    background: transparent;
    color: var(--centerchat-text-light);
    align-self: center;
    font-size: 12px;
    padding: 8px;
    text-align: center;
}

.centerchat-message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
}

/* Typing Indicator */
.centerchat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.centerchat-typing-dots {
    display: flex;
    gap: 4px;
}

.centerchat-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--centerchat-primary);
    border-radius: 50%;
    animation: centerchat-bounce 1.4s infinite ease-in-out;
}

.centerchat-typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.centerchat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.centerchat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes centerchat-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.6;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.centerchat-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid var(--centerchat-border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.centerchat-input {
    flex: 1;
    border: 1px solid var(--centerchat-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.centerchat-input:focus {
    border-color: var(--centerchat-primary);
}

.centerchat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--centerchat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.centerchat-send:hover {
    background: var(--centerchat-primary-dark);
    transform: scale(1.05);
}

.centerchat-send:disabled {
    background: var(--centerchat-border);
    cursor: not-allowed;
    transform: none;
}

.centerchat-send svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Pre-chat Form */
.centerchat-prechat {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--centerchat-bg-light);
}

.centerchat-prechat h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: var(--centerchat-text);
}

.centerchat-prechat p {
    margin: 0;
    color: var(--centerchat-text-light);
    font-size: 14px;
}

.centerchat-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.centerchat-form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--centerchat-text);
}

.centerchat-form-group input {
    padding: 12px 14px;
    border: 1px solid var(--centerchat-border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.centerchat-form-group input:focus {
    border-color: var(--centerchat-primary);
}

.centerchat-start-btn {
    background: var(--centerchat-primary);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.centerchat-start-btn:hover {
    background: var(--centerchat-primary-dark);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .centerchat-window {
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: none;
        bottom: 0;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0;
    }
    
    #centerchat-widget-container.hide-mobile {
        display: none !important;
    }
}

/* Connection Status */
.centerchat-connection-status {
    padding: 8px 16px;
    background: #fff3cd;
    color: #856404;
    font-size: 12px;
    text-align: center;
    display: none;
}

.centerchat-connection-status.show {
    display: block;
}

.centerchat-connection-status.error {
    background: #f8d7da;
    color: #721c24;
}

.centerchat-connection-status.connected {
    background: #d4edda;
    color: #155724;
}
