/* Entel Chatbots - Component Styles */

/* Typing Indicator */
.typing-indicator .message-bubble {
    padding: 16px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: #999;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Thinking messages */
.thinking-text {
    color: #666;
    font-style: italic;
    font-size: 0.85em;
    display: none;
    margin-top: 6px;
    text-align: center;
    min-height: 1.2em;
    line-height: 1.2;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.thinking-text.fade-in {
    opacity: 1;
    transform: translateY(0);
}

.thinking-text.fade-out {
    opacity: 0;
    transform: translateY(-2px);
}

.typing-indicator .message-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* Error & Info Messages */
.message.error .message-bubble {
    background-color: #dc3232;
    color: white;
}

.message.info .message-bubble {
    background-color: #46b450;
    color: white;
    font-size: 14px;
    opacity: 0.9;
}

/* Enhancement Feedback */
.enhancement-feedback {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    margin-bottom: 16px;
    border-radius: 4px;
    font-size: 14px;
    color: #856404;
}

.enhancement-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ffc107;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Icon-sized Spinners */
.icon-spinner-md {
    width: 20px;
    height: 20px;
    border: 2px solid #f0f0f0;
    border-top: 2px solid var(--entel-loading-spinner-color, #2271b1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin: 0;
}

.icon-spinner-lg {
    width: 28px;
    height: 28px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid var(--entel-loading-spinner-color, #2271b1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin: 0;
}

/* Enhanced Messages */
.message.enhanced {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.message.enhanced .message-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.message.enhanced .message-bubble.original {
    background-color: #e9ecef;
    margin-bottom: 8px;
}

.message.enhanced .message-bubble.enhanced-version {
    background-color: #d1ecf1;
    border-left: 3px solid #bee5eb;
}

/* Loading States */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 40px 20px;
    color: #666;
    font-size: 14px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 10;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid var(--entel-loading-spinner-color, #2271b1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

.chat-loading p {
    margin: 0;
    color: #666;
}

/* Tooltips */
.chatbot-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    pointer-events: none;
    z-index: 999999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chatbot-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.chatbot-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* History Modal */
.chatbot-history-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.history-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.history-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f9f9f9;
}

.history-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.history-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.history-modal-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.history-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Inline Chat History View */
.chat-history-view {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-history-search {
    position: relative;
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #ffffff;
}

.history-search-input {
    width: 100%;
    padding: 10px 56px 10px 16px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background: #fafafa;
    font-family: inherit;
}

.history-search-input:focus {
    border-color: #2271b1;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.1);
}

.history-search-input::placeholder {
    color: #999;
    font-style: italic;
}

.chat-history-search .search-icon {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
    opacity: 0.6;
    transition: all 0.2s ease;
    width: 16px;
    height: 16px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-search-input:focus ~ .search-icon {
    color: #2271b1;
    opacity: 0.8;
}

.chat-history-view .history-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chat-history-view .history-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.chat-history-view .history-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-conversation {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: #ffffff;
}

.history-conversation:hover {
    border-color: #2271b1;
    background-color: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.history-conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.history-conversation-date {
    font-size: 11px;
    color: #666;
    font-weight: 500;
}

.history-conversation-meta {
    font-size: 10px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-delete-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    color: #dc3545;
    margin-left: 8px;
}

.history-conversation:hover .history-delete-btn {
    opacity: 0.7;
}

.history-delete-btn:hover {
    opacity: 1 !important;
    background-color: rgba(220, 53, 69, 0.1);
    transform: scale(1.1);
}

.history-delete-btn:focus {
    opacity: 1;
    outline: 2px solid #dc3545;
    outline-offset: 2px;
}

.history-delete-btn .trash-icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
}

.history-message-count {
    background: #e9ecef;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    min-width: 20px;
    text-align: center;
}

.history-conversation-preview {
    font-size: 13px;
    color: #444;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    margin: 0;
}

.history-retention-info {
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    margin-bottom: 12px;
    text-align: center;
}

.history-retention-info small {
    color: #6c757d;
    font-size: 11px;
    font-weight: 500;
}

/* Delete Confirmation Modal */
.entel-delete-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    box-sizing: border-box;
}

.entel-delete-modal {
    background: #ffffff;
    border-radius: 8px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: entelModalSlideIn 0.2s ease-out;
}

@keyframes entelModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.entel-delete-modal-header {
    padding: 20px 20px 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.entel-delete-modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.entel-delete-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #666;
    transition: all 0.2s;
}

.entel-delete-modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

.entel-delete-modal-content {
    padding: 20px;
}

.entel-delete-modal-content p {
    margin: 0 0 12px 0;
    color: #555;
    line-height: 1.5;
}

.entel-delete-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 12px;
    color: #856404;
    font-size: 14px;
}

.entel-delete-modal-footer {
    padding: 0 20px 20px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.entel-delete-cancel-btn,
.entel-delete-confirm-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.entel-delete-cancel-btn {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.entel-delete-cancel-btn:hover {
    background: #e9ecef;
}

.entel-delete-confirm-btn {
    background: #dc3545;
    color: white;
}

.entel-delete-confirm-btn:hover {
    background: #c82333;
}

/* Toast Notifications - Ultra-High Specificity to Override Themes */
html body #entel-toast-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 999999 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    max-width: 400px !important;
    pointer-events: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    letter-spacing: -0.02em !important;
}

html body #entel-toast-container .entel-toast {
    pointer-events: auto !important;
    background: #ffffff !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    padding: 16px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 12px !important;
    border-left: 4px solid #2196F3 !important;
    min-width: 300px !important;
    max-width: 400px !important;
    transform: translateX(100%) !important;
    opacity: 0 !important;
    transition: all 0.3s ease-in-out !important;
    cursor: pointer !important;
    position: relative !important;
    overflow: hidden !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: #333333 !important;
    text-align: left !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    width: auto !important;
    height: auto !important;
    float: none !important;
    clear: none !important;
}

html body #entel-toast-container .entel-toast.entel-toast-show {
    transform: translateX(0) !important;
    opacity: 1 !important;
}

html body #entel-toast-container .entel-toast.entel-toast-hide {
    transform: translateX(100%) !important;
    opacity: 0 !important;
}

html body #entel-toast-container .entel-toast .entel-toast-content {
    display: flex !important;
    align-items: flex-start !important;
    gap: 10px !important;
    flex: 1 !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    text-align: left !important;
    width: auto !important;
    height: auto !important;
    float: none !important;
    clear: none !important;
}

html body #entel-toast-container .entel-toast .entel-toast-icon {
    flex-shrink: 0 !important;
    font-size: 18px !important;
    margin-top: 1px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    text-align: left !important;
    width: auto !important;
    height: auto !important;
    float: none !important;
    clear: none !important;
    line-height: 1 !important;
}

html body #entel-toast-container .entel-toast .entel-toast-message {
    flex: 1 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    word-wrap: break-word !important;
    color: #333333 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    text-align: left !important;
    width: auto !important;
    height: auto !important;
    float: none !important;
    clear: none !important;
    font-family: inherit !important;
    font-weight: normal !important;
}

