/* =====================================================
   AI CHATBOT PAGE - Modern Design
   ===================================================== */

/* Page Layout */
.ai-chatbot-page {
    grid-row: 2;
    display: flex;
    flex-direction: column;
    background: var(--slate-50);
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100vh - var(--header-height));
}

/* Header */
.ai-chatbot-header {
    padding: 32px 40px;
    background: linear-gradient(135deg, var(--white) 0%, var(--slate-50) 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.ai-chatbot-header .header-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.ai-chatbot-header .header-icon {
    width: 64px;
    height: 64px;
    background: var(--indigo-gradient);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px var(--indigo-shadow);
}

.ai-chatbot-header .header-icon i {
    font-size: 32px;
    color: var(--white);
}

.ai-chatbot-header .header-text h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 4px 0;
}

.ai-chatbot-header .header-text p {
    font-size: 15px;
    color: var(--text-secondary);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ai-master-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-medium);
}

.ai-master-toggle .toggle-label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

/* Loading State */
.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 16px;
    color: var(--text-secondary);
}

.ai-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--indigo-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* No Access State */
.ai-no-access {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 40px 20px;
}

.no-access-content {
    max-width: 520px;
    text-align: center;
    padding: 48px 40px;
    background: var(--white);
    border-radius: 24px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.no-access-icon {
    width: 88px;
    height: 88px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-access-icon i {
    font-size: 40px;
    color: #dc2626;
}

.no-access-content h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 12px 0;
}

.no-access-content > p {
    font-size: 15px;
    color: #6b7280;
    line-height: 1.6;
    margin: 0 0 32px 0;
}

.no-access-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 12px;
    margin-bottom: 32px;
}

.no-access-features .feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--white);
    border-radius: 8px;
    font-size: 14px;
    color: #374151;
    transition: transform 0.2s ease;
}

.no-access-features .feature-item:hover {
    transform: translateX(4px);
}

.no-access-features .feature-item i {
    font-size: 20px;
    color: var(--indigo-500);
}

.btn-upgrade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 32px;
    background: var(--indigo-gradient);
    color: var(--white);
    font-size: 15px;
    font-weight: 600;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px var(--indigo-shadow);
}

.btn-upgrade:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--indigo-shadow);
    color: var(--white);
}

.btn-upgrade i {
    font-size: 18px;
}

/* Main Content */
.ai-chatbot-content {
    padding: 32px 40px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.ai-content-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 32px;
}

/* Settings Column */
.ai-settings-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Cards */
.ai-card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.ai-card:hover {
    box-shadow: 0 4px 16px var(--shadow-heavy);
}

.ai-card .card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.ai-card .card-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #f0f0ff 0%, #e8e8ff 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-card .card-icon i {
    font-size: 22px;
    color: var(--indigo-500);
}

.ai-card .card-title {
    flex: 1;
}

.ai-card .card-title h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 2px 0;
}

.ai-card .card-title p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.ai-card .card-body {
    padding: 24px;
}

/* App Checkboxes */
.app-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.app-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--slate-50);
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.app-checkbox-item:hover {
    background: #f0f0ff;
    border-color: var(--indigo-200);
}

.app-checkbox-item.checked {
    background: var(--indigo-50);
    border-color: var(--indigo-500);
}

.app-checkbox-item input {
    display: none;
}

.app-checkbox-item .app-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
}

.app-checkbox-item .app-icon.whatsapp {
    background: var(--whatsapp-green);
}

.app-checkbox-item .app-icon.instagram {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}

.app-checkbox-item .app-icon.live-chat {
    background: var(--dark-primary);
}

.app-checkbox-item .app-icon.facebook {
    background: var(--facebook-blue);
}

.app-checkbox-item .app-icon.telegram {
    background: var(--telegram-blue);
}

.app-checkbox-item .app-name {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.app-checkbox-item .app-name .app-slug {
    font-size: 12px;
    font-weight: 400;
    color: #9ca3af;
}

.app-checkbox-item .check-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    transition: all 0.2s ease;
}

.app-checkbox-item.checked .check-icon {
    background: var(--indigo-500);
    border-color: var(--indigo-500);
    color: var(--white);
}

