/* Chatbot Training Section Styles */
:root {
    --primary-red: #dc3545;
    --primary-red-hover: #c82333;
    --primary-red-light: rgba(220, 53, 69, 0.1);
}

/* Light mode styles */
:root[data-theme="light"] {
    --chatbot-header-bg: #ffffff;
    --chatbot-header-text: #333333;
    --chatbot-header-border: #e0e0e0;
    --chatbot-icon-color: #4169E1;
}

/* Dark mode styles */
:root[data-theme="dark"] {
    --chatbot-header-bg: #1a1a1a;
    --chatbot-header-text: #ffffff;
    --chatbot-header-border: #333333;
    --chatbot-icon-color: #ffffff;
}

.chatbot-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
}

.chatbot-container.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.chatbot-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    font-weight: 500;
}

.chatbot-title i {
    font-size: 16px;
}

.chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chatbot-messages::-webkit-scrollbar {
    display: none;
}

.chatbot-input {
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

.chatbot-input input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.chatbot-input input:focus {
    border-color: var(--primary-color);
}

.chatbot-input button {
    background: var(--primary-color);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.chatbot-input button:hover {
    transform: scale(1.1);
}

.message {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 15px;
    margin: 4px 0;
    font-size: 14px;
    line-height: 1.4;
}

.user-message {
    background: var(--primary-color-light);
    color: var(--primary-color);
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.bot-message {
    background: var(--background-secondary);
    color: var(--text-color);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

[data-theme="dark"] .chatbot-container {
    background: var(--background-color);
}

[data-theme="dark"] .chatbot-input {
    border-top-color: var(--border-color);
}

[data-theme="dark"] .chatbot-input input {
    background: var(--background-secondary);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .bot-message {
    background: var(--background-tertiary);
}

.toggle-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.toggle-group {
    display: flex;
    gap: 8px;
}

@media (max-width: 768px) {
    .toggle-buttons {
        justify-content: space-between;
    }
    
    .toggle-group {
        flex: 1;
        justify-content: flex-start;
    }
}

/* Common button styles */
.toggle-btn, .add-response, .action-btn, .btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    height: 34px;
    line-height: 1;
    white-space: nowrap;
}

.toggle-btn i, .add-response i, .action-btn i {
    font-size: 0.9em;
}

.toggle-btn:hover, .btn:hover {
    background: var(--hover-color);
}

.toggle-btn.active {
    background: #007bff;
    color: white;
}

.add-response {
    background: #28a745;
    color: white;
    margin-top: 0 !important;
}

.add-response:hover {
    background: #218838;
    transform: translateY(-1px);
}

/* Table Styles */
.table-container {
    margin-top: 15px;
    max-width: 100%;
    max-height: 500px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--background-color);
}

.responses-table, .inputs-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9em;
    position: relative;
}

/* Fixed Header Styles */
.responses-table thead, .inputs-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--background-color);
}

.responses-table thead tr, .inputs-table thead tr {
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.responses-table th, .inputs-table th {
    background: var(--background-color);
    font-weight: 500;
    white-space: nowrap;
    padding: 12px 8px;
    position: sticky;
    top: 0;
    z-index: 2;
    border-right: 1px solid var(--border-color);
}

.responses-table th:last-child, 
.inputs-table th:last-child {
    border-right: none;
}

/* Table Body Styles */
.responses-table tbody, .inputs-table tbody {
    position: relative;
}

.responses-table td, .inputs-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    background: var(--background-color);
    word-break: break-word;
    white-space: normal;
    vertical-align: top;
}

.responses-table td:last-child, 
.inputs-table td:last-child {
    border-right: none;
}

/* Column Widths */
.responses-table td:first-child,
.responses-table th:first-child {
    width: 25%;
    max-width: 200px;
}

.responses-table td:nth-child(2),
.responses-table th:nth-child(2) {
    width: auto;
}

.responses-table td:last-child,
.responses-table th:last-child,
.inputs-table td:last-child,
.inputs-table th:last-child {
    width: 80px;
    min-width: 80px;
    text-align: right;
    padding-right: 12px;
}

/* First column in inputs table */
.inputs-table th:first-child,
.inputs-table td:first-child {
    width: 30px;
    min-width: 30px;
    padding-left: 12px;
}

.inputs-table td:nth-child(2),
.inputs-table th:nth-child(2) {
    width: auto;
    max-width: 400px;
}

