/* =============================================================
   Chesterfield AI Chatbot — chatbot.css
   CSS custom properties --cfc-primary and --cfc-dark are
   injected by PHP via wp_add_inline_style so the :root block
   below acts only as a safe fallback.
   ============================================================= */

:root {
    --cfc-primary: #86704d;
    --cfc-dark: #6b4f41;
    --cfc-radius: 16px;
    --cfc-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    --cfc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.10);
    --cfc-white: #ffffff;
    --cfc-bg: #f8f7f5;
    --cfc-text: #2d2d2d;
    --cfc-text-light: #666666;
    --cfc-border: #e8e4df;
    --cfc-green: #27ae60;
    --cfc-green-dark: #1e8449;
    --cfc-orange: #e67e22;
    --cfc-orange-dark: #ca6f1e;
    --cfc-red: #e74c3c;
    --cfc-panel-width: 380px;
    --cfc-panel-height: 520px;
    --cfc-fab-size: 58px;
    --cfc-edge: 24px;
}

/* =============================================================
   ROOT CONTAINER
   ============================================================= */

#cfc-root {
    position: fixed;
    bottom: var(--cfc-edge);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
}

#cfc-root * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#cfc-root.cfc-pos-right {
    right: var(--cfc-edge);
    left: auto;
    align-items: flex-end;
}

#cfc-root.cfc-pos-left {
    left: var(--cfc-edge);
    right: auto;
    align-items: flex-start;
}

/* =============================================================
   FAB (Floating Action Button)
   ============================================================= */

#cfc-fab {
    position: relative;
    width: var(--cfc-fab-size);
    height: var(--cfc-fab-size);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cfc-primary) 0%, var(--cfc-dark) 100%);
    box-shadow: 0 4px 16px rgba(134, 112, 77, 0.45), 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    border: none;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

#cfc-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(134, 112, 77, 0.55), 0 3px 10px rgba(0, 0, 0, 0.18);
}

#cfc-fab:active {
    transform: scale(0.96);
}

/* Pulse ring — only when chat is closed */
#cfc-fab::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--cfc-primary);
    opacity: 0;
    animation: cfcPulse 2.4s ease-out infinite;
}

#cfc-fab.is-open::before {
    animation: none;
    opacity: 0;
}

@keyframes cfcPulse {
    0%   { transform: scale(1);    opacity: 0.7; }
    70%  { transform: scale(1.4);  opacity: 0; }
    100% { transform: scale(1.4);  opacity: 0; }
}

/* Icons inside FAB */
#cfc-fab .cfc-fab-icon-chat,
#cfc-fab .cfc-fab-icon-close {
    position: absolute;
    width: 24px;
    height: 24px;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#cfc-fab .cfc-fab-icon-chat {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

#cfc-fab .cfc-fab-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
}

#cfc-fab.is-open .cfc-fab-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}

#cfc-fab.is-open .cfc-fab-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Notification dot */
#cfc-fab-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 11px;
    height: 11px;
    background: var(--cfc-red);
    border-radius: 50%;
    border: 2px solid var(--cfc-white);
    display: none;
}

#cfc-fab-dot.visible {
    display: block;
}

/* =============================================================
   PROACTIVE BUBBLE
   ============================================================= */

#cfc-proactive {
    background: var(--cfc-white);
    border-radius: 12px;
    padding: 10px 36px 10px 14px;
    max-width: 220px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--cfc-text);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
    position: relative;
    pointer-events: all;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#cfc-proactive.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Caret pointing downward toward FAB */
#cfc-proactive::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--cfc-white);
}

.cfc-pos-left #cfc-proactive::after {
    right: auto;
    left: 20px;
}

#cfc-proactive-dismiss {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--cfc-text-light);
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    transition: background 0.15s;
}

#cfc-proactive-dismiss:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* =============================================================
   CHAT PANEL
   ============================================================= */

#cfc-panel {
    width: var(--cfc-panel-width);
    height: var(--cfc-panel-height);
    background: var(--cfc-white);
    border-radius: var(--cfc-radius);
    box-shadow: var(--cfc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: all;
    transform-origin: bottom right;
    transform: scale(0.85);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.25s ease;
    pointer-events: none;
}

.cfc-pos-left #cfc-panel {
    transform-origin: bottom left;
}

#cfc-panel.open {
    transform: scale(1);
    opacity: 1;
    pointer-events: all;
}

/* =============================================================
   HEADER
   ============================================================= */

#cfc-header {
    flex-shrink: 0;
    height: 60px;
    background: linear-gradient(135deg, var(--cfc-primary) 0%, var(--cfc-dark) 100%);
    display: flex;
    align-items: center;
    padding: 0 12px 0 14px;
    gap: 10px;
}

#cfc-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    color: var(--cfc-white);
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