.app-checkbox-item .check-icon i {
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.app-checkbox-item.checked .check-icon i {
    opacity: 1;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    color: #1f2937;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--indigo-500);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    color: #1f2937;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.2s ease;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--indigo-500);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-hint {
    display: block;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 6px;
}

/* Setting Item */
.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid #f0f0f0;
}

.setting-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.setting-item:first-child {
    padding-top: 0;
}

.setting-info {
    flex: 1;
}

.setting-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 2px;
}

.setting-description {
    font-size: 13px;
    color: #9ca3af;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e5e7eb;
    transition: .3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--white);
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--indigo-gradient);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(22px);
}

/* Multilang Inputs */
.multilang-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lang-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-badge {
    width: 36px;
    height: 36px;
    background: #f3f4f6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    flex-shrink: 0;
}

.lang-input .form-control {
    flex: 1;
}

/* Temperature Slider */
.temperature-slider {
    display: flex;
    align-items: center;
    gap: 16px;
}

.temperature-slider input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    outline: none;
}

.temperature-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--indigo-500);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

.temperature-value {
    min-width: 40px;
    padding: 6px 12px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--indigo-500);
    text-align: center;
}

/* Retrain Section */
.retrain-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.btn-retrain {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--yellow-100);
    color: #92400e;
    border: 1px solid #fcd34d;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-retrain:hover {
    background: var(--yellow-200);
}

.btn-retrain:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-retrain i {
    font-size: 18px;
}

.retrain-result {
    margin-top: 12px;
}

.retrain-result .alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.retrain-result .alert-success {
    background: var(--emerald-100);
    color: #065f46;
    border: 1px solid var(--emerald-200);
}

.retrain-result .alert-error {
    background: var(--red-100);
    color: #991b1b;
    border: 1px solid var(--red-200);
}

/* AI Balance Banner */
.ai-balance-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 16px;
}

.ai-balance-banner .balance-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-balance-banner .balance-icon {
    font-size: 20px;
    color: #43a047;
}

.ai-balance-banner .balance-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.ai-balance-banner .balance-number {
    font-size: 15px;
    font-weight: 700;
    color: #43a047;
}

.ai-balance-banner.balance-low .balance-number {
    color: #f57c00;
}

.ai-balance-banner.balance-empty .balance-number {
    color: #e53935;
}

.ai-balance-banner .btn-add-balance {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    background: #43a047;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.ai-balance-banner .btn-add-balance:hover {
    background: #388e3c;
    color: #fff;
}