.inputs-table td:nth-child(3),
.inputs-table th:nth-child(3) {
    width: 150px;
    min-width: 150px;
    white-space: nowrap;
}

/* Add scrollbar styling */
.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--background-color);
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Action buttons in table */
.table-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.btn.edit-response, 
.btn.delete-response, 
.btn.train-from-input {
    padding: 4px 8px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.btn.edit-response:hover {
    background: var(--primary-red-light);
    color: var(--primary-red);
    border-color: var(--primary-red);
}

.btn.delete-response:hover {
    background: var(--primary-red-light);
    color: var(--primary-red);
    border-color: var(--primary-red);
}

.btn.train-from-input:hover {
    background: var(--primary-red-light);
    color: var(--primary-red);
    border-color: var(--primary-red);
}

/* Response Form */
.response-form {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
    display: none;
}

.response-form.show {
    display: block;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.9em;
}

.form-text.text-muted {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    display: block;
}

.keyword-input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--input-background);
    color: var(--text-color);
    font-size: 0.9em;
    margin-bottom: 0.25rem;
}

/* Chatbot Text Editor */
.chatbot-textEditor {
    margin-top: 5px;
    position: relative;
}

.chatbot-textEditor-content {
    min-height: 150px;
    padding: 12px 35px 12px 12px;
    color: var(--text-color);
    font-size: 0.9em;
    line-height: 1.5;
    background: var(--input-background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    outline: none;
}

.chatbot-textEditor-content:focus {
    border-color: var(--primary-red);
}

.chatbot-textEditor .link-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    z-index: 2;
}

.chatbot-textEditor .link-btn:hover {
    background: var(--primary-red-light);
    color: var(--primary-red);
    border-color: var(--primary-red);
}

.chatbot-textEditor .placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
    pointer-events: none;
    position: absolute;
    top: 12px;
    left: 12px;
}

/* Table header with refresh */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.table-header h3 {
    margin: 0;
    font-size: 1em;
    color: var(--text-color);
}

.table-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.refresh-inputs {
    padding: 4px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.delete-selected {
    padding: 4px 8px;
    height: 24px;
    font-size: 0.85em;
    background: var(--primary-red);
    color: white;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.delete-selected:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

/* User Inputs Actions */
.user-inputs-actions {
    display: none !important;
}

/* Empty state and loading */
.empty-state, .loading-spinner {
    text-align: center;
    padding: 30px 15px;
    font-size: 0.9em;
}

.empty-state i, .loading-spinner i {
    font-size: 24px;
    margin-bottom: 10px;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .chatbot-container {
        padding: 10px;
    }

    .toggle-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .toggle-group {
        width: 100%;
        justify-content: space-between;
    }

    .toggle-btn, .add-response {
        flex: 1;
        justify-content: center;
    }

    .responses-table td, .inputs-table td {
        font-size: 0.85em;
        padding: 8px;
    }

    .table-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .table-header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .btn.edit-response, 
    .btn.delete-response, 
    .btn.train-from-input {
        padding: 3px;
        height: 22px;
        width: 22px;
        min-width: 22px;
    }
}

/* Index Page Chatbot Styles */
.index-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.index-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 145px;
    width: 350px;
    height: 500px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
}

.index-chatbot-container.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.index-chatbot-header {
    padding: 15px;
    background-color: var(--chatbot-header-bg);
    border-bottom: 1px solid var(--chatbot-header-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--chatbot-header-text);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.index-chatbot-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    cursor: pointer;
}

.index-chatbot-title i {
    color: var(--chatbot-icon-color);
    animation: botIconFloat 3s ease-in-out infinite;
    transform-origin: center;
}

@keyframes botIconFloat {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-3px) rotate(-5deg);
    }
    75% {
        transform: translateY(2px) rotate(5deg);
    }
}

/* Add cursor animation on hover */
.index-chatbot-title:hover {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' style='fill: %23dc3545;'><text y='20'>🤖</text></svg>") 12 12, auto;
    /* Fallback cursors */
    cursor: -webkit-grab;
    cursor: grab;
}

.index-chatbot-title:active {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' style='fill: %23dc3545;'><text y='20'>👾</text></svg>") 12 12, auto;
    /* Fallback cursors */
    cursor: -webkit-grabbing;
    cursor: grabbing;
}

.index-chatbot-actions button {
    background: none;
    border: none;
    color: var(--chatbot-header-text);
    cursor: pointer;
    padding: 5px;
    transition: opacity 0.3s ease;
}

