
/**
 * Chat Widget Styles
 * On-theme: brand green (#2d6e3e) + orange (#ff7b00) accents.
 * NOTE: the button / header / primary-button gradients are also injected
 * inline from the admin colour settings (with !important) by the main plugin
 * file; the values below are the on-theme fallbacks used when no override is
 * present. Accent colours (orange) are applied on selectors the inline block
 * does not touch, so they always win.
 */

#cfaq-chat-widget {
    --cfaq-green: #2d6e3e;
    --cfaq-green-dark: #1a3c24;
    --cfaq-orange: #ff7b00;
    --cfaq-orange-dark: #e66c00;
    --cfaq-ink: #1f2937;
    --cfaq-ink-soft: #6b7280;
    --cfaq-border: #e5e7eb;
    --cfaq-surface: #ffffff;
    --cfaq-canvas: #f3f6f4;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.cfaq-chat-button {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d6e3e 0%, #1a3c24 100%);
    border: none;
    box-shadow: 0 8px 22px rgba(45, 110, 62, 0.38);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: relative;
}

.cfaq-chat-button:hover {
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 12px 28px rgba(45, 110, 62, 0.5);
}

.cfaq-chat-button:focus-visible {
    outline: 3px solid var(--cfaq-orange);
    outline-offset: 3px;
}

.cfaq-chat-button svg {
    width: 28px;
    height: 28px;
}

.cfaq-notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: var(--cfaq-orange);
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 rgba(255, 123, 0, 0.6);
    animation: cfaqBadgePulse 1.8s infinite;
}

@keyframes cfaqBadgePulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 123, 0, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(255, 123, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 123, 0, 0); }
}

/* Chat Window */
.cfaq-chat-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 360px;
    height: 540px;
    max-height: calc(100vh - 130px);
    background: var(--cfaq-surface);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(16, 40, 24, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* Header */
.cfaq-chat-header {
    background: linear-gradient(135deg, #2d6e3e 0%, #1a3c24 100%);
    color: #fff;
    padding: 20px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.cfaq-chat-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--cfaq-orange);
}

.cfaq-chat-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.cfaq-close-btn {
    background: rgba(255, 255, 255, 0.14);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.cfaq-close-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* Body */
.cfaq-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--cfaq-canvas);
}

