/* =========================================================
   Live Chat Support Pro — Frontend Widget Styles
   assets/css/style.css
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --lcsp-primary:        #6C63FF;
    --lcsp-primary-dark:   #5A52D5;
    --lcsp-white:          #ffffff;
    --lcsp-bg:             #f7f8fc;
    --lcsp-text:           #1e293b;
    --lcsp-muted:          #64748b;
    --lcsp-border:         rgba(226, 232, 240, 0.8);
    --lcsp-shadow-soft:    0 4px 20px rgba(0,0,0,0.05);
    --lcsp-shadow-heavy:   0 16px 48px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.06);
    --lcsp-radius:         20px;
    --lcsp-font:           'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --lcsp-widget-w:       360px;
    --lcsp-widget-h:       560px;
    --lcsp-z:              999999;
}

/* ── Widget Container ──────────────────────────────────── */
#lcsp-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--lcsp-z);
    font-family: var(--lcsp-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--lcsp-text);
}

/* ── Toggle Button ─────────────────────────────────────── */
#lcsp-toggle-btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--lcsp-primary), var(--lcsp-primary-dark));
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(108,99,255,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    outline: none;
    margin-left: auto;
}

#lcsp-toggle-btn:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 12px 28px rgba(108,99,255,0.45);
}

#lcsp-toggle-btn:active {
    transform: scale(0.95);
}

#lcsp-toggle-btn svg {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#lcsp-unread-dot {
    display: none;
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid var(--lcsp-white);
    animation: lcsp-pulse 1.5s infinite cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.5);
}

@keyframes lcsp-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(255, 71, 87, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}

/* ── Chat Window ───────────────────────────────────────── */
#lcsp-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: var(--lcsp-widget-w);
    height: var(--lcsp-widget-h);
    max-height: calc(100vh - 120px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--lcsp-radius);
    box-shadow: var(--lcsp-shadow-heavy);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: lcsp-widget-open 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes lcsp-widget-open {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Header ────────────────────────────────────────────── */
.lcsp-header {
    background: linear-gradient(135deg, var(--lcsp-primary), var(--lcsp-primary-dark));
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.lcsp-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lcsp-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.25);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.lcsp-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.lcsp-header-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.lcsp-title {
    color: var(--lcsp-white);
    font-weight: 600;
    font-size: 16px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.lcsp-status-text {
    color: rgba(255,255,255,0.9);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.lcsp-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5);
    animation: lcsp-online-pulse 2s infinite;
}

@keyframes lcsp-online-pulse {
    0%  { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); }
    70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
    100%{ box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.lcsp-close-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.lcsp-close-btn:hover { 
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

/* ── Pre-chat Form ─────────────────────────────────────── */
#lcsp-prechat-form {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.lcsp-prechat-inner {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lcsp-welcome {
    color: var(--lcsp-text);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px;
    line-height: 1.5;
}

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

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

.lcsp-form-group label span {
    color: #ef4444;
}

.lcsp-form-group input {
    border: 1px solid var(--lcsp-border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: var(--lcsp-font);
    color: var(--lcsp-text);
    outline: none;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.lcsp-form-group input:hover {
    border-color: rgba(108,99,255,0.4);
}

.lcsp-form-group input:focus {
    border-color: var(--lcsp-primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.15), inset 0 2px 4px rgba(0,0,0,0.02);
    background: #fff;
}

#lcsp-start-chat-btn {
    background: linear-gradient(135deg, var(--lcsp-primary), var(--lcsp-primary-dark));
    color: var(--lcsp-white);
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--lcsp-font);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 14px rgba(108,99,255,0.3);
    margin-top: 8px;
}

#lcsp-start-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108,99,255,0.4);
}

#lcsp-start-chat-btn:active {
    transform: translateY(0);
}

#lcsp-start-chat-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.lcsp-error {
    color: #ef4444;
    font-size: 13px;
    font-weight: 500;
    margin: 0;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.08);
    border-radius: 10px;
    border-left: 4px solid #ef4444;
}

/* ── Chat Area ─────────────────────────────────────────── */
#lcsp-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(248, 250, 252, 0.5); /* slight tint for chat background */
}

