/* 
 * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
 * See LICENSE in the project root for license information.
 */

/* ===== Base Styles ===== */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

html {
    background: #2d2d2d;
}

body {
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
    background: white;
}

.hidden {
    display: none !important;
}

/* ===== Header ===== */
.ms-welcome__header {
    background: white !important;
    padding: 10px 20px 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

.ms-welcome__header img.header-logo {
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: clamp(60px, 10vh, 110px);
    height: clamp(60px, 10vh, 110px);
}

/* ===== Version Info ===== */
.version-info {
    margin: 0px;
    position: absolute;
    top: 10px;
    align-self: start;
}

#app-version {
    font-size: 12px;
    color: grey;
    cursor: pointer;
    transition: color 0.2s ease;
}

#app-version:hover {
    color: #E6003C;
}

/* ===== Auth Buttons ===== */
#auth-ui {
    margin-top: 4px;
}

#login {
    margin: 5px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #E6003C;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(230, 0, 60, 0.4);
}

#login .ms-Icon {
    color: white;
    font-size: 18px;
}

#login:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(230, 0, 60, 0.6);
}

#login:active {
    transform: scale(0.95);
}

/* ===== User Info ===== */
#user-info {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 12px;
    margin-top: 10px;
    border: 1px solid #e0e0e0;
}

.user-info-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-details {
    flex: 1;
    text-align: center;
}

#user-info p {
    margin: 2px 0;
    color: #4B4B4B;
    font-size: 13px;
}

#help {
    right: 20px;
}

#logout {
    right: 60px;
}

#admin-btn {
    right: 100px;
}

.icon-button {
    position: absolute;
    top: 8px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: #E6003C;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 6px rgba(230, 0, 60, 0.3);
    z-index: 10;
}

.icon-button .ms-Icon {
    color: white;
    font-size: 14px;
}

.icon-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(230, 0, 60, 0.5);
}

.icon-button:active {
    transform: scale(0.95);
}

#user-name {
    font-weight: 600;
    font-size: 14px;
}

/* ===== Main Content ===== */
.ms-welcome__main {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: #f5f5f5;
    height: 100%;
    overflow: hidden;
}

/* ===== Chat Container ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    background: white;
    min-height: 0;
}

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 30px 15px 15px 15px;
    background: #f8f9fa;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

/* ===== Messages ===== */
.message {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 85%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    animation: slideIn 0.3s ease;
    word-wrap: break-word;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    white-space: pre-wrap;
    background: #E6003C;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.assistant-message {
    background: white;
    color: #4B4B4B;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    border: 1px solid #e9ecef;
}

.assistant-message p {
    margin: 0 0 8px 0;
}

.assistant-message p:empty {
    display: none;
}

.assistant-message p:last-child {
    margin-bottom: 0;
}

.assistant-message code {
    background: #f0f0f0;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

.assistant-message pre {
    background: #f5f5f5;
    padding: 6px 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 3px 0;
}

.assistant-message pre code {
    background: none;
    padding: 0;
}

.assistant-message h2,
.assistant-message h3,
.assistant-message h4 {
    margin: 6px 0 2px 0;
    line-height: 1.3;
}

.assistant-message h2 { font-size: 1.15em; }
.assistant-message h3 { font-size: 1.05em; }
.assistant-message h4 { font-size: 1em; }

.assistant-message ul,
.assistant-message ol {
    margin: 2px 0;
    padding-left: 20px;
}

.assistant-message li {
    margin: 1px 0;
}

.assistant-message table {
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 0.9em;
    width: 100%;
}

.assistant-message th,
.assistant-message td {
    border: 1px solid #ddd;
    padding: 4px 8px;
    text-align: left;
}

.assistant-message th {
    background: #f5f5f5;
    font-weight: 600;
}

.assistant-message tr:nth-child(even) {
    background: #fafafa;
}

.assistant-message hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 8px 0;
}

.message.thinking {
    background: #fff5f7;
    font-style: italic;
    color: #E6003C;
    border: 1px dashed #E6003C;
}

.thinking-dots .dot {
    animation: thinking 1.4s infinite;
    opacity: 0;
}

