/**
 * Frontend Help & Chat Widget Styles
 * Matches the user's screenshots exactly.
 */

/* Container and Positioning */
.plugin-chat-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Global resets for our widget to avoid theme overrides */
.plugin-chat-container button:not(.plugin-chat-toggle-btn) {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    cursor: pointer !important;
    text-transform: none !important;
    line-height: inherit !important;
    -webkit-appearance: none !important;
    border-radius: 0 !important;
}

.plugin-chat-container span:not(.plugin-chat-toggle-status-dot) {
    background: transparent !important;
    background-color: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.plugin-chat-container svg {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    display: block !important;
}

/* Launcher Switching: Bubble Mode vs Bar Mode */
.plugin-chat-container.mode-bubble .plugin-chat-launcher-bar {
    display: none !important;
}
.plugin-chat-container.mode-bubble .plugin-chat-launcher-bubble {
    display: flex !important;
}

.plugin-chat-container.mode-bar .plugin-chat-launcher-bubble {
    display: none !important;
}
.plugin-chat-container.mode-bar .plugin-chat-launcher-bar {
    display: flex !important;
}

/* Floating Toggle Button (Bubble Mode) */
.plugin-chat-toggle-btn {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background-color: var(--pc-primary-color) !important;
    color: #ffffff !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s !important;
    position: relative !important;
    outline: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

.plugin-chat-toggle-btn:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2) !important;
}

.plugin-chat-toggle-btn:active {
    transform: scale(0.95) !important;
}

/* Anchored Bar Button (Bar Mode) */
.plugin-chat-bar-btn {
    height: 46px !important;
    background-color: var(--pc-primary-color) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 14px 14px 0 0 !important;
    padding: 0 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
    cursor: pointer !important;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.16) !important;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, background-color 0.2s ease !important;
    position: relative !important;
    outline: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

.plugin-chat-bar-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 -6px 22px rgba(0, 0, 0, 0.22) !important;
}

.plugin-chat-bar-btn:active {
    transform: translateY(0) !important;
}

.plugin-chat-bar-content {
    display: flex !important;
    align-items: center !important;
    gap: 9px !important;
}

.plugin-chat-bar-icon {
    display: flex !important;
    align-items: center !important;
    color: #ffffff !important;
}

.plugin-chat-bar-text {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #ffffff !important;
    white-space: nowrap !important;
    letter-spacing: -0.2px !important;
}

.plugin-chat-bar-dot {
    width: 9px !important;
    height: 9px !important;
    background-color: #10B981 !important;
    border: 1.5px solid #ffffff !important;
    border-radius: 50% !important;
    display: inline-block !important;
    animation: pcStatusPulse 2s infinite !important;
    margin-left: 2px !important;
}

.plugin-chat-bar-chevron {
    display: flex !important;
    align-items: center !important;
    color: rgba(255, 255, 255, 0.85) !important;
    transition: transform 0.25s ease !important;
}

.plugin-chat-bar-btn[aria-expanded="true"] .pc-bar-chevron-open {
    display: none !important;
}
.plugin-chat-bar-btn[aria-expanded="true"] .pc-bar-chevron-close {
    display: flex !important;
}
.plugin-chat-bar-btn[aria-expanded="false"] .pc-bar-chevron-open {
    display: flex !important;
}
.plugin-chat-bar-btn[aria-expanded="false"] .pc-bar-chevron-close {
    display: none !important;
}

/* Icons inside toggle */
.plugin-chat-icon-open,
.plugin-chat-icon-close {
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    background-color: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: inherit !important;
    width: auto !important;
    height: auto !important;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Control icon display based on button expanded state */
.plugin-chat-toggle-btn[aria-expanded="false"] .plugin-chat-icon-open {
    display: flex !important;
}
.plugin-chat-toggle-btn[aria-expanded="false"] .plugin-chat-icon-close {
    display: none !important;
}

.plugin-chat-toggle-btn[aria-expanded="true"] .plugin-chat-icon-open {
    display: none !important;
}
.plugin-chat-toggle-btn[aria-expanded="true"] .plugin-chat-icon-close {
    display: flex !important;
}

/* Status Dot on Toggle Button (Closed State) */
.plugin-chat-toggle-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background-color: #10B981; /* Green */
    border: 2px solid #ffffff;
    border-radius: 50%;
    animation: pcStatusPulse 2s infinite;
}

@keyframes pcStatusPulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Help Panel Card Container */
.plugin-chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 370px;
    max-width: calc(100vw - 60px);
    max-height: calc(100vh - 130px);
    background-color: var(--pc-widget-bg);
    border-radius: 28px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    transform-origin: bottom right;
    animation: pcPanelOpen 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Panel positioning override when in bar mode */
.plugin-chat-container.mode-bar .plugin-chat-panel {
    bottom: 56px !important;
}

