/**
 * Purisoft Chatbot Styles
 * Copyright (c) 2025 Purisoft Water Solutions. All rights reserved.
 * This software is proprietary and confidential. Unauthorized copying, modification,
 * distribution, or use of this software, via any medium, is strictly prohibited.
 * 
 * Include this CSS file in your homepage
 */

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

* {
    font-family: 'Poppins', sans-serif;
}

/* ── Pill bubble (replaces old .purisoft-chat-bubble) ── */
.purisoft-chat-pill {
    position: fixed;
    bottom: 60px;
    right: 10px;
    display: flex;
    align-items: center;
    overflow: visible;
    background: linear-gradient(135deg, #2589d0, #0d4a7a);
    border-radius: 50px;
    width: 62px;
    height: 62px;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 6px 20px rgba(13, 74, 122, 0.45);
    transition: width 0.5s cubic-bezier(0.34, 1.4, 0.64, 1),
                box-shadow 0.2s ease;
    /* Clip the text expansion but NOT the ripple rings */
    -webkit-mask-image: none;
}

.purisoft-chat-pill:hover {
    box-shadow: 0 8px 28px rgba(13, 74, 122, 0.55);
}

/* Expanded state — pill grows to the left revealing text */
.purisoft-chat-pill.ps-expanded {
    width: 158px;
}

/* "Try me →" text — hidden until expanded */
.purisoft-pill-text {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    padding-left: 0;
    letter-spacing: 0.01em;
    transition: max-width 0.5s cubic-bezier(0.34, 1.4, 0.64, 1),
                opacity 0.2s ease 0.25s,
                padding-left 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
    pointer-events: none;
    flex-shrink: 0;
    font-family: 'Poppins', sans-serif;
}

.purisoft-chat-pill.ps-expanded .purisoft-pill-text {
    max-width: 120px;
    opacity: 1;
    padding-left: 18px;
    transition: max-width 0.5s cubic-bezier(0.34, 1.4, 0.64, 1),
                opacity 0.3s ease 0.45s,
                padding-left 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* Icon circle on the right */
.purisoft-pill-icon {
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: auto;
    position: relative;  /* ← required for ripple rings to anchor here */
}

.purisoft-pill-icon svg {
    width: 26px;
    height: 26px;
    fill: #fff;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.2));
}

/* ── Ripple rings ── */
.purisoft-ripple-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2.5px solid rgba(13, 74, 122, 0.6);
    opacity: 0;
    pointer-events: none;
}

@keyframes purisoftRipple {
    0%   { transform: scale(1);   opacity: 0.75; }
    100% { transform: scale(2.5); opacity: 0;    }
}

.purisoft-chat-pill.ps-rippling .purisoft-ripple-ring:nth-child(1) {
    animation: purisoftRipple 1.3s ease-out 0s    forwards;
}
.purisoft-chat-pill.ps-rippling .purisoft-ripple-ring:nth-child(2) {
    animation: purisoftRipple 1.3s ease-out 0.25s forwards;
}
.purisoft-chat-pill.ps-rippling .purisoft-ripple-ring:nth-child(3) {
    animation: purisoftRipple 1.3s ease-out 0.5s  forwards;
}

/* ── Idle glow pulse ── */
@keyframes purisoftIdleGlow {
    0%, 100% { box-shadow: 0 6px 20px rgba(13, 74, 122, 0.45); }
    50%       { box-shadow: 0 6px 30px rgba(37, 137, 208, 0.70); }
}

.purisoft-chat-pill.ps-idle {
    animation: purisoftIdleGlow 2.5s ease-in-out infinite;
}

.purisoft-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
}

.purisoft-chat-window.open {
    display: flex;
}

.purisoft-chat-header {
    background: #0088CC;
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.purisoft-chat-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: white;
}

.purisoft-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
}

.purisoft-message-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 12px;
}

.purisoft-reset-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.purisoft-reset-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.purisoft-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.purisoft-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.purisoft-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.purisoft-message {
    display: flex;
    gap: 8px;
    animation: purisoftFadeIn 0.3s;
}

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

.purisoft-message.user {
    flex-direction: row-reverse;
}

.purisoft-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.purisoft-message.user .purisoft-message-avatar {
    background: #0088CC;
    color: white;
}

.purisoft-message.assistant .purisoft-message-avatar {
    background: #e5e5e5;
    color: #333;
}

.purisoft-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 16px;
}

.purisoft-message-content strong {
    font-weight: 600;
}

.purisoft-message-content em {
    font-style: italic;
}

.purisoft-message-content a {
    color: #0088CC;
    text-decoration: underline;
}

.purisoft-message-content a:hover {
    color: #0077b3;
}

.purisoft-message.user .purisoft-message-content {
    background: #0088CC;
    color: white;
    border-bottom-right-radius: 4px;
}

.purisoft-message.assistant .purisoft-message-content {
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.purisoft-chat-input-container {
    padding: 16px;
    border-top: 1px solid #e5e5e5;
    background: white;
}

.purisoft-char-counter {
    font-size: 11px;
    color: #999;
    text-align: right;
    margin-top: 4px;
    padding-right: 4px;
}

.purisoft-char-counter.warning {
    color: #ff6b6b;
}

.purisoft-chat-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.purisoft-chat-input {
    flex: 1;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 44px;
}

.purisoft-chat-input:focus {
    outline: none;
    border-color: #0088CC;
}

.purisoft-send-btn {
    background: #0088CC;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background 0.2s;
    min-height: 44px;
    width: 100%;
    align-self: flex-start;
}

.purisoft-send-btn:hover:not(:disabled) {
    background: #0077b3;
}

.purisoft-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.purisoft-loading {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.purisoft-loading-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: purisoftBounce 1.4s infinite;
}

.purisoft-loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.purisoft-loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes purisoftBounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-8px);
    }
}

/* Desktop: pill position (already set above, this keeps parity) */
@media (min-width: 481px) {
    .purisoft-chat-pill {
        bottom: 60px;
        right: 10px;
    }
}

/* Mobile: hide pill when chat window is open */
@media (max-width: 480px) {
    .purisoft-chat-pill.hidden {
        display: none;
    }
}

@media (max-width: 480px) {
    .purisoft-chat-window {
        right: 0;
        bottom: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .purisoft-chat-header {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 16px;
    }

    .purisoft-chat-bubble {
        bottom: 16px;
        right: 16px;
    }

    /* Prevent iOS zoom on input focus - font-size must be at least 16px */
    .purisoft-chat-input {
        font-size: 16px;
    }
}