.index-chatbot-actions button:hover {
    opacity: 0.7;
}

.index-chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.index-chatbot-messages::-webkit-scrollbar {
    display: none;
}

.index-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.index-chatbot-messages::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 3px;
}

.index-message {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 15px;
    margin: 4px 0;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.index-message ul,
.index-message ol {
    margin: 5px 0;
    padding-left: 12px;
}

.index-message li {
    margin: 3px 0;
}

.index-user-message {
    background: #ffe5e5;
    color: #dc3545;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.index-bot-message {
    background: #f8f9fa;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.index-chatbot-input {
    padding: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.index-chatbot-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.index-chatbot-input input:focus {
    border-color: #dc3545;
}

.index-chatbot-input button {
    background: linear-gradient(45deg, #dc3545, #ff6b6b);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.index-chatbot-input button:hover {
    transform: scale(1.1);
}

.index-chatbot-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.index-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.index-quick-reply {
    background: #ffe5e5;
    color: #dc3545;
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    border: none;
    transition: all 0.3s ease;
}

.index-quick-reply:hover {
    background: #dc3545;
    color: white;
}

.index-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 15px;
    align-self: flex-start;
    margin: 5px 0;
}

.index-typing-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: indexTyping 1s infinite;
}

.index-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.index-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes indexTyping {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* Dark mode support for index chatbot */
[data-theme="dark"] .index-chatbot-container {
    background: #1a1a1a;
}

[data-theme="dark"] .index-chatbot-input {
    border-top-color: #333;
}

[data-theme="dark"] .index-chatbot-input input {
    background: #2d2d2d;
    border-color: #333;
    color: #fff;
}

[data-theme="dark"] .index-bot-message {
    background: #2d2d2d;
    color: #fff;
}

[data-theme="dark"] .index-typing-indicator {
    background: #2d2d2d;
}

/* Add these styles to your chatbot.css */
.dots-loading {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-left: 8px;
}

.dots-loading .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-color, #fff);
    opacity: 0.2;
}

.dots-loading .dot:nth-child(1) {
    animation: blinkDot 4s infinite 0s;
    background-color: #ff3333; /* Red */
}

.dots-loading .dot:nth-child(2) {
    animation: blinkDot 4s infinite 1s;
    background-color: #4169E1; /* Blue */
}

.dots-loading .dot:nth-child(3) {
    animation: blinkDot 4s infinite 2s;
    background-color: #28a745; /* Green */
}

.dots-loading .dot:nth-child(4) {
    animation: blinkDot 4s infinite 3s;
    background-color: #ffc107; /* Yellow */
}

@keyframes blinkDot {
    0%, 15% { opacity: 1; }
    20%, 100% { opacity: 0.2; }
} 


.index-quick-reply-button {
    background-color: #ffe5e5;
    color: #dc3545 !important;
    border: 1px solid #6f686866;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.2s;
}

/* Mobile Styles for Very Small Screens */
@media screen and (max-width: 374px) {
    .index-chatbot-container {
        width: 310px;  /* Reduced from 300px */
        left: -3px;   /* Reduced side spacing */
    }

    .index-chatbot-header {
        padding: 10px;  /* Slightly reduced padding */
    }

    .index-message {
        padding: 8px 12px;  /* Slightly reduced padding */
        margin: 4px 8px;    /* Slightly reduced margins */
    }

    .index-quick-reply-button {
        padding: 6px 12px;  /* Slightly reduced padding */
        margin: 4px;        /* Reduced margin */
        font-size: 12px;    /* Smaller font */
    }

    .index-chatbot-input {
        padding: 8px;      /* Reduced padding */
    }

    #userInput {
        font-size: 14px;  /* Slightly smaller font */
    }
}

.index-message-text {
    width: 100%;
}

/* Ensure bullet points and numbers stay within the bubble */
.index-message-text ul,
.index-message-text ol {
    margin: 5px 0;
    padding-left: 12px;
    list-style-position: inside;
}

.index-message-text li {
    margin: 3px 0;
    text-indent: -12px;
    padding-left: 12px;
}

/* Handle numbered lists specifically */
.index-message-text ol {
    counter-reset: item;
}

.index-message-text ol li {
    display: block;
}

.index-message-text ol li:before {
    content: counter(item) ". ";
    counter-increment: item;
    width: 12px;
    display: inline-block;
    text-align: right;
    margin-right: 3px;
}