/* Left-side position override */
.plugin-chat-container.pos-left .plugin-chat-panel {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

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

/* Header Styling */
.plugin-chat-header {
    padding: 24px 24px 16px 24px;
    background: var(--pc-header-bg);
    color: var(--pc-header-text);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.plugin-chat-header-content {
    flex-grow: 1;
}

.plugin-chat-title {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 4px;
    color: var(--pc-header-text);
    letter-spacing: -0.5px;
}

.plugin-chat-subtitle {
    font-size: 15px;
    font-weight: 500;
    color: #4b5563;
    opacity: 0.9;
}

.plugin-chat-close-btn {
    background: transparent;
    border: none;
    color: #4b5563;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
    margin-top: 2px;
}

.plugin-chat-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #111827;
}

/* Panel Body Scrollable Content */
.plugin-chat-body {
    padding: 0 20px 24px 20px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.plugin-chat-body::-webkit-scrollbar {
    width: 5px;
}
.plugin-chat-body::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.1);
    border-radius: 10px;
}

/* Card General Design */
.plugin-chat-card {
    background-color: var(--pc-card-bg);
    border-radius: 18px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.015);
    padding: 16px 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: var(--pc-text-color);
}

/* Contact Card specifics */
.plugin-chat-contact-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.plugin-chat-card-header {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.plugin-chat-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
}

.plugin-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.plugin-chat-status-dot {
    width: 10px;
    height: 10px;
    background-color: var(--pc-status-color);
    border-radius: 50%;
    display: inline-block;
}

.plugin-chat-status-text {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
}

/* Contact Action buttons */
.plugin-chat-contact-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.plugin-chat-btn {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    background-color: var(--pc-whatsapp-color);
    color: #ffffff;
    border: none;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 14.5px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.28);
    transition: background-color 0.2s, transform 0.15s, box-shadow 0.2s;
    height: 44px;
}

.plugin-chat-btn:hover {
    opacity: 0.95;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.38);
}

.plugin-chat-btn:active {
    transform: scale(0.98);
}

.plugin-chat-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.plugin-chat-icon-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.plugin-chat-icon-btn:active {
    transform: scale(0.95);
}

.plugin-chat-email-btn {
    background-color: var(--pc-email-color);
}

/* FAQ Card styling */
.plugin-chat-faq-card {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* FAQ Search Box with icon on right */
.plugin-chat-search-wrapper {
    position: relative;
    width: 100%;
}

.plugin-chat-search-wrapper input {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border-radius: 12px;
    border: none;
    background-color: #f3f4f6;
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    outline: none;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.plugin-chat-search-wrapper input:focus {
    background-color: #e5e7eb;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.plugin-chat-search-wrapper input::placeholder {
    color: #9ca3af;
    font-weight: 500;
}

.plugin-chat-search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    display: flex;
    align-items: center;
}

/* FAQ Accordion List */
.plugin-chat-faq-list {
    display: flex;
    flex-direction: column;
}

.plugin-chat-faq-item {
    border-bottom: 1px solid #f3f4f6;
}

.plugin-chat-faq-item:last-child {
    border-bottom: none;
}

.plugin-chat-faq-list,
.plugin-chat-faq-item {
    background: transparent !important;
    background-color: transparent !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
}

.plugin-chat-faq-question {
    width: 100% !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 14px 0 !important;
    display: block !important;
    text-align: center !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #1f2937 !important;
    outline: none !important;
    position: relative !important;
    transition: color 0.2s !important;
}

.plugin-chat-faq-question span {
    background: transparent !important;
    background-color: transparent !important;
    padding: 0 24px !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    color: inherit !important;
    display: inline-block !important;
    text-align: center !important;
}

.plugin-chat-faq-question:hover {
    color: var(--pc-primary-color) !important;
}

.plugin-chat-faq-chevron {
    color: #9ca3af !important;
    position: absolute !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    align-items: center !important;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s !important;
    flex-shrink: 0 !important;
}

.plugin-chat-faq-item.active .plugin-chat-faq-chevron {
    transform: translateY(-50%) rotate(90deg) !important;
    color: var(--pc-primary-color) !important;
}

.plugin-chat-faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.plugin-chat-faq-answer-content {
    padding-bottom: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    color: #4b5563;
}

.plugin-chat-faq-answer-content a {
    color: var(--pc-primary-color);
    text-decoration: underline;
}

.plugin-chat-no-results {
    padding: 20px 0;
    text-align: center;
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

.plugin-chat-no-faqs {
    padding: 15px 0;
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
}

/* Animations for admin preview */
.plugin-chat-inline-preview-widget .plugin-chat-panel {
    display: flex !important; /* Force panel visible in design view if we want it open */
    position: absolute !important;
}

/* Media Queries for Responsive Widget */
@media (max-width: 480px) {
    .plugin-chat-panel {
        width: calc(100vw - 40px);
        right: -10px;
        bottom: 75px;
        border-radius: 24px;
    }
    .plugin-chat-container.pos-left .plugin-chat-panel {
        left: -10px;
        right: auto;
    }
    .plugin-chat-container.mode-bar .plugin-chat-panel {
        bottom: 54px !important;
        right: -10px !important;
    }
    .plugin-chat-container.mode-bar.pos-left .plugin-chat-panel {
        left: -10px !important;
        right: auto !important;
    }
    .plugin-chat-bar-btn {
        padding: 0 14px !important;
        height: 44px !important;
    }
    .plugin-chat-bar-text {
        font-size: 13px !important;
    }
}
