/* WP Live Chat Pro - Public Widget CSS */

/* Button */
#wplcp-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(102,126,234,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    z-index: 2147483646;
    transition: transform 0.25s, box-shadow 0.25s;
    animation: wplcp-pulse 3s infinite;
}

@keyframes wplcp-pulse {
    0%,100% { box-shadow: 0 8px 32px rgba(102,126,234,0.45); }
    50%      { box-shadow: 0 8px 40px rgba(102,126,234,0.7); }
}

#wplcp-btn:hover {
    transform: scale(1.08);
    animation: none;
    box-shadow: 0 12px 40px rgba(102,126,234,0.6);
}

#wplcp-btn:active {
    transform: scale(0.95);
}

/* Chat Box */
#wplcp-box {
    position: fixed;
    bottom: 96px;
    right: 20px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 110px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.22), 0 0 0 1px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2147483646;
    animation: wplcp-slidein 0.3s cubic-bezier(0.4,0,0.2,1);
}

@keyframes wplcp-slidein {
    from { opacity:0; transform:scale(0.85) translateY(24px); }
    to   { opacity:1; transform:scale(1) translateY(0); }
}

/* Header */
#wplcp-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* Avatar */
#wplcp-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

#wplcp-avatar-inner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255,255,255,0.3);
    overflow: hidden;
}

#wplcp-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 13px;
    height: 13px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid #fff;
}

#wplcp-online-dot.offline {
    background: #f59e0b;
}

/* Header buttons */
.wplcp-hbtn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
}

.wplcp-hbtn:hover {
    background: rgba(255,255,255,0.28);
}

/* Prechat */
#wplcp-prechat {
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* FIX: allows proper flex shrinking */
}

/* Messages area - FIXED for proper scrolling */
#wplcp-msgs {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background: #f0f4f8;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0; /* CRITICAL FIX: allows flex child to shrink and scroll */
    scroll-behavior: smooth;
}

/* FIXED: Remove justify-content: flex-end — it breaks scrolling to top */
#wplcp-msgs-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: flex-start; /* FIX: was flex-end, which hides overflow at top */
    flex: 1;
}

/* ── Message Row ── */
.wplcp-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 12px;
    animation: wplcp-msgin 0.25s ease-out;
    width: 100%;
}

@keyframes wplcp-msgin {
    from { opacity:0; transform:translateY(8px); }
    to   { opacity:1; transform:translateY(0); }
}

/* Agent: avatar LEFT, bubble LEFT */
.wplcp-msg-row.from-agent {
    flex-direction: row;
    justify-content: flex-start;
}

/* User: avatar RIGHT, bubble RIGHT */
.wplcp-msg-row.from-user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

/* System: centered */
.wplcp-msg-row.from-system {
    justify-content: center;
}

/* ── Avatars ── */
.wplcp-msg-avt {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.wplcp-msg-avt img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Agent avatar: purple gradient */
.wplcp-msg-avt--agent {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}

/* User avatar: pink gradient */
.wplcp-msg-avt--user {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: #fff;
}

/* ── Message Body ── */
.wplcp-msg-body {
    max-width: 68%;
    display: flex;
    flex-direction: column;
}

/* Agent body: align items to left */
.wplcp-msg-row.from-agent .wplcp-msg-body {
    align-items: flex-start;
}

/* User body: align items to right */
.wplcp-msg-row.from-user .wplcp-msg-body {
    align-items: flex-end;
}

/* ── Name label ── */
.wplcp-msg-name {
    font-size: 11px;
    font-weight: 600;
    color: #8c8f94;
    margin-bottom: 3px;
    padding: 0 4px;
}

/* ── Bubbles ── */
.wplcp-msg-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

/* Agent bubble: white, left-bottom corner flat */
.wplcp-msg-row.from-agent .wplcp-msg-bubble {
    background: #ffffff;
    color: #1d2327;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* User bubble: purple gradient, right-bottom corner flat */
.wplcp-msg-row.from-user .wplcp-msg-bubble {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(102,126,234,0.35);
}

/* System bubble */
.wplcp-msg-row.from-system .wplcp-msg-bubble {
    background: #fef3c7;
    color: #92400e;
    font-style: italic;
    font-size: 12px;
    text-align: center;
    border-radius: 20px;
    padding: 6px 14px;
    box-shadow: none;
}

/* ── Timestamp ── */
.wplcp-msg-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

.wplcp-msg-row.from-user .wplcp-msg-time {
    text-align: right;
}

/* Input area */
#wplcp-input-area {
    display: none;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #f0f0f1;
    flex-shrink: 0;
}

/* Input */
#wplcp-send {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

#wplcp-send:hover {
    transform: scale(1.05);
}