.thinking-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots .dot:nth-child(3) { animation-delay: 0.4s; }
.thinking-dots .dot:nth-child(4) { animation-delay: 0.6s; }

@keyframes thinking {
    0%, 60%, 100% { opacity: 0; }
    30% { opacity: 1; }
}

/* ===== Controls Row (Background Info & Model Selector) ===== */
.controls-row {
    padding: 8px 15px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

#background-info-btn,
#rag-btn,
#epj-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 20px;
    border: 1px solid #dee2e6;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    color: #4B4B4B;
    white-space: nowrap;
}

#background-info-btn:hover,
#rag-btn:hover,
#epj-btn:hover {
    border-color: #E6003C;
    background: #fff5f7;
    color: #E6003C;
}

#background-info-btn .ms-Icon,
#rag-btn .ms-Icon,
#epj-btn .ms-Icon {
    font-size: 14px;
}

#epj-btn.active {
    background: #E6003C;
    color: white;
    border-color: #E6003C;
}

.model-selector-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-selector-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #4B4B4B;
    white-space: nowrap;
}

.model-selector-label .ms-Icon {
    font-size: 14px;
    color: #E6003C;
}

.model-select {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    background: white;
    font-size: 13px;
    color: #4B4B4B;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.model-select:hover {
    border-color: #E6003C;
    box-shadow: 0 0 8px rgba(230, 0, 60, 0.15);
}

.model-select:focus {
    outline: none;
    border-color: #E6003C;
    box-shadow: 0 0 0 3px rgba(230, 0, 60, 0.1);
}

/* ===== Mode Switch ===== */
.mode-switch-container {
    padding: 0 15px 8px 15px;
    flex-shrink: 0;
}

.mode-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.mode-label {
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
    transition: color 0.3s ease;
}

.mode-label.active {
    color: #E6003C;
    font-weight: 600;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: #E6003C;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.slider:hover {
    box-shadow: 0 0 8px rgba(230, 0, 60, 0.3);
}

/* ===== Input Area ===== */
.chat-input-container {
    display: flex;
    gap: 10px;
    padding: 15px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 24px;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: white;
}

.chat-input:focus {
    outline: none;
    border-color: #E6003C;
    box-shadow: 0 0 0 3px rgba(230, 0, 60, 0.1);
}

#send-message {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #E6003C;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(230, 0, 60, 0.4);
    flex-shrink: 0;
}

#send-message:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(230, 0, 60, 0.6);
}

#send-message:active {
    transform: scale(0.95);
}

#send-message .ms-Icon {
    color: white;
    font-size: 18px;
}

/* ===== Login Prompt ===== */
.login-prompt {
    padding: 30px 20px;
    margin: 40px 20px;
    background: white;
    border: 2px solid #E6003C;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(230, 0, 60, 0.15);
}

.login-prompt p {
    margin: 0;
    color: #4B4B4B;
    font-size: 15px;
    line-height: 1.6;
    font-weight: 500;
}

/* ===== Quota Display ===== */
.quota-info {
    padding: 3px 0 0 0;
    margin-top: 0;
}

.quota-label {
    font-size: 12px;
    margin-bottom: 6px;
    color: #4B4B4B;
}

.quota-bar-container {
    width: 100%;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.quota-bar {
    height: 100%;
    transition: width 0.5s ease, background-color 0.3s ease;
    border-radius: 3px;
}

/* ===== Background Info Dialog ===== */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.dialog-container {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: dialogSlideIn 0.3s ease;
}

@keyframes dialogSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dialog-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dialog-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #4B4B4B;
}

.close-dialog-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.close-dialog-btn:hover {
    background: #f8f9fa;
}

.close-dialog-btn .ms-Icon {
    font-size: 16px;
    color: #6c757d;
}

.dialog-body {
    padding: 0px 20px 20px 20px;
    flex: 1;
    overflow-y: auto;
}

.column-info {
    background: #fff5f7;
    border: 1px solid #E6003C;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 15px;
    font-size: 13px;
    color: #E6003C;
    font-weight: 500;
}

.column-info:empty {
    display: none;
}

