/**
 * BatchPay AI Chat Widget Styles
 */

/* Widget Container */
#batchpay-chat-widget {
    font-family: 'Play', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
}

/* Floating Button */
.chat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00B0E5 0%, #0090c0 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 176, 229, 0.4);
    transition: all 0.3s ease;
}

.chat-widget-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 176, 229, 0.5);
}

.chat-widget-button svg {
    width: 28px;
    height: 28px;
    color: white;
}

/* Chat Panel */
.chat-widget-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    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 */
.chat-widget-header {
    background: linear-gradient(135deg, #00B0E5 0%, #0090c0 100%);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-widget-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-widget-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-avatar svg {
    width: 24px;
    height: 24px;
}

.chat-widget-title {
    font-weight: 600;
    font-size: 16px;
}

.chat-widget-subtitle {
    font-size: 12px;
    opacity: 0.9;
}

.chat-widget-header-actions {
    display: flex;
    gap: 8px;
}

.chat-widget-header-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-widget-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-widget-header-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* Messages Container */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

/* Message Bubbles */
.chat-widget-message {
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.chat-widget-message-user {
    align-self: flex-end;
}

.chat-widget-message-assistant {
    align-self: flex-start;
}

.chat-widget-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
}

.chat-widget-message-user .chat-widget-message-content {
    background: #00B0E5;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-widget-message-assistant .chat-widget-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Source Articles */
.chat-widget-sources {
    margin-top: 8px;
    padding: 8px 12px;
    background: #e8f4f8;
    border-radius: 8px;
    font-size: 12px;
    color: #666;
}

/* Feedback */
.chat-widget-feedback {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #888;
}

.feedback-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.feedback-btn:hover {
    background: #f0f0f0;
}

.feedback-btn svg {
    width: 16px;
    height: 16px;
    color: #888;
}

.feedback-yes:hover {
    border-color: #4caf50;
    color: #4caf50;
}

.feedback-yes:hover svg {
    color: #4caf50;
}

.feedback-no:hover {
    border-color: #f44336;
    color: #f44336;
}

.feedback-no:hover svg {
    color: #f44336;
}

.feedback-thanks {
    color: #4caf50;
    font-style: italic;
}

/* Escalate Button */
.chat-widget-escalate-btn {
    margin-top: 8px;
    padding: 8px 16px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.chat-widget-escalate-btn:hover {
    background: #f57c00;
}

/* Loading Indicator */
.chat-widget-loading .chat-widget-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-widget-typing span {
    width: 8px;
    height: 8px;
    background: #00B0E5;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.chat-widget-typing span:nth-child(1) {
    animation-delay: 0s;
}

.chat-widget-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-widget-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Input Container */
.chat-widget-input-container {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #eee;
}

.chat-widget-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #f8f9fa;
    border-radius: 24px;
    padding: 8px 8px 8px 16px;
    border: 1px solid #e0e0e0;
    transition: border-color 0.2s;
}

.chat-widget-input-wrapper:focus-within {
    border-color: #00B0E5;
}

.chat-widget-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    max-height: 120px;
    padding: 4px 0;
}

.chat-widget-input::placeholder {
    color: #aaa;
}

.chat-widget-send {
    width: 36px;
    height: 36px;
    border: none;
    background: #00B0E5;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-widget-send:hover:not(:disabled) {
    background: #0090c0;
    transform: scale(1.05);
}

.chat-widget-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chat-widget-send svg {
    width: 18px;
    height: 18px;
    color: white;
}

.chat-widget-powered {
    text-align: center;
    font-size: 11px;
    color: #aaa;
    margin-top: 8px;
}

/* Escalation Form */
.chat-widget-escalation-form {
    padding: 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-widget-escalation-form p {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #333;
}

.chat-widget-escalation-input,
.chat-widget-escalation-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.chat-widget-escalation-textarea {
    resize: vertical;
    min-height: 60px;
}

.chat-widget-escalation-input:focus,
.chat-widget-escalation-textarea:focus {
    outline: none;
    border-color: #00B0E5;
}

.chat-widget-escalation-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.chat-widget-escalation-submit,
.chat-widget-escalation-cancel {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-widget-escalation-submit {
    background: #00B0E5;
    color: white;
}

.chat-widget-escalation-submit:hover {
    background: #0090c0;
}

.chat-widget-escalation-cancel {
    background: #f0f0f0;
    color: #666;
}

.chat-widget-escalation-cancel:hover {
    background: #e0e0e0;
}

/* Responsive */
@media (max-width: 480px) {
    #batchpay-chat-widget {
        bottom: 10px;
        right: 10px;
    }

    .chat-widget-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: 0;
        border-radius: 12px;
    }

    .chat-widget-button {
        width: 50px;
        height: 50px;
    }

    .chat-widget-button svg {
        width: 24px;
        height: 24px;
    }
}

/* Scrollbar */
.chat-widget-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-widget-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ========================================
   Tab Content Areas
   ======================================== */
.chat-widget-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========================================
   Tab Navigation
   ======================================== */
.chat-widget-tabs {
    display: flex;
    background: white;
    border-bottom: 1px solid #e0e0e0;
}

.chat-widget-tab {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
    position: relative;
}

.chat-widget-tab:hover {
    color: #00B0E5;
    background: #f8f9fa;
}

.chat-widget-tab.active {
    color: #00B0E5;
}

.chat-widget-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #00B0E5;
    border-radius: 3px 3px 0 0;
}