#wplcp-end-btn:hover {
    background: #fef2f2;
}

#wplcp-start {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

#wplcp-start:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102,126,234,0.4);
}

/* Feedback stars */
.wplcp-star:hover,
.wplcp-star.sel {
    color: #f59e0b !important;
    transform: scale(1.15);
}

/* Emoji */
.wplcp-em.sel {
    border-color: #667eea !important;
    background: rgba(102,126,234,0.1) !important;
    transform: scale(1.1);
}

/* Feedback submit */
#wplcp-fb-submit {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

/* Feedback screen — must fill remaining box height and scroll internally */
#wplcp-feedback {
    flex: 1;
    display: none;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    padding: 24px 20px 20px;
    background: #fff;
    box-sizing: border-box;
    min-height: 0;
}

#wplcp-feedback h3 {
    font-size: 17px;
    font-weight: 700;
    color: #1d2327;
    margin: 0 0 16px;
    text-align: center;
}

#wplcp-stars {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

#wplcp-stars .wplcp-star {
    font-size: 32px;
    cursor: pointer;
    color: #d1d5db;
    transition: all 0.2s;
    user-select: none;
    line-height: 1;
}

.wplcp-em-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-shrink: 0;
    flex-wrap: nowrap;
    width: 100%;
}

.wplcp-em {
    font-size: 26px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

#wplcp-fb-text {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    margin-bottom: 12px;
    box-sizing: border-box;
    flex-shrink: 0;
    min-height: 64px;
}

.wplcp-fb-btns {
    display: flex;
    gap: 10px;
    width: 100%;
    flex-shrink: 0;
}

#wplcp-skip {
    flex: 1;
    padding: 11px;
    background: #f3f4f6;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    color: #6b7280;
    cursor: pointer;
    font-weight: 600;
}

#wplcp-fb-submit {
    flex: 2;
    padding: 11px;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    background: linear-gradient(135deg, #667eea, #764ba2);
}

/* Thank you screen */
#wplcp-ty {
    flex: 1;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    min-height: 0;
}

/* Scrollbars */
#wplcp-msgs::-webkit-scrollbar,
#wplcp-prechat::-webkit-scrollbar,
#wplcp-feedback::-webkit-scrollbar {
    width: 4px;
}
#wplcp-msgs::-webkit-scrollbar-thumb,
#wplcp-prechat::-webkit-scrollbar-thumb,
#wplcp-feedback::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

/* Typing indicator */
.wplcp-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f9fafb;
    border-radius: 12px;
    margin: 8px 0;
    min-height: 40px;
}

.wplcp-typing-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wplcp-typing-dots {
    display: flex;
    gap: 4px;
}

.wplcp-typing-dots span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: wplcp-typing-bounce 1.4s infinite ease-in-out;
}

.wplcp-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.wplcp-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.wplcp-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes wplcp-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mobile */
@media (max-width: 480px) {
    #wplcp-box {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    #wplcp-btn {
        width: 56px;
        height: 56px;
    }
}

/* Attachment Button */
.wplcp-attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.wplcp-attach-btn:hover {
    background: #e5e7eb;
    transform: scale(1.1);
}

.wplcp-attach-btn svg {
    width: 18px;
    height: 18px;
    color: #6b7280;
}

/* Attachment Preview */
.wplcp-attachment-preview {
    position: relative;
    display: inline-block;
    margin-top: 8px;
    padding: 8px;
    background: #f3f4f6;
    border-radius: 8px;
    max-width: 150px;
}

.wplcp-attachment-preview img {
    max-width: 130px;
    max-height: 100px;
    border-radius: 6px;
    object-fit: cover;
}

.wplcp-remove-attachment {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wplcp-remove-attachment:hover {
    background: #dc2626;
}