.background-textarea {
    width: 85%;
    min-height: 200px;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    resize: vertical;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.background-textarea:focus {
    outline: none;
    border-color: #E6003C;
    box-shadow: 0 0 0 3px rgba(230, 0, 60, 0.1);
}

.dialog-footer {
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.dialog-footer .ms-Button {
    padding: 10px 20px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.dialog-footer .ms-Button--primary {
    background: #E6003C;
    color: white;
}

.dialog-footer .ms-Button--primary:hover {
    background: #c7002e;
    box-shadow: 0 4px 12px rgba(230, 0, 60, 0.4);
}

.dialog-footer .ms-Button--default {
    background: #f8f9fa;
    color: #4B4B4B;
    border: 1px solid #dee2e6;
}

.dialog-footer .ms-Button--default:hover {
    background: #e9ecef;
}

.dialog-footer .ms-Button .ms-Icon {
    font-size: 14px;
}

/* Smaller text for load-from-row4 and export-to-row4 buttons */
#load-from-row4 span,
#export-to-row4 span {
    font-size: 11px;
}

/* Make the quota label a clickable button */
.quota-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  width: 100%;
  transition: all 0.2s ease;
  border-radius: 4px;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  text-align: center;
}

.quota-button:hover {
  background: rgba(0, 0, 0, 0.05);
  text-decoration: underline;
}

.quota-button:active {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(0.98);
}

.quota-button:hover::after {
  opacity: 1;
}

/* Confirmation Dialog */
.confirm-dialog {
  max-width: 400px;
}

.confirm-dialog .dialog-body {
  text-align: center;
  padding: 20px;
}

.confirm-dialog .dialog-body p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

/* Confirm dialog must appear above other dialogs */
#confirm-dialog {
  z-index: 2000;
}

/* Delete Confirm Dialog Overlay */
.confirm-dialog-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;
}

.confirm-dialog-overlay.hidden {
  display: none !important;
}

.confirm-dialog-box {
  background: white;
  border-radius: 8px;
  padding: 20px;
  max-width: 300px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.confirm-dialog-box p {
  margin: 0 0 16px 0;
  font-size: 14px;
  line-height: 1.4;
}

.confirm-dialog-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-dialog-buttons button {
  min-width: 80px;
}

.estimated-usage {
  font-size: 11px;
  color: #666;
  align-self: end;
  padding-top: 0px;
  padding-right: 4px;
  padding-bottom: 4px;
}

/* ===== RAG Dialog Styles ===== */
.rag-dialog {
  max-width: 500px;
  max-height: 80vh;
}

.rag-description {
  font-size: 13px;
  color: #666;
  margin-bottom: 16px;
  line-height: 1.4;
}

.rag-toggle-section {
  background: #fff5f7;
  border: 1px solid #E6003C;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.rag-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.rag-toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #E6003C;
  cursor: pointer;
}

.rag-toggle-text {
  font-size: 13px;
  font-weight: 500;
  color: #E6003C;
}

.rag-upload-section {
  background: #f8f9fa;
  border: 2px dashed #ddd;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  margin-bottom: 20px;
  transition: all 0.2s ease;
}

.rag-upload-section:hover {
  border-color: #E6003C;
  background: #f0f6fc;
}

.rag-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #E6003C;
  font-weight: 600;
}

.rag-upload-label i {
  font-size: 32px;
}

.rag-file-input {
  display: none;
}

.rag-file-hint {
  display: block;
  font-size: 11px;
  color: #888;
  margin-top: 8px;
}

.rag-upload-progress {
  margin-top: 12px;
}

.progress-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #E6003C;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.upload-status {
  margin-top: 8px;
  font-size: 12px;
}

.upload-status.success {
  color: #107c10;
}

.upload-status.error {
  color: #E6003C;
}

.rag-documents-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: #333;
}

.rag-document-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 4px;
}

.rag-document-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  transition: background 0.2s ease;
}

.rag-document-item:last-child {
  border-bottom: none;
}

.rag-document-item:hover {
  background: #f8f9fa;
}

.rag-document-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.rag-document-name {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rag-document-meta {
  font-size: 11px;
  color: #888;
}

.rag-delete-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.rag-delete-btn:hover {
  background: #fde7e9;
  color: #E6003C;
}

.loading-indicator,
.empty-message,
.error-message {
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 13px;
}

.error-message {
  color: #E6003C;
}

/* RAG Tabs */
.rag-tabs {
  display: flex;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 16px;
  margin-top: 12px;
}

.rag-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 13px;
  color: #666;
  transition: all 0.2s ease;
}

