/*
 * Styles for Professional CTA Chat plugin.
 * These styles provide the default layout for the floating chat button and popup. Users can override colors via the plugin settings.
 */

/* Wrapper ensures the button and popup share a z-index context */
#pctc-chat-wrapper {
    position: static;
}

/* Floating button */
/*
 * The chat trigger button is styled to resemble a modern live chat bubble.
 * It uses a fixed width/height, rounded corners, subtle shadow and a hover
 * effect.  The label inside the button is hidden on small screens but can
 * be customized via CSS.  Users can change the colour via the plugin
 * settings.
 */
#pctc-chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 64px;
    min-height: 64px;
    padding: 0 16px;
    background-color: #0073aa;
    color: #ffffff;
    border: none;
    border-radius: 32px;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease-in-out, background-color 0.2s ease-in-out;
    /* Set relative positioning so the live indicator can be absolutely positioned inside */
    /* position remains fixed (declared above); no need to redeclare */
}

/* Add a speech bubble icon before the label.  We use the Unicode character
 * U+1F4AC (💬) as a simple icon.  If the browser does not support this
 * character, the label will still be visible. */
#pctc-chat-button::before {
    content: '\1F4AC';
    font-size: 24px;
    margin-right: 6px;
}

/* When a custom icon is provided via settings, hide the default pseudo-element. */
.pctc-has-icon::before {
    display: none;
}

/* Style for custom button icon inserted via PHP.  This element appears
 * inside the chat button before the text label. */
.pctc-button-icon {
    font-size: 24px;
    margin-right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* When a custom image is used as the button icon, style it similarly to the
 * text icon.  The image is constrained to 24px, centered vertically and
 * given a right margin for spacing. */
.pctc-button-icon-img {
    width: 24px;
    height: 24px;
    margin-right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
}

/* Support agent avatar and name displayed in the chat header.  The
 * container uses flexbox to align the image and name horizontally. */
.pctc-agent-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}
.pctc-agent-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.pctc-agent-name {
    font-size: 12px;
    font-weight: normal;
    opacity: 0.9;
}

/* Slight lift on hover */
#pctc-chat-button:hover {
    transform: translateY(-2px);
    background-color: #005885;
}

/* Hide the text label on the button on small devices; the icon will still be visible */
@media (max-width: 480px) {
    #pctc-chat-button .pctc-button-label {
        display: none;
    }

    /* Mobile adjustments for popup.  Position is determined by the wrapper class.
     * We adjust offsets and width for each position on small screens.
     */
    .pctc-position-bottom-right #pctc-chat-popup {
        bottom: 70px;
        right: 10px;
        left: auto;
        top: auto;
        width: calc(100% - 20px);
        border-radius: 14px;
    }
    .pctc-position-bottom-left #pctc-chat-popup {
        bottom: 70px;
        left: 10px;
        right: auto;
        top: auto;
        width: calc(100% - 20px);
        border-radius: 14px;
    }
    .pctc-position-top-right #pctc-chat-popup {
        top: 70px;
        right: 10px;
        left: auto;
        bottom: auto;
        width: calc(100% - 20px);
        border-radius: 14px;
    }
    .pctc-position-top-left #pctc-chat-popup {
        top: 70px;
        left: 10px;
        right: auto;
        bottom: auto;
        width: calc(100% - 20px);
        border-radius: 14px;
    }

    .pctc-user-info input,
    .pctc-input-group input[type="text"],
    .pctc-send-btn {
        font-size: 16px;
    }
    .pctc-chat-header {
        padding: 12px;
    }
}

/* Chat popup container */
/*
 * Instead of simply hiding and showing the chat popup using inline styles,
 * we rely on a CSS class to animate the panel into view.  The widget is
 * positioned off‑screen by default using translateY and zero opacity and
 * pointer‑events set to none.  When the `.pctc-open` class is applied the
 * panel slides up smoothly and becomes interactive, creating a slick
 * animation reminiscent of commercial live chat widgets like JivoChat.
 */
#pctc-chat-popup {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 360px;
    max-width: 95%;
    background-color: #ffffff;
    /* Increase border radius for a more rounded appearance */
    border-radius: 18px;
    /* Soften shadow to create a floating effect */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Hidden state */
    transform: translateY(200%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/*
 * Position classes for the chat wrapper.  These classes are applied to
 * #pctc-chat-wrapper in PHP.  They control the positioning of the
 * button and popup relative to the viewport.  Adjustments here use
 * the same spacing as the default (20px from the edge for the button
 * and 80px for the popup).  The default CSS sets the bottom right
 * positioning; these classes override only the relevant top/bottom
 * and left/right properties.
 */
.pctc-position-bottom-right #pctc-chat-button {
    right: 20px;
    left: auto;
    bottom: 20px;
    top: auto;
}
.pctc-position-bottom-right #pctc-chat-popup {
    right: 20px;
    left: auto;
    bottom: 80px;
    top: auto;
}
.pctc-position-bottom-left #pctc-chat-button {
    left: 20px;
    right: auto;
    bottom: 20px;
    top: auto;
}
.pctc-position-bottom-left #pctc-chat-popup {
    left: 20px;
    right: auto;
    bottom: 80px;
    top: auto;
}
.pctc-position-top-right #pctc-chat-button {
    right: 20px;
    left: auto;
    top: 20px;
    bottom: auto;
}
.pctc-position-top-right #pctc-chat-popup {
    right: 20px;
    left: auto;
    top: 80px;
    bottom: auto;
}
.pctc-position-top-left #pctc-chat-button {
    left: 20px;
    right: auto;
    top: 20px;
    bottom: auto;
}
.pctc-position-top-left #pctc-chat-popup {
    left: 20px;
    right: auto;
    top: 80px;
    bottom: auto;
}