#lcsp-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#lcsp-messages-container::-webkit-scrollbar { width: 6px; }
#lcsp-messages-container::-webkit-scrollbar-track { background: transparent; }
#lcsp-messages-container::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }
#lcsp-messages-container::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* ── Message Bubbles ───────────────────────────────────── */
.lcsp-msg-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 20px;
    animation: lcsp-msg-slide-up 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes lcsp-msg-slide-up {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.lcsp-msg-wrapper.lcsp-bubble-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.lcsp-msg-wrapper.lcsp-bubble-admin {
    align-self: flex-start;
    flex-direction: row;
}

.lcsp-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.lcsp-agent-letter, .lcsp-user-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.lcsp-agent-letter {
    background: linear-gradient(135deg, var(--lcsp-primary), #8B85FF);
}

.lcsp-user-letter {
    background: #cbd5e1;
    color: #334155;
}

.lcsp-msg-content {
    display: flex;
    flex-direction: column;
    max-width: calc(100% - 38px);
}

.lcsp-bubble-admin .lcsp-msg-content { align-items: flex-start; }
.lcsp-bubble-user .lcsp-msg-content { align-items: flex-end; }

.lcsp-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    position: relative;
    max-width: 100%;
}

.lcsp-bubble img.lcsp-attachment-img {
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 4px;
    display: block;
}

.lcsp-bubble a.lcsp-attachment-link {
    display: inline-flex;
    align-items: center;
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}
.lcsp-bubble-admin .lcsp-bubble {
    background: #f1f5f9;
    color: var(--lcsp-text);
    border-bottom-left-radius: 4px;
}

.lcsp-bubble-user .lcsp-bubble {
    background: linear-gradient(135deg, var(--lcsp-primary), #8B85FF);
    color: white;
    border-bottom-right-radius: 4px;
}

.lcsp-bubble-time {
    font-size: 11px;
    font-weight: 500;
    color: var(--lcsp-muted);
    margin-top: 6px;
    padding: 0 4px;
    opacity: 0.8;
}

/* ── Typing Indicator ──────────────────────────────────── */
.lcsp-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px !important;
}

.lcsp-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--lcsp-primary);
    animation: lcsp-typing-bounce 1.4s infinite ease-in-out both;
    display: inline-block;
    opacity: 0.6;
}

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

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

/* ── System Message ────────────────────────────────────── */
.lcsp-system-msg {
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--lcsp-muted);
    padding: 8px 16px;
    background: rgba(0,0,0,0.04);
    border-radius: 20px;
    margin: 8px auto;
    max-width: 85%;
    backdrop-filter: blur(4px);
}

/* ── Input Area ────────────────────────────────────────── */
.lcsp-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 15px;
    border-top: 1px solid rgba(0,0,0,0.06);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    position: relative;
}

#lcsp-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: #64748b;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    margin-right: 8px;
}
#lcsp-upload-btn:hover {
    background: #f1f5f9;
    color: var(--lcsp-primary);
}

#lcsp-message-input {
    flex: 1;
    border: 1px solid var(--lcsp-border);
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: var(--lcsp-font);
    color: var(--lcsp-text);
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 120px;
    overflow-y: auto;
    transition: all 0.3s ease;
    line-height: 1.5;
    background: var(--lcsp-white);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

#lcsp-message-input:focus {
    border-color: rgba(108,99,255,0.4);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.1), inset 0 2px 4px rgba(0,0,0,0.02);
}

#lcsp-message-input::-webkit-scrollbar { width: 4px; }
#lcsp-message-input::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }

#lcsp-message-input:disabled {
    background: #f1f5f9;
    color: var(--lcsp-muted);
    cursor: not-allowed;
}

#lcsp-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--lcsp-primary), var(--lcsp-primary-dark));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(108,99,255,0.25);
}

#lcsp-send-btn svg {
    margin-left: -2px;
    margin-top: 2px;
}

#lcsp-send-btn:hover  { 
    transform: scale(1.08) translateY(-1px); 
    box-shadow: 0 6px 16px rgba(108,99,255,0.35);
}
#lcsp-send-btn:active { transform: scale(0.95); }
#lcsp-send-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; filter: grayscale(50%); }

.lcsp-footer-note {
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--lcsp-muted);
    padding: 6px 0 10px;
    background: rgba(255, 255, 255, 0.9);
}

.lcsp-footer-note a {
    color: var(--lcsp-primary);
    text-decoration: none;
    font-weight: 600;
}

/* ── Bot Mode UI ───────────────────────────────────────── */
.lcsp-bot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 16px 12px;
    animation: lcsp-msg-slide-up 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.lcsp-bot-pill {
    background: rgba(108,99,255,0.08); /* slightly transparent primary */
    color: var(--lcsp-primary);
    border: 1px solid rgba(108,99,255,0.2);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--lcsp-font);
    transition: all 0.2s ease;
}

.lcsp-bot-pill.lcsp-bot-pill-agent {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.2);
}

.lcsp-bot-pill:hover {
    background: var(--lcsp-primary);
    color: var(--lcsp-white);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(108,99,255,0.2);
}

.lcsp-bot-pill.lcsp-bot-pill-agent:hover {
    background: #10b981;
    color: var(--lcsp-white);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}

.lcsp-bot-select-wrap {
    width: 100%;
}

.lcsp-bot-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--lcsp-border);
    font-size: 13px;
    background: rgba(255,255,255,0.9);
    outline: none;
    font-family: var(--lcsp-font);
    font-weight: 500;
    color: var(--lcsp-text);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: border-color 0.2s;
}

.lcsp-bot-select:hover {
    border-color: var(--lcsp-primary);
}

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 480px) {
    #lcsp-widget {
        bottom: 0;
        right: 0;
        left: 0;
    }

    #lcsp-toggle-btn {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    #lcsp-chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border-top-left-radius: 24px;
        border-top-right-radius: 24px;
        border: none;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
        animation: lcsp-mobile-slide-up 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    }
    
    @keyframes lcsp-mobile-slide-up {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}