.rag-tab:hover {
  color: #E6003C;
  background: #fdf2f4;
}

.rag-tab.active {
  color: #E6003C;
  border-bottom-color: #E6003C;
  font-weight: 600;
}

.rag-tab i {
  font-size: 16px;
}

.rag-tab-content {
  display: none;
}

.rag-tab-content.active {
  display: block;
}

/* SharePoint Integration Styles */
.sharepoint-section {
  margin-top: 8px;
}

.admin-consent-info {
  background: #fff4e5;
  border: 1px solid #ffc107;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
  text-align: center;
}

.admin-info-text {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 10px 0;
  font-size: 12px;
  color: #856404;
  line-height: 1.4;
  justify-content: center;
}

.admin-info-text i {
  font-size: 14px;
  margin-top: 2px;
  flex-shrink: 0;
}

.admin-consent-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #ffc107;
  color: #000;
  text-decoration: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.admin-consent-link:hover {
  background: #ffb300;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.admin-consent-link i {
  font-size: 16px;
}

.sharepoint-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.sharepoint-status.connected {
  background: #e6f4ea;
  color: #137333;
}

.sharepoint-status .status-icon {
  font-size: 16px;
}

.sharepoint-status.connected .status-icon {
  color: #137333;
}

.sharepoint-connect-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 20px;
  border: 1px solid #dee2e6;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  color: #4B4B4B;
}

.sharepoint-connect-btn:hover {
  border-color: #E6003C;
  background: #fff5f7;
  color: #E6003C;
}

.sharepoint-connect-btn i {
  font-size: 14px;
}

.sharepoint-config {
  margin-top: 16px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.config-group {
  margin-bottom: 14px;
}

.config-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

.sharepoint-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  background: white;
}

.folder-browser {
  display: flex;
  align-items: center;
  gap: 8px;
}

.folder-path {
  flex: 1;
  padding: 8px 10px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

.config-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.config-actions button {
  flex: 1;
}

.sharepoint-connected {
  background: #e6f4ea;
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
}

.connected-details {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #137333;
  font-weight: 500;
  margin-bottom: 6px;
}

.connected-folder {
  display: block;
  font-size: 12px;
  color: #555;
  margin-bottom: 10px;
}

#change-sharepoint-config {
  width: 100%;
}

/* Uploads Section Styles */
.uploads-section {
  margin-top: 8px;
}

.azure-search-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.azure-search-status.available {
  background: #e6f4ea;
  color: #137333;
}

.azure-search-status.unavailable {
  background: #fef7e0;
  color: #b06000;
}

.azure-search-status .status-icon {
  font-size: 16px;
}

.upload-section {
  margin-bottom: 16px;
}

.upload-dropzone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fafafa;
}

.upload-dropzone:hover {
  border-color: #E6003C;
  background: #fdf2f4;
}

.upload-dropzone.dragover {
  border-color: #E6003C;
  background: #fdf2f4;
  transform: scale(1.01);
}

.dropzone-icon {
  font-size: 32px;
  color: #999;
  margin-bottom: 8px;
}

.upload-dropzone:hover .dropzone-icon {
  color: #E6003C;
}

.upload-dropzone p {
  margin: 4px 0;
  color: #666;
  font-size: 13px;
}

.upload-hint {
  font-size: 11px !important;
  color: #999 !important;
}

.upload-progress {
  margin-top: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 6px;
}

.progress-bar {
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: #E6003C;
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

#progress-text {
  font-size: 12px;
  color: #666;
}

.documents-list-section {
  margin-top: 16px;
}

.documents-list-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin: 0 0 10px 0;
}

.documents-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #fafafa;
}

.no-documents {
  padding: 20px;
  text-align: center;
  color: #999;
  font-size: 13px;
  margin: 0;
}

.document-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #e8e8e8;
  gap: 10px;
}

.document-item:last-child {
  border-bottom: none;
}

.document-item i {
  font-size: 18px;
  color: #666;
}

.document-info {
  flex: 1;
  min-width: 0;
}

