/**
 * Farmers Bounty Chatbot Styles
 * Three-panel layout with conversation history
 * Standalone-ready: all classes prefixed with fb-
 *
 * @since      1.1.0
 * @updated    4.4.0  Three-panel layout, history sidebar, welcome state
 */

/* ══════════════════════════════════════════════════════════════
   THREE-PANEL CONTAINER
   ══════════════════════════════════════════════════════════════ */

.fb-chatbot-container {
    max-width: 1100px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(76, 110, 71, 0.15);
    background: #ffffff;
}

.fb-chatbot--three-panel {
    display: flex;
    min-height: 600px;
}

/* ══════════════════════════════════════════════════════════════
   LEFT PANEL: CONVERSATION HISTORY
   ══════════════════════════════════════════════════════════════ */

.fb-chatbot-history-panel {
    width: 240px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e5ebe3;
    background: #f8faf7;
}

.fb-history-header {
    padding: 12px;
}

.fb-new-chat-button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: linear-gradient(135deg, #6b8e65 0%, #88a883 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.fb-new-chat-button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.fb-new-chat-button .fb-icon {
    font-size: 16px;
}

/* Search */
.fb-history-search {
    padding: 0 12px 10px;
}

.fb-history-search-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #d4e1d1;
    border-radius: 6px;
    font-size: 12px;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.fb-history-search-input:focus {
    outline: none;
    border-color: #6b8e65;
}

/* Conversation List */
.fb-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.fb-history-list::-webkit-scrollbar {
    width: 4px;
}

.fb-history-list::-webkit-scrollbar-thumb {
    background: #c5d5c0;
    border-radius: 2px;
}

.fb-history-group-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b8e65;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px 4px;
}

.fb-history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
    position: relative;
}

.fb-history-item:hover {
    background: rgba(108, 142, 101, 0.08);
}

.fb-history-item.active {
    background: rgba(108, 142, 101, 0.12);
    border-left-color: #6b8e65;
}

.fb-history-item-icon {
    font-size: 12px;
    color: #9bb096;
    flex-shrink: 0;
}

.fb-history-item.active .fb-history-item-icon {
    color: #6b8e65;
}

.fb-history-item-info {
    flex: 1;
    min-width: 0;
}

.fb-history-item-title {
    font-size: 13px;
    color: #2d4028;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.fb-history-item.active .fb-history-item-title {
    font-weight: 600;
}

.fb-history-item-meta {
    font-size: 10px;
    color: #9bb096;
    margin-top: 1px;
}

/* Context menu trigger */
.fb-history-item-menu {
    opacity: 0;
    padding: 2px 6px;
    border: none;
    background: transparent;
    color: #9bb096;
    cursor: pointer;
    font-size: 14px;
    border-radius: 4px;
    transition: opacity 0.15s, background 0.15s;
    flex-shrink: 0;
}

.fb-history-item:hover .fb-history-item-menu {
    opacity: 1;
}

.fb-history-item-menu:hover {
    background: rgba(0,0,0,0.06);
}

/* Dropdown context menu */
.fb-context-menu {
    position: absolute;
    right: 8px;
    top: 100%;
    z-index: 100;
    background: #fff;
    border: 1px solid #e5ebe3;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 4px 0;
    min-width: 160px;
}

.fb-context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: none;
    font-size: 13px;
    color: #2d4028;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s;
}

.fb-context-menu-item:hover {
    background: #f0f4ef;
}

.fb-context-menu-item.fb-danger {
    color: #c0392b;
}

.fb-context-menu-item.fb-danger:hover {
    background: #fdf0ef;
}

.fb-context-menu-divider {
    height: 1px;
    background: #e5ebe3;
    margin: 4px 0;
}

/* Empty state in history */
.fb-history-empty {
    text-align: center;
    padding: 40px 16px;
    color: #9bb096;
}

.fb-history-empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.fb-history-empty-text {
    font-size: 12px;
    line-height: 1.4;
}