.chat-widget-tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.chat-widget-tab-content.active {
    display: flex;
}

/* ========================================
   Knowledge Base Styles
   ======================================== */
.kb-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.kb-search-container {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #eee;
}

.kb-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.kb-search:focus {
    outline: none;
    border-color: #00B0E5;
}

.kb-search::placeholder {
    color: #aaa;
}

.kb-articles-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
    background: #f8f9fa;
}

.kb-article-item {
    padding: 14px 16px;
    background: white;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.kb-article-item:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.kb-article-item:last-child {
    margin-bottom: 0;
}

.kb-article-item-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    font-size: 14px;
}

.kb-article-item-summary {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kb-back-btn {
    padding: 8px 12px;
    border: none;
    background: #f0f0f0;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    font-family: inherit;
    font-size: 13px;
    color: #666;
}

.kb-back-btn:hover {
    background: #e0e0e0;
}

.kb-back-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Article View - Header title (used in header bar) */
.kb-article-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Article View - Full page layout */
.kb-article-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px;
    background: #f8f9fa;
}

.kb-article-view-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 12px 0 16px 0;
}

.kb-article-view-content {
    flex: 1;
    overflow-y: auto;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    line-height: 1.6;
    color: #333;
}

.kb-article-view-content h3 {
    color: #00B0E5;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 16px;
}

.kb-article-view-content h3:first-child {
    margin-top: 0;
}

.kb-article-view-content p {
    margin: 0 0 12px 0;
}

.kb-article-view-content ul,
.kb-article-view-content ol {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

.kb-article-view-content li {
    margin-bottom: 6px;
}

/* Legacy content classes (keeping for compatibility) */
.kb-article-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
}

.kb-article-content-inner {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    line-height: 1.6;
    color: #333;
}

.kb-article-content-inner h2,
.kb-article-content-inner h3 {
    color: #00B0E5;
    margin-top: 20px;
    margin-bottom: 10px;
}

.kb-article-content-inner h2:first-child,
.kb-article-content-inner h3:first-child {
    margin-top: 0;
}

.kb-article-content-inner p {
    margin: 0 0 12px 0;
}

.kb-article-content-inner ul,
.kb-article-content-inner ol {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

.kb-article-content-inner li {
    margin-bottom: 6px;
}

/* KB Loading State */
.kb-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #888;
    font-size: 14px;
}

.kb-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #00B0E5;
    border-radius: 50%;
    margin-right: 10px;
    animation: kb-spin 0.8s linear infinite;
}

@keyframes kb-spin {
    to {
        transform: rotate(360deg);
    }
}

/* KB No Results */
.kb-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-size: 14px;
}

.kb-no-results svg {
    width: 48px;
    height: 48px;
    color: #ddd;
    margin-bottom: 12px;
}

/* KB Scrollbar */
.kb-articles-list::-webkit-scrollbar,
.kb-article-content::-webkit-scrollbar,
.kb-article-view-content::-webkit-scrollbar {
    width: 6px;
}

.kb-articles-list::-webkit-scrollbar-track,
.kb-article-content::-webkit-scrollbar-track,
.kb-article-view-content::-webkit-scrollbar-track {
    background: transparent;
}

.kb-articles-list::-webkit-scrollbar-thumb,
.kb-article-content::-webkit-scrollbar-thumb,
.kb-article-view-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.kb-articles-list::-webkit-scrollbar-thumb:hover,
.kb-article-content::-webkit-scrollbar-thumb:hover,
.kb-article-view-content::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}