.document-name {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-meta {
  font-size: 11px;
  color: #999;
}

.document-delete {
  padding: 4px 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.document-delete:hover {
  background: #fee;
  color: #E6003C;
}

/* Background Section Styles (in RAG dialog) */
.background-section {
  margin-top: 8px;
}

.background-section .column-info {
  font-size: 13px;
  font-weight: 500;
  color: #E6003C;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #fdf2f4;
  border-radius: 6px;
}

.background-section .background-textarea {
  width: 100%;
  min-height: 150px;
  padding: 12px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  resize: vertical;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 13px;
  box-sizing: border-box;
}

.background-section .background-textarea:focus {
  outline: none;
  border-color: #E6003C;
  box-shadow: 0 0 0 3px rgba(230, 0, 60, 0.1);
}

.background-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e9ecef;
}

.background-actions .ms-Button {
  flex: 1;
  padding: 10px 16px;
  border-radius: 20px;
  border: 1px solid #dee2e6;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  color: #4B4B4B;
}

.background-actions .ms-Button:hover {
  background: #e9ecef;
}

.background-actions .ms-Button .ms-Icon {
  font-size: 14px;
}

.background-actions .ms-Button span {
  font-size: 11px;
}

.background-save-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.background-save-actions .ms-Button--primary {
  padding: 10px 20px;
  border-radius: 20px;
  border: none;
  background: #E6003C;
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.background-save-actions .ms-Button--primary:hover {
  background: #c7002e;
  box-shadow: 0 4px 12px rgba(230, 0, 60, 0.4);
}

.background-save-actions .ms-Button--primary .ms-Icon {
  font-size: 14px;
}

/* EPJ Edit Section Styles */
.epj-edit-section {
  margin-top: 8px;
}

.epj-edit-description {
  font-size: 13px;
  color: #666;
  margin: 12px 0 12px 0;
  line-height: 1.4;
}

.epj-upload-area {
  margin-bottom: 16px;
}

.epj-edit-panel {
  margin-top: 16px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.epj-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.epj-edit-filename {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.epj-edit-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.epj-edit-actions .btn-small {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid #ddd;
  background: #fff;

  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

/* ===== Admin Panel ===== */
.admin-panel-container {
    max-width: 760px;
    width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.admin-panel-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    padding: 12px 16px;
    gap: 10px;
}

.admin-status {
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
    min-height: 28px;
}

.admin-status--info    { background: #e8f0fe; color: #1a56db; }
.admin-status--success { background: #d1fae5; color: #065f46; }
.admin-status--error   { background: #fee2e2; color: #991b1b; }

/* Admin tabs */
.admin-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e0e0e0;
    flex-shrink: 0;
}

.admin-tab {
    padding: 7px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.admin-tab:hover { color: #E6003C; }

.admin-tab.active {
    color: #E6003C;
    border-bottom-color: #E6003C;
}

.admin-tab-content { display: none; flex-direction: column; gap: 12px; overflow-y: auto; flex: 1; }
.admin-tab-content.active { display: flex; }

/* Admin table */
.admin-table-wrapper {
    overflow-x: auto;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    flex-shrink: 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.admin-table th {
    background: #f5f5f5;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #444;
    border-bottom: 1px solid #e0e0e0;
    white-space: nowrap;
}

.admin-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #fafafa; }

.admin-cell-id {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-cell-num { text-align: right; white-space: nowrap; }
.admin-cell-feat { font-size: 11px; color: #666; }
.admin-cell-actions { white-space: nowrap; }
.admin-empty { text-align: center; color: #999; padding: 16px; font-style: italic; }

/* Row action buttons */
.admin-btn-edit, .admin-btn-delete {
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    margin-right: 4px;
    transition: opacity 0.15s ease;
}

.admin-btn-edit {
    background: #e8f0fe;
    border-color: #4285f4;
    color: #1a56db;
}

.admin-btn-delete {
    background: #fee2e2;
    border-color: #e53e3e;
    color: #991b1b;
}

.admin-btn-edit:hover, .admin-btn-delete:hover { opacity: 0.8; }

/* Admin form */
.admin-form {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.admin-form-title {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.admin-form-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    align-items: center;
    gap: 8px;
}

.admin-form-row label {
    font-size: 12px;
    color: #555;
    font-weight: 500;
}

.admin-input {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s ease;
}

.admin-input:focus { border-color: #E6003C; box-shadow: 0 0 0 2px rgba(230,0,60,.1); }

.admin-optional {
    font-weight: 400;
    color: #999;
    font-size: 11px;
}

.admin-form-actions {
    display: flex;
    gap: 8px;
    padding-top: 4px;
}

.admin-save-btn {
    min-width: 100px;
}


.epj-edit-actions .btn-small:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

.epj-edit-actions .ms-Button--primary.btn-small {
  background: #E6003C;
  color: white;
  border-color: #E6003C;
}

.epj-edit-actions .ms-Button--primary.btn-small:hover {
  background: #c7002e;
}

.epj-edit-info {
  font-size: 12px;
  color: #888;
  margin-bottom: 12px;
  padding: 6px 10px;
  background: #f8f9fa;
  border-radius: 4px;
}

.epj-edit-input-area {
  margin-bottom: 12px;
}

.epj-edit-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
}

.epj-edit-textarea:focus {
  outline: none;
  border-color: #E6003C;
  box-shadow: 0 0 0 2px rgba(230, 0, 60, 0.1);
}

.epj-edit-input-area .ms-Button--primary {
  margin-top: 8px;
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: none;
  background: #E6003C;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.epj-edit-input-area .ms-Button--primary:hover {
  background: #c7002e;
  box-shadow: 0 4px 12px rgba(230, 0, 60, 0.3);
}

.epj-edit-input-area .ms-Button--primary:disabled {
  background: #ccc;
  cursor: not-allowed;
  box-shadow: none;
}

/* EPJ Preview Area */
.epj-preview-area {
  margin-top: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px;
  background: #fafafa;
}

.epj-preview-area h4 {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin: 0 0 10px 0;
}

.epj-preview-list {
  max-height: 300px;
  overflow-y: auto;
}

.epj-operations-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.epj-operation-item {
  padding: 8px 10px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  line-height: 1.5;
  color: #333;
}

.epj-old-value {
  color: #c7002e;
  text-decoration: line-through;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
}

.epj-new-value {
  color: #137333;
  font-weight: 600;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
}

.epj-error {
  color: #c7002e;
  font-size: 12px;
}

.epj-warning {
  margin-top: 8px;
  padding: 8px 10px;
  background: #fef7e0;
  border: 1px solid #f0d060;
  border-radius: 4px;
  font-size: 12px;
  color: #b06000;
}

.epj-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.epj-preview-actions .ms-Button--primary {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  background: #E6003C;
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.epj-preview-actions .ms-Button--primary:hover {
  background: #c7002e;
}

.epj-preview-actions .ms-Button--default {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.epj-preview-actions .ms-Button--default:hover {
  background: #f5f5f5;
}

/* EPJ upload progress in chat */
.epj-upload-status {
  font-size: 13px;
  margin-bottom: 6px;
  color: #555;
}

.epj-upload-bar-wrap {
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

.epj-upload-bar {
  height: 100%;
  background: #E6003C;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* EPJ in-chat preview box */
.epj-preview-box {
  margin-top: 10px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px;
  background: #fafafa;
  font-size: 13px;
}

.epj-preview-box .epj-preview-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.epj-preview-box .epj-preview-list li {
  padding: 7px 10px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  background: #fff;
  line-height: 1.5;
}

.epj-preview-box .epj-preview-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.epj-preview-box .epj-download-btn {
  margin-top: 6px;
}

.epj-success {
  padding: 10px 12px;
  background: #e6f4ea;
  border: 1px solid #b7e1cd;
  border-radius: 6px;
  color: #137333;
  font-size: 13px;
  line-height: 1.4;
}

.epj-error-result {
  padding: 10px 12px;
  background: #fce8e6;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  color: #c7002e;
  font-size: 13px;
}

/* EPJ File Item Selection */
.epj-file-item {
  cursor: pointer;
  transition: background 0.15s ease;
}

.epj-file-item:hover {
  background: #f0f0f0;
}

.epj-file-item.selected {
  background: #fdf2f4;
  border-left: 3px solid #E6003C;
}