/* History footer */
.fb-history-footer {
    padding: 8px 12px;
    border-top: 1px solid #e5ebe3;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.fb-history-action {
    padding: 6px 10px;
    border: 1px solid #d4e1d1;
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.fb-history-action:hover {
    background: #f0f4ef;
    border-color: #6b8e65;
}

/* ══════════════════════════════════════════════════════════════
   CENTER PANEL: CHAT AREA
   ══════════════════════════════════════════════════════════════ */

.fb-chatbot-chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header */
.fb-chatbot-header {
    background: linear-gradient(135deg, #4c6e47 0%, #6b8e65 100%);
    color: #ffffff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.fb-chatbot-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fb-chatbot-header h3::before {
    content: "🌱";
    font-size: 20px;
}

.fb-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fb-conversation-title {
    font-size: 13px;
    opacity: 0.85;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fb-chatbot-status {
    display: flex;
    gap: 6px;
    align-items: center;
}

.fb-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #90EE90;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.fb-status-text {
    font-size: 12px;
    opacity: 0.9;
}

.fb-chatbot-consent-wrapper {
    padding: 10px 16px;
    border-bottom: 1px solid #e5ebe3;
}

/* Messages Area */
.fb-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafbf9;
    background-image:
        linear-gradient(rgba(108, 142, 101, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(108, 142, 101, 0.02) 1px, transparent 1px);
    background-size: 20px 20px;
}

.fb-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.fb-chatbot-messages::-webkit-scrollbar-thumb {
    background: #c5d5c0;
    border-radius: 3px;
}

/* Individual Messages */
.fb-chat-message {
    margin-bottom: 16px;
    display: flex;
    animation: messageSlide 0.3s ease-out;
}

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

.fb-chat-message.user {
    justify-content: flex-end;
}

.fb-chat-message.bot {
    justify-content: flex-start;
}

.fb-message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    position: relative;
}

.fb-chat-message.user .fb-message-bubble {
    background: linear-gradient(135deg, #6b8e65 0%, #88a883 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.fb-chat-message.bot .fb-message-bubble {
    background: #ffffff;
    color: #2d4028;
    border: 1px solid #d4e1d1;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(76, 110, 71, 0.08);
}

.fb-message-content {
    line-height: 1.55;
    font-size: 14px;
}

.fb-message-content p {
    margin: 0 0 8px 0;
}

.fb-message-content p:last-child {
    margin-bottom: 0;
}

.fb-message-content ul,
.fb-message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.fb-message-content li {
    margin-bottom: 4px;
}

.fb-message-content code {
    background: rgba(108, 142, 101, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.fb-message-meta {
    font-size: 10px;
    margin-top: 6px;
    opacity: 0.7;
}

.fb-chat-message.user .fb-message-meta {
    color: rgba(255, 255, 255, 0.8);
    text-align: right;
}

.fb-chat-message.bot .fb-message-meta {
    color: #6b8e65;
}

/* Sources */
.fb-message-sources {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(108, 142, 101, 0.2);
}

.fb-sources-title {
    font-size: 11px;
    font-weight: 600;
    color: #4c6e47;
    margin-bottom: 6px;
}

.fb-source-link {
    display: block;
    font-size: 11px;
    color: #6b8e65;
    text-decoration: none;
    margin-bottom: 3px;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(108, 142, 101, 0.05);
    transition: background 0.2s;
}

.fb-source-link:hover {
    background: rgba(108, 142, 101, 0.15);
    color: #4c6e47;
}

.fb-source-link::before {
    content: "🔗 ";
}

/* Typing Indicator */
.fb-typing-indicator {
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #d4e1d1;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: inline-block;
}

.fb-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.fb-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6b8e65;
    animation: typingBounce 1.4s infinite;
}

.fb-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.fb-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-7px); }
}

/* Input Area (enhanced) */
.fb-chatbot-input-area {
    padding: 16px 20px;
    background: #ffffff;
    border-top: 2px solid #e5ebe3;
}