/* Save Section */
.ai-save-section {
    padding: 24px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.btn-save {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    background: var(--indigo-gradient);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.btn-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-save i {
    font-size: 20px;
}

/* Test Column */
.ai-test-column {
    position: sticky;
    top: 0;
}

.ai-test-card {
    height: calc(100vh - var(--header-height) - 200px);
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.ai-test-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.btn-clear-test {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear-test:hover {
    background: var(--red-100);
    color: var(--red-600);
}

/* Test Chat Container */
.test-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.test-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.test-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    text-align: center;
    padding: 40px;
}

.test-empty-state i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.test-empty-state p {
    font-size: 14px;
    margin: 0;
}

/* Test Messages */
.test-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.test-message.user {
    align-self: flex-end;
    background: var(--indigo-gradient);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.test-message.ai {
    align-self: flex-start;
    background: #f3f4f6;
    color: #374151;
    border-bottom-left-radius: 4px;
}

.test-message.system {
    align-self: center;
    background: var(--yellow-100);
    color: #92400e;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 8px;
}

.test-message.loading {
    align-self: flex-start;
    background: #f3f4f6;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 8px;
}

.test-message.loading::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

/* Test Input */
.test-input-container {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}

.test-input-container .form-control {
    flex: 1;
    background: var(--white);
}

.btn-send-test {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--indigo-gradient);
    color: var(--white);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-send-test:hover {
    transform: scale(1.05);
}

.btn-send-test:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-send-test i {
    font-size: 20px;
}

/* Responsive */
@media (max-width: 1200px) {
    .ai-content-grid {
        grid-template-columns: 1fr;
    }

    .ai-test-column {
        position: static;
    }

    .ai-test-card {
        height: 500px;
    }
}

@media (max-width: 768px) {
    .ai-chatbot-header {
        padding: 24px 20px;
    }

    .ai-chatbot-header .header-icon {
        width: 48px;
        height: 48px;
    }

    .ai-chatbot-header .header-icon i {
        font-size: 24px;
    }

    .ai-chatbot-header .header-text h1 {
        font-size: 22px;
    }

    .ai-chatbot-content {
        padding: 20px;
    }

    .ai-card .card-header {
        padding: 16px 20px;
    }

    .ai-card .card-body {
        padding: 20px;
    }

    .app-checkboxes {
        flex-direction: column;
    }

    .app-checkbox-item {
        width: 100%;
    }
}

@media (min-width:780px) {
    .ai-chatbot-page {
        grid-column: 2 / -1;
    }
}

/* =====================================================
   PDF TRAINING STYLES
   ===================================================== */

/* PDF Icon */
.card-icon.pdf-icon {
    background: linear-gradient(135deg, var(--red-500) 0%, var(--red-600) 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.card-icon.pdf-icon i {
    color: var(--white);
}

/* Upload Area */
.pdf-upload-area {
    border: 2px dashed #e5e7eb;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafafa;
    margin-bottom: 24px;
}

.pdf-upload-area:hover {
    border-color: var(--indigo-500);
    background: rgba(99, 102, 241, 0.02);
}

.pdf-upload-area.dragover {
    border-color: var(--indigo-500);
    background: rgba(99, 102, 241, 0.05);
    transform: scale(1.01);
}

.pdf-upload-area .upload-content i {
    font-size: 48px;
    color: #9ca3af;
    margin-bottom: 16px;
}

.pdf-upload-area:hover .upload-content i {
    color: var(--indigo-500);
}

.pdf-upload-area .upload-text {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 4px 0;
}

.pdf-upload-area .upload-hint {
    font-size: 14px;
    color: #9ca3af;
    margin: 0 0 8px 0;
}

.pdf-upload-area .upload-limit {
    font-size: 12px;
    color: #d1d5db;
}

/* Upload Progress */
.pdf-upload-progress {
    background: #f9fafb;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.pdf-upload-progress .progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.pdf-upload-progress .progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.pdf-upload-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--indigo-500) 0%, var(--indigo-600) 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.pdf-upload-progress .progress-files {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pdf-upload-progress .progress-file {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6b7280;
}

.pdf-upload-progress .progress-file i {
    color: var(--red-500);
}

/* PDF List */
.pdf-list-section {
    margin-top: 24px;
}

.pdf-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.pdf-list-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

.btn-refresh-pdfs {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-refresh-pdfs:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
}

.pdf-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.pdf-list-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: #9ca3af;
}

.pdf-list-empty {
    text-align: center;
    padding: 32px 20px;
    color: #9ca3af;
}

.pdf-list-empty i {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
}

.pdf-list-empty p {
    margin: 0;
    font-size: 14px;
}

/* PDF Item */
.pdf-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.pdf-item:hover {
    background: #f3f4f6;
}

.pdf-item .pdf-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    flex-shrink: 0;
}

.pdf-item .pdf-icon i {
    font-size: 20px;
    color: var(--red-500);
}

.pdf-item .pdf-info {
    flex: 1;
    min-width: 0;
}

.pdf-item .pdf-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-item .pdf-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 2px;
}

.pdf-item .pdf-chunks,
.pdf-item .pdf-date {
    font-size: 12px;
    color: #9ca3af;
}

.pdf-item .pdf-chunks {
    background: rgba(99, 102, 241, 0.1);
    color: var(--indigo-500);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.btn-delete-pdf {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-delete-pdf:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red-500);
}

/* Spin animation */
.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ================================================
   DARK MODE OVERRIDES - AI Chatbot
   ================================================ */

/* --- Header --- */
[data-theme="dark"] .ai-chatbot-header {
    background: linear-gradient(135deg, #1a1a28 0%, #111118 100%);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .ai-chatbot-header .header-text h1 {
    color: var(--text-primary);
}

[data-theme="dark"] .ai-chatbot-header .header-text p {
    color: var(--text-secondary);
}

[data-theme="dark"] .ai-master-toggle {
    background: #1e1e2e;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ai-master-toggle .toggle-label {
    color: var(--text-primary);
}

/* --- Loading --- */
[data-theme="dark"] .ai-loading {
    color: var(--text-secondary);
}

[data-theme="dark"] .ai-loading .spinner {
    border-color: var(--border-color);
    border-top-color: var(--indigo-500);
}

/* --- No Access --- */
[data-theme="dark"] .no-access-content {
    background: #1a1a28;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .no-access-icon {
    background: linear-gradient(135deg, #3b1418 0%, #5c1c1f 100%);
}

[data-theme="dark"] .no-access-icon i {
    color: #f87171;
}

[data-theme="dark"] .no-access-content h2 {
    color: var(--text-primary);
}

[data-theme="dark"] .no-access-content > p {
    color: var(--text-secondary);
}

[data-theme="dark"] .no-access-features {
    background: #1e1e2e;
}

[data-theme="dark"] .no-access-features .feature-item {
    background: #252535;
    color: var(--text-primary);
}

/* --- AI Cards --- */
[data-theme="dark"] .ai-card {
    background: #1a1a28;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ai-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .ai-card .card-header {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .ai-card .card-icon {
    background: linear-gradient(135deg, #1e1b3a 0%, #272352 100%);
}

/* PDF icon should keep red gradient */
[data-theme="dark"] .ai-card .card-icon.pdf-icon {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

[data-theme="dark"] .ai-card .card-title h3 {
    color: var(--text-primary);
}

[data-theme="dark"] .ai-card .card-title p {
    color: var(--text-secondary);
}

[data-theme="dark"] .ai-card .card-body {
    background: #1a1a28;
}

/* --- App Checkboxes --- */
[data-theme="dark"] .app-checkbox-item {
    background: #1e1e2e;
    border-color: var(--border-color);
}

[data-theme="dark"] .app-checkbox-item:hover {
    background: #252535;
    border-color: #3e3e4e;
}

[data-theme="dark"] .app-checkbox-item.checked {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--indigo-500);
}

[data-theme="dark"] .app-checkbox-item .app-name {
    color: var(--text-primary);
}

[data-theme="dark"] .app-checkbox-item .app-name .app-slug {
    color: var(--text-muted);
}

[data-theme="dark"] .app-checkbox-item .check-icon {
    border-color: #3e3e4e;
}

[data-theme="dark"] .app-checkbox-item .app-icon.live-chat {
    background: #6366f1;
}

/* --- Form Elements --- */
[data-theme="dark"] .ai-chatbot-page .form-group label {
    color: var(--text-primary);
}

[data-theme="dark"] .ai-chatbot-page .form-control,
[data-theme="dark"] .ai-chatbot-page .form-textarea {
    color: var(--text-primary);
    background: #1e1e2e;
    border-color: var(--border-color);
}

[data-theme="dark"] .ai-chatbot-page .form-control:focus,
[data-theme="dark"] .ai-chatbot-page .form-textarea:focus {
    background: #1a1a28;
    border-color: var(--indigo-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

[data-theme="dark"] .ai-chatbot-page .form-control::placeholder,
[data-theme="dark"] .ai-chatbot-page .form-textarea::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .form-hint {
    color: var(--text-muted);
}

/* --- Setting Items --- */
[data-theme="dark"] .setting-item {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .setting-label {
    color: var(--text-primary);
}

[data-theme="dark"] .setting-description {
    color: var(--text-muted);
}

/* --- Toggle Switch --- */
[data-theme="dark"] .ai-chatbot-page .toggle-slider {
    background-color: #3e3e4e;
}

/* --- Multilang Inputs --- */
[data-theme="dark"] .lang-badge {
    background: #252535;
    color: var(--text-secondary);
}

/* --- Temperature --- */
[data-theme="dark"] .temperature-slider input[type="range"] {
    background: #2e2e3e;
}

[data-theme="dark"] .temperature-value {
    background: #252535;
    color: #818cf8;
}

/* --- Retrain --- */
[data-theme="dark"] .retrain-section {
    border-top-color: var(--border-color);
}

[data-theme="dark"] .btn-retrain {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .btn-retrain:hover {
    background: rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .retrain-result .alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.2);
}

[data-theme="dark"] .retrain-result .alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.2);
}

/* --- Save Section --- */
[data-theme="dark"] .ai-save-section {
    background: #1a1a28;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* --- Test Panel --- */
[data-theme="dark"] .btn-clear-test {
    background: #252535;
    color: var(--text-secondary);
}

[data-theme="dark"] .btn-clear-test:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

[data-theme="dark"] .test-messages {
    scrollbar-color: #3e3e4e transparent;
}

[data-theme="dark"] .test-empty-state {
    color: var(--text-muted);
}

[data-theme="dark"] .test-empty-state i {
    color: #3e3e4e;
}

[data-theme="dark"] .test-message.ai {
    background: #1e1e2e;
    color: var(--text-primary);
}

[data-theme="dark"] .test-message.system {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
}

[data-theme="dark"] .test-message.loading {
    background: #1e1e2e;
    color: var(--text-muted);
}

[data-theme="dark"] .test-message.loading::before {
    background: var(--text-muted);
}

[data-theme="dark"] .test-input-container {
    background: #111118;
    border-top-color: var(--border-color);
}

[data-theme="dark"] .test-input-container .form-control {
    background: #1e1e2e;
}

/* --- PDF Training --- */
[data-theme="dark"] .pdf-upload-area {
    background: #1e1e2e;
    border-color: var(--border-color);
}

[data-theme="dark"] .pdf-upload-area:hover {
    border-color: var(--indigo-500);
    background: rgba(99, 102, 241, 0.04);
}

[data-theme="dark"] .pdf-upload-area.dragover {
    border-color: var(--indigo-500);
    background: rgba(99, 102, 241, 0.08);
}

[data-theme="dark"] .pdf-upload-area .upload-content i {
    color: var(--text-muted);
}

[data-theme="dark"] .pdf-upload-area:hover .upload-content i {
    color: var(--indigo-500);
}

[data-theme="dark"] .pdf-upload-area .upload-text {
    color: var(--text-primary);
}

[data-theme="dark"] .pdf-upload-area .upload-hint {
    color: var(--text-muted);
}

[data-theme="dark"] .pdf-upload-area .upload-limit {
    color: #4b5563;
}

[data-theme="dark"] .pdf-upload-progress {
    background: #1e1e2e;
}

[data-theme="dark"] .pdf-upload-progress .progress-header {
    color: var(--text-primary);
}

[data-theme="dark"] .pdf-upload-progress .progress-bar {
    background: #2e2e3e;
}

[data-theme="dark"] .pdf-upload-progress .progress-file {
    color: var(--text-secondary);
}

[data-theme="dark"] .pdf-list-header h4 {
    color: var(--text-primary);
}

[data-theme="dark"] .btn-refresh-pdfs {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .btn-refresh-pdfs:hover {
    background: #252535;
    border-color: #3e3e4e;
    color: var(--text-primary);
}

[data-theme="dark"] .pdf-list-loading {
    color: var(--text-muted);
}

[data-theme="dark"] .pdf-list-empty {
    color: var(--text-muted);
}

[data-theme="dark"] .pdf-item {
    background: #1e1e2e;
}

[data-theme="dark"] .pdf-item:hover {
    background: #252535;
}

[data-theme="dark"] .pdf-item .pdf-icon {
    background: rgba(239, 68, 68, 0.15);
}

[data-theme="dark"] .pdf-item .pdf-name {
    color: var(--text-primary);
}

[data-theme="dark"] .pdf-item .pdf-chunks {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

[data-theme="dark"] .pdf-item .pdf-date {
    color: var(--text-muted);
}

[data-theme="dark"] .btn-delete-pdf {
    color: var(--text-muted);
}

[data-theme="dark"] .btn-delete-pdf:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

[data-theme="dark"] .ai-balance-banner {
    background: var(--card-bg);
    border-color: var(--border-color);
}

[data-theme="dark"] .ai-balance-banner .balance-icon {
    color: #66bb6a;
}

[data-theme="dark"] .ai-balance-banner .balance-number {
    color: #66bb6a;
}

[data-theme="dark"] .ai-balance-banner.balance-low .balance-number {
    color: #ffa726;
}

[data-theme="dark"] .ai-balance-banner.balance-empty .balance-number {
    color: #ef5350;
}

[data-theme="dark"] .ai-balance-banner .btn-add-balance {
    background: #388e3c;
}

[data-theme="dark"] .ai-balance-banner .btn-add-balance:hover {
    background: #2e7d32;
}

/* =====================================================
   FUNCTION CALLING SECTION
   ===================================================== */

.fc-card .card-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.fc-card .card-header .toggle-switch {
    margin-left: auto;
}

.fc-icon {
    background: linear-gradient(135deg, #f0f0ff 0%, #e8e8ff 100%) !important;
    color: var(--indigo-500) !important;
}

.search-icon {
    background: linear-gradient(135deg, #f0f0ff 0%, #e8e8ff 100%) !important;
    color: var(--indigo-500) !important;
}

.collect-icon {
    background: linear-gradient(135deg, #f0f0ff 0%, #e8e8ff 100%) !important;
    color: var(--indigo-500) !important;
}

.location-icon {
    background: linear-gradient(135deg, #f0f0ff 0%, #e8e8ff 100%) !important;
    color: var(--indigo-500) !important;
}

.fc-location-settings .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.fc-sub-card {
    margin-left: 16px;
    border-left: 3px solid var(--indigo-200);
}

[data-theme="dark"] .fc-sub-card {
    border-left-color: var(--border-color);
}

[data-theme="dark"] .fc-icon {
    background: linear-gradient(135deg, #1e1b3a 0%, #272352 100%) !important;
    color: #818cf8 !important;
}

[data-theme="dark"] .search-icon {
    background: linear-gradient(135deg, #1e1b3a 0%, #272352 100%) !important;
    color: #818cf8 !important;
}

[data-theme="dark"] .collect-icon {
    background: linear-gradient(135deg, #1e1b3a 0%, #272352 100%) !important;
    color: #818cf8 !important;
}

[data-theme="dark"] [data-theme="dark"] .location-icon {
    background: linear-gradient(135deg, #1e1b3a 0%, #272352 100%) !important;
    color: #818cf8 !important;
}

.code-textarea {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    background: var(--slate-50);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .code-textarea {
    background: var(--dark-bg);
    color: var(--text-primary);
}

/* Collect Fields Builder */
.fc-fields-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.fc-field-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fc-field-row .form-control {
    flex: 1;
    min-width: 0;
}

.fc-field-row select.form-control {
    flex: 0 0 80px;
}

.fc-field-required {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
}

.btn-remove-field {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-remove-field:hover {
    background: #fee2e2;
    color: #dc2626;
}

[data-theme="dark"] .btn-remove-field:hover {
    background: rgba(220, 38, 38, 0.15);
    color: #ef5350;
}

.btn-add-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px dashed var(--border-color);
    background: transparent;
    color: var(--indigo-500);
    font-size: 13px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-field:hover {
    border-color: var(--indigo-500);
    background: var(--indigo-50);
}

[data-theme="dark"] .btn-add-field:hover {
    background: rgba(99, 102, 241, 0.1);
}


    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: 9999;
}

.modal-container {
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    overflow: hidden;
}

[data-theme="dark"] .modal-container {
    background: var(--card-bg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
}

.modal-close:hover {
    background: var(--slate-100);
}

.modal-body {
    padding: 24px;
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 80px;
    gap: 12px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.modal-footer .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.modal-footer .btn-secondary {
    background: var(--slate-100);
    color: var(--text-primary);
}

.modal-footer .btn-primary {
    background: var(--indigo-gradient);
    color: var(--white);
}

[data-theme="dark"] .modal-footer .btn-secondary {
    background: var(--dark-bg);
}
