/**
 * InfoChat Widget Styles
 */

/* CSS Variables - set via PHP inline styles */
:root {
    --infochat-primary: #0073aa;
    --infochat-primary-dark: #005d8c;
    --infochat-primary-light: #e6f3f8;
    --infochat-text: #333333;
    --infochat-text-light: #666666;
    --infochat-bg: #ffffff;
    --infochat-border: #e0e0e0;
    --infochat-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    --infochat-radius: 16px;
    --infochat-radius-sm: 8px;
}

/* Reset for widget */
.infochat-widget,
.infochat-widget * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Widget Container */
.infochat-widget {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
}

.infochat-widget.infochat-right {
    right: 20px;
}

.infochat-widget.infochat-left {
    left: 20px;
}

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

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

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

.infochat-toggle .infochat-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
}

.infochat-widget.infochat-open .infochat-toggle .infochat-icon-chat {
    opacity: 0;
    transform: rotate(90deg);
}

.infochat-widget.infochat-open .infochat-toggle .infochat-icon-close {
    opacity: 1;
    transform: rotate(0);
}

/* Chat Window */
.infochat-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--infochat-bg);
    border-radius: var(--infochat-radius);
    box-shadow: var(--infochat-shadow);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    overflow: hidden;
}

.infochat-widget.infochat-right .infochat-window {
    right: 0;
}

.infochat-widget.infochat-left .infochat-window {
    left: 0;
}

.infochat-widget.infochat-open .infochat-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.infochat-header {
    background: var(--infochat-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.infochat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.infochat-avatar svg {
    width: 24px;
    height: 24px;
    color: white;
}

.infochat-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.infochat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.infochat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
}

.infochat-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.infochat-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

.infochat-minimize svg {
    width: 16px;
    height: 16px;
    color: white;
}

/* Messages Container */
.infochat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8f9fa;
}

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

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

.infochat-messages::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

/* Message Bubbles */
.infochat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: infochat-fade-in 0.3s ease;
}

@keyframes infochat-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.infochat-message.infochat-user {
    align-self: flex-end;
}

.infochat-message.infochat-assistant {
    align-self: flex-start;
}

.infochat-message-content {
    padding: 12px 16px;
    border-radius: var(--infochat-radius);
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.infochat-message.infochat-user .infochat-message-content {
    background: var(--infochat-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.infochat-message.infochat-assistant .infochat-message-content {
    background: white;
    color: var(--infochat-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.infochat-message-time {
    font-size: 11px;
    color: var(--infochat-text-light);
    margin-top: 4px;
    padding: 0 4px;
}

.infochat-message.infochat-user .infochat-message-time {
    text-align: right;
}

/* Typing Indicator */
.infochat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: var(--infochat-radius);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    max-width: 60px;
}

.infochat-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--infochat-text-light);
    border-radius: 50%;
    animation: infochat-typing 1.4s infinite;
}

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

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

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

/* Welcome Message */
.infochat-welcome {
    text-align: center;
    padding: 20px;
}

.infochat-welcome-icon {
    width: 60px;
    height: 60px;
    background: var(--infochat-primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.infochat-welcome-icon svg {
    width: 32px;
    height: 32px;
    color: var(--infochat-primary);
}

.infochat-welcome h4 {
    margin: 0 0 8px;
    font-size: 16px;
    color: var(--infochat-text);
}

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

/* Lead Form */
.infochat-lead-form {
    padding: 20px;
    background: white;
    border-top: 1px solid var(--infochat-border);
}

.infochat-lead-form-inner h4 {
    margin: 0 0 16px;
    font-size: 14px;
    color: var(--infochat-text);
}

.infochat-lead-form-inner input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--infochat-border);
    border-radius: var(--infochat-radius-sm);
    margin-bottom: 10px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.infochat-lead-form-inner input:focus {
    outline: none;
    border-color: var(--infochat-primary);
}

.infochat-lead-form-inner button {
    width: 100%;
    padding: 12px;
    background: var(--infochat-primary);
    color: white;
    border: none;
    border-radius: var(--infochat-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.infochat-lead-form-inner button:hover {
    background: var(--infochat-primary-dark);
}

/* Input Area */
.infochat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--infochat-border);
    flex-shrink: 0;
}

.infochat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.infochat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--infochat-border);
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.infochat-input:focus {
    outline: none;
    border-color: var(--infochat-primary);
}

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

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

.infochat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.infochat-send svg {
    width: 18px;
    height: 18px;
    color: white;
}

.infochat-powered {
    text-align: center;
    font-size: 11px;
    color: var(--infochat-text-light);
    margin-top: 8px;
}

/* Quick Actions */
.infochat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    background: #f8f9fa;
}

.infochat-quick-action {
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--infochat-border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--infochat-text);
    cursor: pointer;
    transition: all 0.2s;
}

.infochat-quick-action:hover {
    background: var(--infochat-primary-light);
    border-color: var(--infochat-primary);
    color: var(--infochat-primary);
}

/* Error Message */
.infochat-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: var(--infochat-radius-sm);
    font-size: 13px;
    margin: 10px 20px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .infochat-widget {
        bottom: 10px;
    }
    
    .infochat-widget.infochat-right {
        right: 10px;
    }
    
    .infochat-widget.infochat-left {
        left: 10px;
    }
    
    .infochat-window {
        position: fixed;
        width: 100vw;
        height: calc(100vh - 70px);
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        max-width: 100vw;
        max-height: calc(100vh - 70px);
    }
    
    .infochat-widget.infochat-right .infochat-window,
    .infochat-widget.infochat-left .infochat-window {
        right: 0;
        left: 0;
    }
    
    .infochat-toggle {
        width: 54px;
        height: 54px;
    }
    
    .infochat-toggle svg {
        width: 24px;
        height: 24px;
    }
    
    /* Hide toggle when chat is open on mobile */
    .infochat-widget.infochat-open .infochat-toggle {
        opacity: 0;
        pointer-events: none;
    }
}

/* Notification Badge */
.infochat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: infochat-pulse 2s infinite;
}

@keyframes infochat-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .infochat-widget {
        --infochat-bg: #1f2937;
        --infochat-text: #f9fafb;
        --infochat-text-light: #9ca3af;
        --infochat-border: #374151;
    }
    
    .infochat-messages {
        background: #111827;
    }
    
    .infochat-message.infochat-assistant .infochat-message-content {
        background: #374151;
        color: #f9fafb;
    }
    
    .infochat-lead-form-inner input {
        background: #374151;
        color: #f9fafb;
    }
    
    .infochat-input {
        background: #374151;
        color: #f9fafb;
    }
    
    .infochat-quick-action {
        background: #374151;
        color: #f9fafb;
    }
}

/* System Messages (operator joined/left) */
.infochat-message.infochat-system {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}

.infochat-message.infochat-system .infochat-system-content {
    background: var(--infochat-primary-light);
    color: var(--infochat-primary-dark);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 12px;
    text-align: center;
    max-width: 80%;
}

/* Sender name for operator messages */
.infochat-message-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--infochat-primary);
    margin-bottom: 4px;
}

/* Live operator indicator */
.infochat-status.infochat-live {
    color: #22c55e;
}

.infochat-status.infochat-live::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

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