#cfc-header-info {
    flex: 1;
    min-width: 0;
}

#cfc-agent-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--cfc-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#cfc-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

#cfc-status-dot {
    width: 7px;
    height: 7px;
    background: #2ecc71;
    border-radius: 50%;
    flex-shrink: 0;
}

#cfc-status-text {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
}

#cfc-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

#cfc-team-btn {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 20px;
    color: var(--cfc-white);
    font-size: 11px;
    padding: 4px 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

#cfc-team-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

#cfc-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--cfc-white);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    transition: background 0.15s;
    flex-shrink: 0;
}

#cfc-close-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

#cfc-close-btn svg {
    width: 16px;
    height: 16px;
}

/* =============================================================
   MESSAGES AREA
   ============================================================= */

#cfc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--cfc-bg);
    scroll-behavior: smooth;
}

#cfc-messages::-webkit-scrollbar {
    width: 4px;
}

#cfc-messages::-webkit-scrollbar-track {
    background: transparent;
}

#cfc-messages::-webkit-scrollbar-thumb {
    background: rgba(134, 112, 77, 0.3);
    border-radius: 2px;
}

#cfc-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(134, 112, 77, 0.55);
}

/* =============================================================
   MESSAGE BUBBLES
   ============================================================= */

.cfc-msg {
    max-width: 82%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 14px;
    word-break: break-word;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.cfc-msg.visible {
    opacity: 1;
    transform: translateY(0);
}

.cfc-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--cfc-primary) 0%, var(--cfc-dark) 100%);
    color: var(--cfc-white);
    border-bottom-right-radius: 4px;
}

.cfc-msg--bot {
    align-self: flex-start;
    background: var(--cfc-white);
    color: var(--cfc-text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--cfc-shadow-sm);
}

.cfc-msg--bot a {
    color: var(--cfc-primary);
    text-decoration: underline;
}

.cfc-msg--bot ul {
    margin: 6px 0 0 0;
    padding-left: 18px;
}

.cfc-msg--bot li {
    margin-bottom: 3px;
}

/* =============================================================
   TYPING INDICATOR
   ============================================================= */

.cfc-typing {
    align-self: flex-start;
    background: var(--cfc-white);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    box-shadow: var(--cfc-shadow-sm);
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.cfc-typing.visible {
    opacity: 1;
    transform: translateY(0);
}

.cfc-typing span {
    width: 7px;
    height: 7px;
    background: var(--cfc-primary);
    border-radius: 50%;
    display: block;
    animation: cfcBounce 1.3s ease-in-out infinite;
    opacity: 0.7;
}

.cfc-typing span:nth-child(2) { animation-delay: 0.18s; }
.cfc-typing span:nth-child(3) { animation-delay: 0.36s; }

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

/* =============================================================
   PRODUCT CARDS
   ============================================================= */

.cfc-product {
    align-self: flex-start;
    background: var(--cfc-white);
    border: 1px solid var(--cfc-border);
    border-radius: 12px;
    padding: 12px;
    max-width: 88%;
    box-shadow: var(--cfc-shadow-sm);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.cfc-product.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Product card rendered inline inside a bot message */
.cfc-product--inline {
    margin-top: 8px;
    max-width: 100%;
}

.cfc-product-loading {
    font-size: 12px;
    color: var(--cfc-text-light);
    font-style: italic;
    padding: 4px 2px;
}

.cfc-product-inner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.cfc-product-img {
    width: 66px;
    height: 66px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--cfc-border);
    flex-shrink: 0;
}

.cfc-product-info {
    flex: 1;
    min-width: 0;
}

.cfc-product-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--cfc-text);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.cfc-product-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--cfc-primary);
    margin: 0 0 3px 0;
}

.cfc-product-sku {
    font-size: 11px;
    color: var(--cfc-text-light);
    margin: 0 0 5px 0;
}

.cfc-product-stock {
    display: inline-block;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 500;
}

.cfc-product-stock--in {
    background: #e8f8f0;
    color: var(--cfc-green);
}

.cfc-product-stock--out {
    background: #fde8e8;
    color: var(--cfc-red);
}

.cfc-product-actions {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}


.cfc-add-to-cart {
    flex: 1;
    padding: 7px 10px;
    background: linear-gradient(135deg, var(--cfc-primary) 0%, var(--cfc-dark) 100%);
    color: var(--cfc-white);
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    white-space: nowrap;
}

.cfc-add-to-cart:hover:not(:disabled) {
    opacity: 0.85;
    transform: translateY(-1px);
}

.cfc-add-to-cart:active:not(:disabled) {
    transform: translateY(0);
}

.cfc-add-to-cart:disabled {
    opacity: 0.6;
    cursor: default;
}

