/**
 * Live Support Chat — Frontend Widget Stylesheet
 */

/* Main Containers & Variables */
.lsc-widget-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
    box-sizing: border-box;
    z-index: 999999;
}

.lsc-widget-container *,
.lsc-widget-container *::before,
.lsc-widget-container *::after {
    box-sizing: border-box;
}

.lsc-hidden {
    display: none !important;
}

/* Floating Launcher Positions */
.lsc-pos-right {
    position: fixed;
    bottom: 24px;
    right: 24px;
}

.lsc-pos-left {
    position: fixed;
    bottom: 24px;
    left: 24px;
}

.lsc-pos-inline {
    position: relative;
    max-width: 380px;
    width: 100%;
}

.lsc-launcher-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--lsc-button-color, #10b981);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
    position: relative;
}

/* Launcher Icons styling */
.lsc-launcher-btn svg.lsc-icon-chat {
    width: 28px !important;
    height: 28px !important;
    transition: transform 0.2s ease;
}

/* Launcher icon status managed dynamically by Javascript */

.lsc-launcher-btn .lsc-icon-close {
    text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3) !important;
    z-index: 99999 !important;
    transition: transform 0.2s ease;
}

/* Ensure custom uploaded image logo fills the launcher button completely */
.lsc-launcher-btn img.lsc-icon-chat {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

.lsc-launcher-btn:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

.lsc-launcher-btn:active {
    transform: scale(0.95);
}

/* Launcher Pulse Animation */
@keyframes lscPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.lsc-pos-right .lsc-launcher-btn,
.lsc-pos-left .lsc-launcher-btn {
    animation: lscPulse 2.5s infinite;
}

/* Unread Badge */
.lsc-unread-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Chat Popup Window Layout */
.lsc-window {
    width: 370px;
    height: 520px;
    background-color: #ffffff;
    border-radius: var(--lsc-radius, 12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* When floating, offset from bottom launcher */
.lsc-pos-right .lsc-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    transform-origin: bottom right;
}

.lsc-pos-left .lsc-window {
    position: fixed;
    bottom: 96px;
    left: 24px;
    transform-origin: bottom left;
}

/* Header UI details */
.lsc-window-header {
    background: linear-gradient(135deg, var(--lsc-primary, #10b981) 0%, rgba(var(--lsc-primary), 0.85) 100%);
    background-color: var(--lsc-primary, #10b981);
    color: var(--lsc-title-color, #ffffff);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.lsc-header-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.lsc-avatar-initials {
    font-weight: bold;
    font-size: 16px;
    color: #ffffff;
}

.lsc-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
}

.status-online {
    background-color: #10b981;
}

.status-offline {
    background-color: #9ca3af;
}

.lsc-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--lsc-title-color, #ffffff) !important;
}

.lsc-status-text {
    font-size: 11px;
    opacity: 0.9;
}

.lsc-close-button {
    background: none;
    border: none;
    color: var(--lsc-title-color, #ffffff) !important;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 4px;
    display: flex;
}

.lsc-close-button:hover {
    opacity: 1;
}

/* Window Content Viewport */
.lsc-window-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    background-color: #f8fafc;
}

.lsc-panel {
    display: none;
    height: 100%;
    flex-direction: column;
    overflow-y: auto;
}

.lsc-panel.active {
    display: flex;
}

/* Visitor Form Panel Styling */
#lsc-visitor-form-panel {
    padding: 24px;
    justify-content: center;
}

.lsc-form-welcome {
    text-align: center;
    margin-bottom: 24px;
}

.lsc-form-welcome p {
    margin: 0;
    color: #4b5563;
    font-size: 14px;
}

.lsc-chat-form .lsc-form-group {
    margin-bottom: 18px;
}

.lsc-chat-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 12px;
    color: #4b5563;
}

.lsc-chat-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    transition: border-color 0.2s;
}

.lsc-chat-form input:focus {
    outline: none;
    border-color: var(--lsc-primary, #10b981);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.lsc-btn-primary {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background-color: var(--lsc-primary, #10b981);
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 8px;
}

.lsc-btn-primary:hover {
    background-color: #059669;
}

/* Scrollable message timeline */
.lsc-timeline {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Hide scrollbar defaults */
.lsc-timeline::-webkit-scrollbar {
    width: 5px;
}
.lsc-timeline::-webkit-scrollbar-track {
    background: transparent;
}
.lsc-timeline::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* Bubble Styling */
.lsc-message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Visitor message (right alignment) */
.msg-visitor {
    align-self: flex-end;
    background-color: var(--lsc-primary, #10b981);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

/* Admin message (left alignment) */
.msg-admin {
    align-self: flex-start;
    background-color: #ffffff;
    color: #1f2937;
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(0,0,0,0.03);
}

.lsc-message-time {
    display: block;
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
}

.msg-visitor .lsc-message-time {
    color: rgba(255, 255, 255, 0.9);
}

.msg-admin .lsc-message-time {
    color: #6b7280;
}

/* Typing indicator */
.lsc-typing-box {
    align-self: flex-start;
    background-color: #e5e7eb;
    padding: 10px 14px;
    border-radius: 14px;
    border-bottom-left-radius: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 20px;
}

.lsc-typing-dot {
    width: 6px;
    height: 6px;
    background-color: #4b5563;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.lsc-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.lsc-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Footer composer details */
.lsc-window-footer {
    padding: 12px 16px;
    background-color: #ffffff;
    border-top: 1px solid #f1f5f9;
}

.lsc-compose-box {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background-color: #f1f5f9;
    border-radius: 20px;
    padding: 6px 12px;
}

.lsc-compose-box textarea {
    flex: 1;
    background: none;
    border: none;
    resize: none;
    max-height: 80px;
    font-size: 13px;
    outline: none;
    padding: 4px 0;
    line-height: 1.4;
    color: #1f2937;
}

.lsc-send-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--lsc-primary, #10b981);
    display: flex;
    padding: 4px;
    transition: transform 0.2s, opacity 0.2s;
}

.lsc-send-icon-btn:hover {
    transform: scale(1.1);
}

/* Mobile responsive settings */
@media (max-width: 480px) {
    .lsc-pos-right, .lsc-pos-left {
        bottom: 12px;
        right: 12px;
        left: auto;
    }
    
    .lsc-pos-left {
        left: 12px;
        right: auto;
    }

    .lsc-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        max-height: 600px;
    }
}
