/**
 * Frontend Widget Stylesheet
 * Floating Lead Chat Widget
 */

:root {
    --flc-primary: #4f46e5;
    --flc-primary-hover: #4338ca;
    --flc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --flc-radius-lg: 18px;
    --flc-radius-md: 12px;
    --flc-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --flc-shadow-trigger: 0 4px 14px rgba(0, 0, 0, 0.15);
}

/* Container */
.flc-widget-container {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: var(--flc-font);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    transition: all 0.3s ease;
}

.flc-widget-container.flc-pos-right {
    right: 24px;
    align-items: flex-end;
}

.flc-widget-container.flc-pos-left {
    left: 24px;
    align-items: flex-start;
}

/* Chat Window */
.flc-widget-window {
    width: 340px;
    max-width: calc(100vw - 48px);
    background: #ffffff;
    border-radius: var(--flc-radius-lg);
    box-shadow: var(--flc-shadow);
    overflow: hidden;
    margin-bottom: 16px;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.flc-pos-left .flc-widget-window {
    transform-origin: bottom left;
}

.flc-widget-container.flc-is-open .flc-widget-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.flc-widget-header {
    background: var(--flc-primary);
    color: #ffffff;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.flc-widget-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.flc-widget-avatar svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}

.flc-widget-header-text {
    flex: 1;
}

.flc-widget-header-name {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
}

.flc-widget-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.flc-widget-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #22c55e;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4);
}

.flc-widget-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.flc-widget-close-btn:hover {
    color: #ffffff;
}

.flc-widget-close-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Body / Chat Area */
.flc-widget-body {
    padding: 20px;
    background-color: #f8fafc;
    max-height: 220px;
    overflow-y: auto;
}

.flc-widget-msg-bubble {
    background: #ffffff;
    border-radius: 0 14px 14px 14px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.45;
    color: #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    max-width: 85%;
    word-break: break-word;
    border: 1px solid rgba(0,0,0,0.02);
}

.flc-pos-left .flc-widget-msg-bubble {
    border-radius: 14px 14px 14px 0;
}

/* Footer / Form */
.flc-widget-footer {
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    padding: 14px;
}

.flc-widget-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 6px 6px 6px 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.flc-widget-form:focus-within {
    border-color: var(--flc-primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.flc-widget-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 13px;
    outline: none;
    color: #0f172a;
    resize: none;
    max-height: 80px;
    font-family: inherit;
    line-height: 1.3;
}

.flc-widget-input::placeholder {
    color: #94a3b8;
}

.flc-widget-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--flc-primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.flc-widget-send-btn:hover {
    background-color: var(--flc-primary-hover);
    transform: scale(1.05);
}

.flc-widget-send-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    margin-left: 2px;
}

/* Success View */
.flc-widget-success-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.flc-widget-success-view.flc-is-visible {
    opacity: 1;
    pointer-events: auto;
}

.flc-widget-success-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #f0fdf4;
    color: #22c55e;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.flc-widget-success-icon svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.flc-widget-success-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #0f172a;
}

.flc-widget-success-text {
    font-size: 13px;
    color: #64748b;
    margin: 0;
}

/* Floating Trigger Button */
.flc-widget-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--flc-primary);
    color: #ffffff;
    box-shadow: var(--flc-shadow-trigger);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: none;
    transition: background-color 0.2s, transform 0.2s;
    outline: none;
}

.flc-widget-trigger:hover {
    background-color: var(--flc-primary-hover);
    transform: scale(1.05);
}

.flc-widget-trigger svg {
    position: absolute;
    width: 28px;
    height: 28px;
    fill: currentColor;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Toggle Trigger Icons (chat / close) */
.flc-widget-trigger .flc-icon-chat {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.flc-widget-trigger .flc-icon-close {
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

.flc-widget-container.flc-is-open .flc-widget-trigger .flc-icon-chat {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

.flc-widget-container.flc-is-open .flc-widget-trigger .flc-icon-close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Pulse Animation when closed */
.flc-widget-trigger::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 0 var(--flc-primary);
    opacity: 0.6;
    z-index: -1;
    animation: flc-pulse 2s infinite;
}

.flc-widget-container.flc-is-open .flc-widget-trigger::after {
    animation: none;
}

@keyframes flc-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(79, 70, 229, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .flc-widget-container {
        bottom: 16px;
    }
    .flc-widget-container.flc-pos-right {
        right: 16px;
    }
    .flc-widget-container.flc-pos-left {
        left: 16px;
    }
    .flc-widget-window {
        width: calc(100vw - 32px);
        max-height: calc(100vh - 120px);
        margin-bottom: 12px;
    }
    .flc-widget-body {
        max-height: 180px;
    }
}