.cfc-checkout-btn {
    flex: 1;
    padding: 7px 10px;
    background: transparent;
    color: var(--cfc-primary);
    border: 1.5px solid var(--cfc-primary);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
    white-space: nowrap;
}

.cfc-checkout-btn:hover {
    background: var(--cfc-primary);
    color: var(--cfc-white);
    transform: translateY(-1px);
}

.cfc-checkout-btn:active {
    transform: translateY(0);
}

/* Inline add-to-cart button rendered directly inside a bot message bubble */
.cfc-inline-atc {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: none;
    margin-top: 8px;
    padding: 7px 14px;
    font-size: 13px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(134, 112, 77, 0.3);
}

.cfc-inline-atc:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

/* =============================================================
   INPUT AREA
   ============================================================= */

#cfc-input {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--cfc-white);
    border-top: 1px solid var(--cfc-border);
}

#cfc-text-input {
    flex: 1;
    padding: 9px 14px;
    border: 1.5px solid var(--cfc-border);
    border-radius: 22px;
    font-size: 14px;
    color: var(--cfc-text);
    background: var(--cfc-bg);
    outline: none;
    transition: border-color 0.2s;
    resize: none;
}

#cfc-text-input::placeholder {
    color: #aaa;
}

#cfc-text-input:focus {
    border-color: var(--cfc-primary);
    background: var(--cfc-white);
}

#cfc-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cfc-primary) 0%, var(--cfc-dark) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}

#cfc-send-btn:hover {
    transform: scale(1.08);
}

#cfc-send-btn:active {
    transform: scale(0.94);
}

#cfc-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#cfc-send-btn svg {
    width: 18px;
    height: 18px;
}

/* =============================================================
   LEAD FORM
   ============================================================= */

.cfc-lead-form {
    align-self: flex-start;
    background: var(--cfc-white);
    border: 1px solid var(--cfc-border);
    border-radius: 12px;
    padding: 16px;
    max-width: 92%;
    box-shadow: var(--cfc-shadow-sm);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.cfc-lead-form.visible {
    opacity: 1;
    transform: translateY(0);
}

.cfc-lead-form-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--cfc-text);
    margin: 0 0 12px 0;
}

.cfc-lead-field {
    margin-bottom: 10px;
}

.cfc-lead-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--cfc-text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.cfc-lead-field input,
.cfc-lead-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid var(--cfc-border);
    border-radius: 7px;
    font-size: 13px;
    color: var(--cfc-text);
    background: var(--cfc-bg);
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.cfc-lead-field input:focus,
.cfc-lead-field textarea:focus {
    border-color: var(--cfc-primary);
    background: var(--cfc-white);
}

.cfc-lead-field input.cfc-error,
.cfc-lead-field textarea.cfc-error {
    border-color: var(--cfc-red);
}

.cfc-lead-field textarea {
    resize: vertical;
    min-height: 60px;
}

.cfc-lead-error-msg {
    font-size: 11px;
    color: var(--cfc-red);
    margin-top: 3px;
    display: none;
}

.cfc-lead-error-msg.visible {
    display: block;
}

.cfc-lead-submit {
    width: 100%;
    padding: 9px;
    background: linear-gradient(135deg, var(--cfc-primary) 0%, var(--cfc-dark) 100%);
    color: var(--cfc-white);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    transition: opacity 0.15s, transform 0.15s;
}

.cfc-lead-submit:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.cfc-lead-submit:active {
    transform: translateY(0);
}

.cfc-lead-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.cfc-lead-cancel {
    display: block;
    text-align: center;
    font-size: 11px;
    color: var(--cfc-text-light);
    cursor: pointer;
    margin-top: 8px;
    background: none;
    border: none;
    text-decoration: underline;
    padding: 0;
}

.cfc-lead-cancel:hover {
    color: var(--cfc-text);
}

/* =============================================================
   MOBILE — full screen panel
   ============================================================= */

@media (max-width: 480px) {
    #cfc-root {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        pointer-events: none;
        align-items: flex-end;
        justify-content: flex-end;
    }

    #cfc-root.cfc-pos-left {
        align-items: flex-start;
    }

    #cfc-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        border-radius: 0;
        transform-origin: bottom center;
    }

    #cfc-fab {
        position: fixed;
        bottom: 16px;
        right: 16px;
        z-index: 100000;
        pointer-events: all;
    }

    .cfc-pos-left #cfc-fab {
        right: auto;
        left: 16px;
    }

    #cfc-proactive {
        position: fixed;
        bottom: 86px;
        right: 16px;
        pointer-events: all;
    }

    .cfc-pos-left #cfc-proactive {
        right: auto;
        left: 16px;
    }

    #cfc-root.cfc-pos-left,
    #cfc-root.cfc-pos-right {
        right: 0;
        left: 0;
        bottom: 0;
    }
}
