/*
 * 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;
}

/* Chat logo in header */
.pctc-chat-logo {
    width: 32px;
    height: 32px;
    margin-right: 8px;
    object-fit: cover;
    border-radius: 6px;
}

/* Header avatar shown before brand name (agent image or chat logo) */
.pctc-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
}

/* Header layout.  We separate the left section (logo and brand) and controls */
.pctc-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
}
.pctc-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pctc-header-controls button {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
}

/* Suggestions area */
.pctc-suggestions {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pctc-suggestion {
    background-color: rgba(0,0,0,0.05);
    border: none;
    border-radius: 14px;
    padding: 8px 12px;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.pctc-suggestion:hover {
    background-color: rgba(0,0,0,0.1);
}

/* Attach button inside input group */
.pctc-attach-btn {
    background-color: #f5f5f5;
    border: 1px solid #cccccc;
    border-radius: 20px;
    color: #555555;
    padding: 0 12px;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.pctc-attach-btn:hover {
    background-color: #e0e0e0;
}

/* Override send button styling for arrow icon.  Keep same structure but adjust padding */
.pctc-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    padding: 0 16px;
    border: none;
    border-radius: 20px;
    background-color: #0073aa;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.pctc-send-btn:hover {
    background-color: #005885;
}

/* Reply time message */
.pctc-reply-time {
    margin-top: 6px;
    font-size: 12px;
    font-style: italic;
    color: rgba(0,0,0,0.6);
}

/* Minimized state: collapse body content but keep header visible. */
#pctc-chat-popup.pctc-minimized {
    height: auto;
    max-height: none;
    overflow: hidden;
}
#pctc-chat-popup.pctc-minimized .pctc-chat-body {
    display: none;
}

/* 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;
}

/* Agent name inside brand wrap (used when avatar displayed separately) */
.pctc-brand-wrap .pctc-agent-name {
    font-size: 12px;
    font-weight: normal;
    opacity: 0.8;
    margin-top: 2px;
}

/* 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 is inherited from the header to allow dynamic colouring */
    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 */
/* Adjust user info to support icons.  Each input is wrapped in .pctc-field-wrapper which handles
   alignment of the icon and input. */
.pctc-user-info .pctc-field-wrapper {
    /* Position relative so the icon can be absolutely positioned within the wrapper */
    position: relative;
    flex: 1 1 100%;
    display: flex;
    align-items: center;
}

.pctc-user-info .pctc-field-wrapper input {
    flex: 1 1 auto;
    padding: 8px 10px;
    /* Add left padding to accommodate the left positioned icon */
    padding-left: 36px;
    border: 1px solid #cccccc;
    /* Larger border radius for a softer look */
    border-radius: 12px;
    font-size: 14px;
    box-sizing: border-box;
}

/* Icons inside user info fields */
/* The icon is absolutely positioned inside the field wrapper on the left.  We
 * disable pointer events so that clicking on the icon focuses the input. */
.pctc-user-info .pctc-field-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* On wider screens, split first two field wrappers half width and last full width */
@media (min-width: 480px) {
    .pctc-user-info .pctc-field-wrapper {
        flex: 1 1 calc(50% - 4px);
    }
    .pctc-user-info .pctc-field-wrapper: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;
}
/* WhatsApp button uses flexbox to align the icon and label horizontally.
 * We use flex instead of inline-flex to ensure the button content wraps
 * correctly in narrow containers. */
.pctc-whatsapp-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    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;
}

/* Chat status indicator inserted before the popup tagline. */
.pctc-chat-status-icon {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

/* Container for status indicator and tagline.  Align contents horizontally so
 * the indicator appears to the left of the tagline on the same line. */
.pctc-tagline-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Remove default margin from status icon inside tagline wrap; spacing is
 * handled by the gap on the wrap. */
.pctc-tagline-wrap .pctc-chat-status-icon {
    margin-right: 0;
}
.pctc-status-online {
    background-color: #4caf50;
}
.pctc-status-offline {
    background-color: #cccccc;
}
/* WhatsApp icon and label inside the link */
.pctc-whatsapp-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pctc-whatsapp-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}
.pctc-whatsapp-label {
    line-height: 1;
}