.fb-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.fb-input-icon {
    padding: 10px 0 10px 12px;
    font-size: 16px;
    color: #9bb096;
    flex-shrink: 0;
}

.fb-chatbot-textarea {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    padding: 11px 14px;
    border: 2px solid #d4e1d1;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s;
    background: #fafbf9;
    box-sizing: border-box;
}

.fb-chatbot-textarea:focus {
    outline: none;
    border-color: #6b8e65;
    background: #ffffff;
}

.fb-chatbot-textarea::placeholder {
    color: #9bb096;
}

.fb-send-button {
    min-width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #6b8e65 0%, #88a883 100%);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(76, 110, 71, 0.2);
    flex-shrink: 0;
}

.fb-send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(76, 110, 71, 0.3);
}

.fb-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #9bb096;
}

.fb-send-button::before {
    content: "➤";
}

.fb-input-hint {
    font-size: 11px;
    color: #b0c4a8;
    text-align: center;
    margin-top: 6px;
}

/* Welcome / Empty State */
.fb-chatbot-empty-state {
    text-align: center;
    padding: 60px 24px;
    color: #6b8e65;
}

.fb-empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.fb-empty-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #4c6e47;
}

.fb-empty-description {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 24px;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.fb-suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

.fb-suggestion-chip {
    background: #ffffff;
    border: 1px solid #d4e1d1;
    color: #6b8e65;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.fb-suggestion-chip:hover {
    background: #6b8e65;
    color: #ffffff;
    border-color: #6b8e65;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 110, 71, 0.2);
}

/* Error */
.fb-chat-error {
    background: #fee;
    border: 1px solid #fcc;
    color: #a33;
    padding: 10px 14px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 13px;
}

.fb-chat-error::before {
    content: "⚠️ ";
}

/* ══════════════════════════════════════════════════════════════
   RIGHT PANEL: QUICK ACTIONS & CONTEXT
   ══════════════════════════════════════════════════════════════ */

.fb-chatbot-actions-panel {
    width: 240px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e5ebe3;
    background: #f8faf7;
    overflow-y: auto;
    padding: 16px;
}

.fb-actions-section h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #4c6e47;
}

.fb-actions-divider {
    height: 1px;
    background: #e5ebe3;
    margin: 14px 0;
}

/* Quick Actions */
.fb-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fb-quick-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #e5ebe3;
    border-radius: 8px;
    font-size: 13px;
    color: #2d4028;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    width: 100%;
}

.fb-quick-action:hover {
    border-color: #6b8e65;
    background: #f0f4ef;
}

.fb-qa-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.fb-qa-text {
    flex: 1;
}

/* Suggestions in right panel */
.fb-suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fb-suggestions-list .fb-suggestion-chip {
    width: 100%;
    text-align: left;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
}

/* Help section */
.fb-help-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.fb-help-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b8e65;
    padding: 3px 0;
}

.fb-help-list li span {
    font-size: 13px;
}

.fb-actions-footer {
    margin-top: auto;
    padding-top: 12px;
    font-size: 11px;
    color: #9bb096;
    text-align: center;
}

/* Toast notification */
.fb-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: #4c6e47;
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10000;
    animation: toastIn 0.3s ease-out;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
    .fb-chatbot--three-panel {
        flex-direction: column;
        height: auto !important;
    }

    .fb-chatbot-history-panel {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #e5ebe3;
    }

    .fb-chatbot-actions-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid #e5ebe3;
        max-height: 300px;
    }

    .fb-chatbot-messages {
        min-height: 300px;
    }
}

@media (max-width: 600px) {
    .fb-chatbot-container {
        margin: 8px;
        border-radius: 8px;
    }

    .fb-chatbot-history-panel,
    .fb-chatbot-actions-panel {
        display: none;
    }

    .fb-message-bubble {
        max-width: 90%;
    }
}
