/**
 * My Live Chat - Frontend Widget Styles
 * 
 * Scoped with .mlc- prefix to avoid theme conflicts.
 */

/* CSS Custom Properties for easy theming */
:root {
    --mlc-primary: #0073aa;
    --mlc-primary-hover: #005a87;
    --mlc-online: #28a745;
    --mlc-offline: #6c757d;
    --mlc-bg: #fff;
    --mlc-bg-secondary: #f8f9fa;
    --mlc-border: #e0e0e0;
    --mlc-text: #333;
    --mlc-text-muted: #666;
    --mlc-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --mlc-radius: 12px;
    --mlc-radius-sm: 8px;
}

/* Reset scoped to widget */
.mlc-widget,
.mlc-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Widget container */
.mlc-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--mlc-text);
}

/* Launcher button */
.mlc-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--mlc-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--mlc-shadow);
    transition: transform 0.2s, background 0.2s;
    position: relative;
}

.mlc-launcher:hover {
    background: var(--mlc-primary-hover);
    transform: scale(1.05);
}

.mlc-launcher:focus {
    outline: 2px solid var(--mlc-primary);
    outline-offset: 2px;
}

.mlc-launcher svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

/* Unread badge */
.mlc-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Chat panel */
.mlc-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--mlc-bg);
    border-radius: var(--mlc-radius);
    box-shadow: var(--mlc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mlc-slide-up 0.2s ease-out;
}

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

/* Header */
.mlc-header {
    background: var(--mlc-primary);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mlc-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mlc-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--mlc-offline);
    flex-shrink: 0;
}

.mlc-status-indicator.mlc-online {
    background: var(--mlc-online);
}

.mlc-header-title {
    font-weight: 600;
    font-size: 16px;
}

.mlc-status-text {
    font-size: 13px;
    opacity: 0.9;
}

/* GDPR Notice */
.mlc-gdpr-notice {
    padding: 16px;
    background: var(--mlc-bg-secondary);
    border-bottom: 1px solid var(--mlc-border);
    text-align: center;
}

.mlc-gdpr-notice p {
    font-size: 13px;
    color: var(--mlc-text-muted);
    margin-bottom: 12px;
}

.mlc-gdpr-accept {
    background: var(--mlc-primary);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--mlc-radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.mlc-gdpr-accept:hover {
    background: var(--mlc-primary-hover);
}

/* Messages area */
.mlc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message bubbles */
.mlc-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mlc-message.mlc-visitor {
    align-self: flex-end;
}

.mlc-message.mlc-agent {
    align-self: flex-start;
}

.mlc-message-bubble {
    padding: 10px 14px;
    border-radius: var(--mlc-radius-sm);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mlc-visitor .mlc-message-bubble {
    background: var(--mlc-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.mlc-agent .mlc-message-bubble {
    background: var(--mlc-bg-secondary);
    color: var(--mlc-text);
    border-bottom-left-radius: 4px;
}

.mlc-message-bubble a {
    color: inherit;
    text-decoration: underline;
}

.mlc-message-time {
    font-size: 11px;
    color: var(--mlc-text-muted);
}

.mlc-visitor .mlc-message-time {
    text-align: right;
}

/* Attachments in messages */
.mlc-message-attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.mlc-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--mlc-radius-sm);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.mlc-attachment:hover {
    background: rgba(0, 0, 0, 0.1);
}

.mlc-visitor .mlc-attachment {
    background: rgba(255, 255, 255, 0.15);
}

.mlc-visitor .mlc-attachment:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mlc-attachment-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.mlc-attachment-info {
    flex: 1;
    min-width: 0;
}

.mlc-attachment-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mlc-attachment-size {
    font-size: 11px;
    opacity: 0.7;
}

.mlc-attachment-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    opacity: 0.6;
}

/* Typing indicator */
.mlc-typing {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--mlc-text-muted);
    font-size: 13px;
}

.mlc-typing-dots {
    display: flex;
    gap: 3px;
}

.mlc-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--mlc-text-muted);
    border-radius: 50%;
    animation: mlc-typing-bounce 1.4s infinite ease-in-out;
}

.mlc-typing-dots span:nth-child(1) { animation-delay: 0s; }
.mlc-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.mlc-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes mlc-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* Email prompt */
.mlc-email-prompt {
    padding: 12px 16px;
    background: var(--mlc-bg-secondary);
    border-top: 1px solid var(--mlc-border);
}

.mlc-visitor-email {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--mlc-border);
    border-radius: var(--mlc-radius-sm);
    font-size: 14px;
    font-family: inherit;
}

.mlc-visitor-email:focus {
    outline: none;
    border-color: var(--mlc-primary);
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

/* Honeypot (hidden) */
.mlc-honeypot {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    pointer-events: none !important;
}

/* Composer */
.mlc-composer {
    padding: 12px 16px;
    border-top: 1px solid var(--mlc-border);
    background: var(--mlc-bg);
}

.mlc-composer-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.mlc-composer-attachments:empty {
    display: none;
    margin-bottom: 0;
}

.mlc-pending-attachment {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--mlc-bg-secondary);
    border-radius: var(--mlc-radius-sm);
    font-size: 12px;
}

.mlc-pending-attachment button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.6;
}

.mlc-pending-attachment button:hover {
    opacity: 1;
}

.mlc-composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.mlc-attach-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--mlc-text-muted);
    transition: color 0.2s;
    flex-shrink: 0;
}

.mlc-attach-btn:hover {
    color: var(--mlc-primary);
}

.mlc-attach-btn svg {
    width: 20px;
    height: 20px;
}

.mlc-file-input {
    display: none;
}

.mlc-message-input {
    flex: 1;
    min-height: 36px;
    max-height: 120px;
    padding: 8px 12px;
    border: 1px solid var(--mlc-border);
    border-radius: var(--mlc-radius-sm);
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

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

.mlc-send-btn {
    width: 36px;
    height: 36px;
    background: var(--mlc-primary);
    border: none;
    border-radius: var(--mlc-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.mlc-send-btn:hover {
    background: var(--mlc-primary-hover);
}

.mlc-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mlc-send-btn svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .mlc-widget {
        bottom: 0;
        right: 0;
        left: 0;
    }

    .mlc-launcher {
        position: fixed;
        bottom: 16px;
        right: 16px;
    }

    .mlc-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .mlc-launcher.mlc-hidden {
        display: none;
    }
}

/* Scrollbar styling */
.mlc-messages::-webkit-scrollbar {
    width: 6px;
}

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

.mlc-messages::-webkit-scrollbar-thumb {
    background: var(--mlc-border);
    border-radius: 3px;
}

.mlc-messages::-webkit-scrollbar-thumb:hover {
    background: var(--mlc-text-muted);
}

/* Loading state */
.mlc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--mlc-text-muted);
}

/* Error state */
.mlc-error {
    padding: 12px 16px;
    background: #fff3cd;
    color: #856404;
    text-align: center;
    font-size: 13px;
}

/* Image preview in messages */
.mlc-image-preview {
    max-width: 100%;
    border-radius: var(--mlc-radius-sm);
    cursor: pointer;
    transition: opacity 0.2s;
}

.mlc-image-preview:hover {
    opacity: 0.9;
}

/* Focus trap visual indicator */
.mlc-panel:focus-within .mlc-header {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3);
}
