/* =============================================
   WP Chat — Frontend Widget Styles
   ============================================= */

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

/* ── Widget wrapper ── */
#wpchat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
}

/* ── Toggle button ── */
.wpchat-toggle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.55);
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s;
    position: relative;
    outline: none;
}

.wpchat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 32px rgba(102, 126, 234, 0.65);
}

.wpchat-toggle:active { transform: scale(0.95); }

.wpchat-icon-chat,
.wpchat-icon-close {
    width: 26px;
    height: 26px;
    color: #fff;
    position: absolute;
    transition: opacity 0.2s, transform 0.25s;
}

.wpchat-icon-close {
    opacity: 0;
    transform: rotate(-90deg);
}

#wpchat-widget.is-open .wpchat-icon-chat {
    opacity: 0;
    transform: rotate(90deg);
}

#wpchat-widget.is-open .wpchat-icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

.wpchat-bubble-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
}

/* ── Chat window ── */
.wpchat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    max-height: 560px;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 20px 60px rgba(0,0,0,0.15),
        0 4px 16px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    transform-origin: bottom right;
    animation: wpchatSlideIn 0.3s cubic-bezier(.34,1.56,.64,1);
}

@keyframes wpchatSlideIn {
    from { opacity: 0; transform: scale(0.85) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Window header ── */
.wpchat-win-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.wpchat-win-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpchat-win-avatar svg {
    width: 22px;
    height: 22px;
    color: #fff;
    fill: #fff;
}

.wpchat-win-title {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.wpchat-win-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: rgba(255,255,255,0.85);
}

.wpchat-online-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: wpchatPulse 2s infinite;
}

@keyframes wpchatPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(74,222,128,0.5); }
    50%      { box-shadow: 0 0 0 5px rgba(74,222,128,0); }
}

.wpchat-win-close {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.wpchat-win-close:hover { background: rgba(255,255,255,0.3); }
.wpchat-win-close svg { width: 16px; height: 16px; fill: #fff; }

/* ── Screens ── */
.wpchat-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Email capture screen ── */
.wpchat-welcome {
    padding: 28px 24px 16px;
    text-align: center;
}

.wpchat-welcome-icon { font-size: 40px; margin-bottom: 10px; }

.wpchat-welcome h3 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
}

.wpchat-welcome p {
    margin: 0;
    font-size: 14px;
    color: #6b6b8f;
    line-height: 1.5;
}

#wpchat-email-form {
    padding: 0 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wpchat-field-wrap { display: flex; flex-direction: column; gap: 6px; }

.wpchat-field-wrap label {
    font-size: 12px;
    font-weight: 600;
    color: #4a4a6a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wpchat-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #e0e0f0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: #1a1a2e;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafafa;
}

.wpchat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.12);
    background: #fff;
}

.wpchat-error-msg {
    color: #ef4444;
    font-size: 12px;
}

.wpchat-start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 13px 20px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102,126,234,0.4);
    transition: box-shadow 0.2s, transform 0.15s;
}

.wpchat-start-btn:hover {
    box-shadow: 0 6px 22px rgba(102,126,234,0.55);
    transform: translateY(-1px);
}

.wpchat-start-btn svg { width: 18px; height: 18px; fill: #fff; }

/* ── Chat screen ── */
#wpchat-chat-screen { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.wpchat-session-info {
    padding: 8px 16px;
    background: #f5f5fb;
    border-bottom: 1px solid #ebebf5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.wpchat-session-email {
    font-size: 12px;
    color: #7070a0;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wpchat-new-chat-link {
    font-size: 12px;
    color: #667eea;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    padding: 0;
    flex-shrink: 0;
}

.wpchat-new-chat-link:hover { text-decoration: underline; }

/* ── Message list ── */
.wpchat-msg-list {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafafa;

    scrollbar-width: thin;
    scrollbar-color: #d4d4e8 transparent;
}

.wpchat-msg-list::-webkit-scrollbar { width: 4px; }
.wpchat-msg-list::-webkit-scrollbar-thumb { background: #d4d4e8; border-radius: 4px; }

/* Message bubble */
.wpchat-bubble-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.wpchat-bubble-row.from-user  { justify-content: flex-end; }
.wpchat-bubble-row.from-admin { justify-content: flex-start; }

.wpchat-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 18px;
    word-break: break-word;
    line-height: 1.45;
    font-size: 14px;
    position: relative;
}

.wpchat-bubble-row.from-user .wpchat-bubble {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.wpchat-bubble-row.from-admin .wpchat-bubble {
    background: #fff;
    border: 1px solid #e8e8f5;
    color: #2d2d4a;
    border-bottom-left-radius: 4px;
}

.wpchat-bubble-time {
    font-size: 10px;
    opacity: 0.65;
    display: block;
    margin-top: 4px;
}

.wpchat-bubble-row.from-user  .wpchat-bubble-time { color: rgba(255,255,255,0.8); text-align: right; }
.wpchat-bubble-row.from-admin .wpchat-bubble-time { color: #aaa; }

/* ── Typing indicator ── */
.wpchat-typing {
    padding: 4px 20px 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wpchat-typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #c0c0d8;
    border-radius: 50%;
    animation: wpchatBounce 1.2s infinite;
}

.wpchat-typing span:nth-child(2) { animation-delay: 0.2s; }
.wpchat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes wpchatBounce {
    0%,60%,100% { transform: translateY(0); }
    30%          { transform: translateY(-6px); }
}

/* ── Closed banner ── */
.wpchat-closed-banner {
    background: #fef3c7;
    color: #92400e;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    padding: 8px 16px;
    flex-shrink: 0;
}

/* ── Input bar ── */
.wpchat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #ebebf5;
    background: #fff;
    flex-shrink: 0;
}

.wpchat-msg-input {
    flex: 1;
    border: 1.5px solid #e0e0f0;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: #1a1a2e;
    line-height: 1.45;
}

.wpchat-msg-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.12);
}

.wpchat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(102,126,234,0.4);
    transition: transform 0.15s, box-shadow 0.15s;
}

.wpchat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 14px rgba(102,126,234,0.55);
}

.wpchat-send-btn:active { transform: scale(0.95); }
.wpchat-send-btn svg { width: 18px; height: 18px; fill: #fff; }

/* ── Responsive ── */
@media (max-width: 420px) {
    #wpchat-widget { bottom: 16px; right: 16px; }
    .wpchat-window { width: calc(100vw - 32px); right: 0; }
}

/* ── Bot bubble ── */
.wpchat-bubble-row.from-bot { justify-content: flex-start; }

.wpchat-bubble-row.from-bot .wpchat-bubble {
    background: #f0f0fa;
    border: 1px solid #e0e0f0;
    color: #2d2d4a;
    border-bottom-left-radius: 4px;
}

.wpchat-bot-label {
    font-size: 10px;
    color: #9090b8;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Styled link inside bot reply */
.wpchat-bubble-row.from-bot .wpchat-bubble a {
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(102,126,234,0.35);
}

.wpchat-bubble-row.from-bot .wpchat-bubble a:hover {
    border-bottom-color: #667eea;
}

/* Bot follow-up nudge */
.wpchat-bot-nudge {
    font-size: 11px;
    color: #a0a0be;
    font-style: italic;
    margin-top: 4px;
    display: block;
}