/* Visible state applied via JavaScript */
#pctc-chat-popup.pctc-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Header section */
/* Header section */
.pctc-chat-header {
    padding: 14px 12px;
    background-color: #0073aa;
    color: #ffffff;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Rounded top corners to match popup */
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
}

/* Brand name in header */
.pctc-brand-name {
    font-size: 16px;
    font-weight: bold;
}

/* Wrap containing brand name and tagline */
.pctc-brand-wrap {
    display: flex;
    flex-direction: column;
}

/* Tagline under the brand name */
.pctc-brand-tagline {
    font-size: 12px;
    font-weight: normal;
    opacity: 0.8;
    margin-top: 2px;
}

.pctc-chat-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

/* Body section */
.pctc-chat-body {
    flex: 1 1 auto;
    padding: 10px;
    background-color: inherit;
    color: inherit;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Conversation area */
.pctc-conversation {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 6px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

/* Message bubbles */
.pctc-message {
    max-width: 80%;
    padding: 10px 14px;
    /* Increase border radius for pill‑like chat bubbles */
    border-radius: 24px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.pctc-bot-message {
    align-self: flex-start;
    background-color: #0073aa;
    color: #ffffff;
    /* Custom rounding for bot messages: speech bubble effect */
    border-radius: 24px 24px 24px 8px;
}

.pctc-user-message {
    align-self: flex-end;
    background-color: #f0f0f0;
    color: #333333;
    /* Custom rounding for user messages */
    border-radius: 24px 24px 8px 24px;
}

/* User info (name and email) */
/* User info container.  We allow wrapping so multiple fields can stack on smaller screens. */
.pctc-user-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

/* Fields for name, email and phone */
.pctc-user-info input {
    flex: 1 1 100%;
    padding: 8px 10px;
    border: 1px solid #cccccc;
    /* Larger border radius for a softer look */
    border-radius: 12px;
    font-size: 14px;
    box-sizing: border-box;
}

/* On wider screens, place inputs side by side.  For three fields, we use a two‑column layout to avoid squeezing. */
@media (min-width: 480px) {
    .pctc-user-info input {
        flex: 1 1 calc(50% - 4px);
    }
    /* For the third field (phone), we can make it span full width to avoid cramped layout */
    .pctc-user-info input:last-child {
        flex: 1 1 100%;
    }
}

/* Input group for message and send button */
/* Input group for message and send button */
.pctc-input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.pctc-input-group input[type="text"] {
    flex: 1 1 auto;
    padding: 8px 10px;
    border: 1px solid #cccccc;
    border-radius: 20px;
    font-size: 14px;
    box-sizing: border-box;
}

/* Send button styling */
.pctc-send-btn {
    background-color: #0073aa;
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease-in-out;
}

.pctc-send-btn:hover {
    background-color: #005885;
}

/* Live indicator on chat button
 * The live indicator is a small circular dot positioned inside the chat button to
 * signal that someone is available.  Its colour can be customised via the
 * plugin settings.  By default it uses a green tone.  The indicator is
 * absolutely positioned relative to the chat button (which is fixed). */
.pctc-live-indicator {
    position: absolute;
    width: 10px;
    height: 10px;
    top: 6px;
    right: 6px;
    background-color: #4caf50;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    display: inline-block;
}

/*
 * Layout variations
 * Additional classes are appended to the popup to create alternate looks.  These classes
 * modify border radii, shadows and dimensions to differentiate between classic,
 * modern, minimal, bubble and side panel layouts.
 */

/* Modern layout: squared edges and subtle styling */
.pctc-chat-popup.pctc-layout-modern {
    border-radius: 8px;
}
.pctc-chat-popup.pctc-layout-modern .pctc-chat-header {
    border-radius: 8px 8px 0 0;
}

/* Minimal layout: remove shadows and background from header */
.pctc-chat-popup.pctc-layout-minimal {
    box-shadow: none;
    border: 1px solid #e0e0e0;
}
.pctc-chat-popup.pctc-layout-minimal .pctc-chat-header {
    background-color: transparent;
    color: inherit;
    padding-top: 8px;
    padding-bottom: 8px;
}
.pctc-chat-popup.pctc-layout-minimal .pctc-chat-close {
    color: inherit;
}

/* Bubble layout: more rounded corners and reduced width */
.pctc-chat-popup.pctc-layout-bubble {
    border-radius: 30px;
    width: 320px;
}
.pctc-chat-popup.pctc-layout-bubble .pctc-chat-header {
    border-radius: 30px 30px 0 0;
}

/* Side panel layout: taller panel reminiscent of a sidebar */
.pctc-chat-popup.pctc-layout-sidepanel {
    width: 380px;
    height: 80vh;
    max-height: 90%;
    max-width: 90%;
}

/* Offline status: optionally adjust appearance when chat is offline */
.pctc-chat-popup.pctc-offline .pctc-chat-header {
    opacity: 0.8;
}

/* WhatsApp link styling */
.pctc-whatsapp-wrap {
    margin-top: 8px;
    text-align: center;
}
.pctc-whatsapp-link {
    display: inline-block;
    background-color: #25D366;
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    transition: opacity 0.2s ease-in-out;
}
.pctc-whatsapp-link:hover {
    opacity: 0.9;
}