/* Custom Scrollbar */
.cfaq-chat-body::-webkit-scrollbar { width: 6px; }
.cfaq-chat-body::-webkit-scrollbar-track { background: transparent; }
.cfaq-chat-body::-webkit-scrollbar-thumb { background: #cdd6cf; border-radius: 3px; }
.cfaq-chat-body::-webkit-scrollbar-thumb:hover { background: #a9b6ac; }
.cfaq-chat-body { scrollbar-width: thin; scrollbar-color: #cdd6cf transparent; }

.cfaq-view { display: none; }
.cfaq-view-active { display: block; }

/* Welcome Message */
.cfaq-welcome-message {
    background: transparent;
    padding: 0 0 14px 0;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--cfaq-border);
}

.cfaq-welcome-message p {
    margin: 0;
    color: var(--cfaq-ink);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* FAQ List */
.cfaq-faq-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cfaq-faq-item {
    background: var(--cfaq-surface);
    border: 1.5px solid var(--cfaq-border);
    border-radius: 12px;
    padding: 14px 15px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cfaq-faq-item:hover {
    border-color: var(--cfaq-green);
    background: #f7faf8;
    transform: translateX(4px);
    box-shadow: 0 4px 14px rgba(45, 110, 62, 0.12);
}

.cfaq-faq-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: rgba(255, 123, 0, 0.12);
}

.cfaq-faq-icon svg {
    width: 15px;
    height: 15px;
    stroke: var(--cfaq-orange);
}

.cfaq-faq-text {
    color: var(--cfaq-ink);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

/* Answer View */
.cfaq-answer-content {
    background: var(--cfaq-surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(16, 40, 24, 0.06);
}

.cfaq-back-btn {
    background: transparent;
    border: none;
    color: var(--cfaq-green);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 15px;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.cfaq-back-btn:hover { background: #eef4ef; }

.cfaq-answer-text {
    color: #374151;
    font-size: 14px;
    line-height: 1.65;
    margin-bottom: 20px;
    white-space: pre-wrap;
}

.cfaq-feedback {
    border-top: 1px solid var(--cfaq-border);
    padding-top: 18px;
}

.cfaq-feedback p {
    color: var(--cfaq-ink-soft);
    font-size: 14px;
    margin: 0 0 14px 0;
    font-weight: 500;
}

.cfaq-feedback-buttons {
    display: flex;
    gap: 10px;
}

/* Buttons */
.cfaq-btn {
    padding: 11px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    flex: 1;
}

.cfaq-btn-primary {
    background: linear-gradient(135deg, #2d6e3e 0%, #1a3c24 100%);
    color: #fff;
}

.cfaq-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(45, 110, 62, 0.38);
}

.cfaq-btn-success {
    background: var(--cfaq-green);
    color: #fff;
}

.cfaq-btn-success:hover { background: var(--cfaq-green-dark); }

.cfaq-btn-secondary {
    background: #eef1ee;
    color: #374151;
}

.cfaq-btn-secondary:hover { background: #e2e6e2; }

/* Agent Request View */
.cfaq-agent-request-content {
    background: var(--cfaq-surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(16, 40, 24, 0.06);
}

.cfaq-agent-request-content h4 {
    margin: 0 0 8px 0;
    color: #111827;
    font-size: 16px;
    font-weight: 700;
}

.cfaq-agent-request-content p {
    color: var(--cfaq-ink-soft);
    font-size: 14px;
    margin: 0 0 14px 0;
    line-height: 1.55;
}

.cfaq-textarea {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--cfaq-border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.cfaq-textarea:focus {
    outline: none;
    border-color: var(--cfaq-green);
    box-shadow: 0 0 0 3px rgba(45, 110, 62, 0.14);
}

/* Success View */
.cfaq-success-content {
    background: var(--cfaq-surface);
    border-radius: 12px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(16, 40, 24, 0.06);
}

.cfaq-success-icon {
    width: 64px;
    height: 64px;
    background: var(--cfaq-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: #fff;
    box-shadow: 0 8px 20px rgba(45, 110, 62, 0.3);
}

.cfaq-success-content h4 {
    margin: 0 0 10px 0;
    color: #111827;
    font-size: 18px;
    font-weight: 700;
}

.cfaq-success-content p {
    color: var(--cfaq-ink-soft);
    font-size: 14px;
    margin: 0 0 20px 0;
    line-height: 1.55;
}

/* Live Chat View (customer side of an agent session) */
#cfaq-live-view.cfaq-view-active {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.cfaq-live-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--cfaq-surface);
    border: 1.5px solid var(--cfaq-border);
    border-radius: 10px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--cfaq-ink-soft);
}

.cfaq-live-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--cfaq-orange);
    flex-shrink: 0;
    animation: cfaqBadgePulse 1.8s infinite;
}

.cfaq-live-status-active .cfaq-live-status-dot {
    background: var(--cfaq-green);
    animation: none;
}

.cfaq-live-status-ended .cfaq-live-status-dot {
    background: #ef4444;
    animation: none;
}

.cfaq-live-end-btn {
    margin-left: auto;
    background: transparent;
    border: 1.5px solid var(--cfaq-border);
    border-radius: 8px;
    color: var(--cfaq-ink-soft);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.cfaq-live-end-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
}

.cfaq-live-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 2px;
    scrollbar-width: thin;
    scrollbar-color: #cdd6cf transparent;
}

.cfaq-live-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.cfaq-live-msg-user {
    align-self: flex-end;
    align-items: flex-end;
}

.cfaq-live-msg-agent {
    align-self: flex-start;
    align-items: flex-start;
}

.cfaq-live-msg-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.cfaq-live-msg-user .cfaq-live-msg-bubble {
    background: var(--cfaq-green);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.cfaq-live-msg-agent .cfaq-live-msg-bubble {
    background: var(--cfaq-surface);
    border: 1.5px solid var(--cfaq-border);
    color: var(--cfaq-ink);
    border-bottom-left-radius: 4px;
}

.cfaq-live-msg-time {
    font-size: 11px;
    color: var(--cfaq-ink-soft);
    margin-top: 3px;
    padding: 0 4px;
}

.cfaq-live-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.cfaq-live-input {
    flex: 1;
    padding: 10px 12px;
    border: 1.5px solid var(--cfaq-border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    box-sizing: border-box;
    max-height: 90px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cfaq-live-input:focus {
    outline: none;
    border-color: var(--cfaq-green);
    box-shadow: 0 0 0 3px rgba(45, 110, 62, 0.14);
}

.cfaq-live-send-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: 10px;
    background: var(--cfaq-orange);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.cfaq-live-send-btn:hover { background: var(--cfaq-orange-dark); transform: translateY(-1px); }
.cfaq-live-send-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.cfaq-live-closed {
    margin-top: 10px;
    background: var(--cfaq-surface);
    border: 1.5px solid var(--cfaq-border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.cfaq-live-closed p {
    margin: 0 0 12px 0;
    color: var(--cfaq-ink-soft);
    font-size: 14px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .cfaq-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 130px);
        right: 16px;
        bottom: 92px;
    }
}

@media (max-width: 480px) {
    #cfaq-chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .cfaq-chat-window {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 80px;
    }
}