html body #entel-toast-container .entel-toast .entel-toast-close {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    opacity: 0.5 !important;
    transition: opacity 0.2s ease !important;
    flex-shrink: 0 !important;
    font-size: 16px !important;
    line-height: 1 !important;
    width: auto !important;
    height: auto !important;
    min-width: 16px !important;
    min-height: 16px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    position: relative !important;
    top: 1px !important;
    right: 0 !important;
    left: auto !important;
    bottom: auto !important;
    float: none !important;
    clear: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #666666 !important;
    text-decoration: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

html body #entel-toast-container .entel-toast .entel-toast-close:hover {
    opacity: 1 !important;
    background: rgba(0, 0, 0, 0.05) !important;
    border-radius: 2px !important;
}

html body #entel-toast-container .entel-toast .entel-toast-close .entel-chatbot-icon {
    font-size: 14px !important;
    width: 14px !important;
    height: 14px !important;
    background-color: currentColor !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    display: block !important;
    float: none !important;
    clear: none !important;
}

/* Toast Type Colors - Using Agent-Specific Admin Settings Variables */
html body #entel-toast-container .entel-toast[data-agent-id] {
    border-left-color: var(--entel-primary-color, #2196F3) !important;
}

/* Success Toast - Uses Enhancement Success Colors from Admin Settings */
html body #entel-toast-container .entel-toast-success {
    border-left-color: var(--entel-enhancement-success-border, #c3e6cb) !important;
    background: var(--entel-enhancement-success-bg, #d4edda) !important;
    color: var(--entel-enhancement-success-text, #155724) !important;
}

html body #entel-toast-container .entel-toast-success .entel-toast-icon {
    color: var(--entel-enhancement-success-text, #155724) !important;
}

html body #entel-toast-container .entel-toast-success .entel-toast-message {
    color: var(--entel-enhancement-success-text, #155724) !important;
}

/* Error Toast - Uses Enhancement Error Colors from Admin Settings */
html body #entel-toast-container .entel-toast-error {
    border-left-color: var(--entel-enhancement-error-border, #f5c6cb) !important;
    background: var(--entel-enhancement-error-bg, #f8d7da) !important;
    color: var(--entel-enhancement-error-text, #721c24) !important;
}

html body #entel-toast-container .entel-toast-error .entel-toast-icon {
    color: var(--entel-enhancement-error-text, #721c24) !important;
}

html body #entel-toast-container .entel-toast-error .entel-toast-message {
    color: var(--entel-enhancement-error-text, #721c24) !important;
}

/* Warning Toast - Uses Enhancement Gradient Colors for Visual Distinction */
html body #entel-toast-container .entel-toast-warning {
    border-left-color: var(--entel-enhancement-gradient-start, #ff6b35) !important;
    background: #fff3cd !important;
    color: #856404 !important;
}

html body #entel-toast-container .entel-toast-warning .entel-toast-icon {
    color: var(--entel-enhancement-gradient-start, #ff6b35) !important;
}

html body #entel-toast-container .entel-toast-warning .entel-toast-message {
    color: #856404 !important;
}

/* Info Toast - Uses Message Info Colors from Admin Settings */
html body #entel-toast-container .entel-toast-info {
    border-left-color: var(--entel-message-info-border, #c7d2fe) !important;
    background: var(--entel-message-info-bg, #f0f6fc) !important;
    color: var(--entel-message-info-text, #0969da) !important;
}

html body #entel-toast-container .entel-toast-info .entel-toast-icon {
    color: var(--entel-message-info-text, #0969da) !important;
}

html body #entel-toast-container .entel-toast-info .entel-toast-message {
    color: var(--entel-message-info-text, #0969da) !important;
}

/* Hover Effects with Ultra-High Specificity */
html body #entel-toast-container .entel-toast:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2) !important;
    transform: translateY(-1px) !important;
}

html body #entel-toast-container .entel-toast.entel-toast-show:hover {
    transform: translateX(0) translateY(-1px) !important;
}

/* Responsive Toast with Ultra-High Specificity */
@media (max-width: 768px) {
    html body #entel-toast-container {
        bottom: 10px !important;
        right: 10px !important;
        left: 10px !important;
        max-width: none !important;
        width: auto !important;
    }

    html body #entel-toast-container .entel-toast {
        min-width: 0 !important;
        max-width: none !important;
        width: auto !important;
    }
}
