body {
  font-family: Arial, sans-serif;
}

#container {
  display: flex;
  gap: 20px;
}

.left-panel {
  flex: 0 0 20%;
  display: flex;
  flex-direction: column;
  height: 97vh;
}

.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 97vh;
  overflow: hidden;
}

h1 {
  font-size: 1.4em;
  margin: 0 0 8px 0;
}

.header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.logo {
  height: 2.5em;
  width: auto;
  margin-right: 6px;
}

.header .user-info {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header .user-info a {
  color: #007bff;
  text-decoration: none;
  font-size: 0.95em;
}

#logout-button {
  color: #d11;
  cursor: pointer;
}

form {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}

.text-field-label {
  font-weight: 600;
}

.form-field input[type="date"],
.form-field input[type="datetime-local"],
.form-field input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
}

.field-error {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 4px;
}

.input-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.15);
}

.input-with-clear {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-clear input {
  flex: 1;
  padding-right: 30px;
}

.clear-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #ccc;
  color: #333;
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 3px;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.clear-btn:hover {
  background-color: #f8f8f8;
  color: #d11;
  border-color: #d11;
}

.clear-btn:active {
  background-color: #f0f0f0;
}

#audit-types {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  font-size: 0.9em;
}

#audit-types label {
  font-size: 0.9em;
}

#audit-terms {
  margin-top: 10px;
}

#audit-terms .term-group {
  margin-top: 12px;
  padding-top: 6px;
  border-top: 1px solid #e0e0e0;
}

#audit-terms .term-group:first-of-type {
  border-top: none;
  padding-top: 0;
}

#audit-terms strong {
  font-size: 14px;
  display: block;
  margin-bottom: 6px;
}

#audit-terms ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#audit-terms li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.term-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
}

.term-checkbox input {
  margin: 0;
}

#audit-terms > .section-label {
  display: flex;
  align-items: center;
}

#add-term {
  display: none;
  margin-top: 8px;
  width: 100%;
  gap: 8px;
}

#audit-terms.editing #add-term {
  display: flex;
}

#toggle-edit-terms {
  background: none;
  border: none;
  color: #007bff;
  cursor: pointer;
  padding: 0;
  font-size: 0.9em;
  text-decoration: none;
  margin-left: 4px;
  transition: color 0.2s;
}

#toggle-edit-terms:hover {
  color: #0056b3;
  text-decoration: underline;
}

/* remove term buttons appear only in edit mode */
.term-remove {
  display: none;
  background: none;
  border: none;
  color: #d11;
  cursor: pointer;
  font-size: 0.85em;
  padding: 0 4px;
}

#audit-terms.editing .term-remove {
  display: inline;
}

#add-term select {
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  height: 34px;
  min-width: 120px;
}

#add-term input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
}

#add-term input[type="text"] {
  flex: 1;
  box-sizing: border-box;
}

#add-term button {
  padding: 6px 12px;
}

.section-label {
  margin-top: 2px;
  margin-bottom: 2px;
}

#preferences {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  font-size: 0.9em;
}

#preferences label {
  font-size: 0.9em;
}

/* Container for side-by-side layout of Audit Types and Preferences */
.audit-prefs-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 6px;
}

.section-label {
  font-weight: bold;
}

#summary-info {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  flex: 1;
}

@media (min-width: 520px) {
  #summary-info {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.summary-card {
  background: #f8fbff;
  border: 1px solid #d8e2f6;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-card__header {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  color: #475569;
}

.summary-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.summary-metric {
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-metric__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.summary-metric__value {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0f172a;
}

.summary-metric--muted .summary-metric__value {
  color: #94a3b8;
}

.term-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.term-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  background: #e2e8f0;
  color: #1f2937;
}

.term-badge__label {
  font-weight: 500;
}

.term-badge__count {
  font-weight: 600;
}

.term-badge--search {
  background: #dbeafe;
  color: #1d4ed8;
}

.term-badge--classification {
  background: #fef3c7;
  color: #92400e;
}

.term-badge--keyword {
  background: #fed7aa;
  color: #9a3412;
}

.term-badge--codeword {
  background: #fee2e2;
  color: #b91c1c;
}

.term-badge--generic {
  background: #e0f2fe;
  color: #0369a1;
}

.term-badges__empty {
  margin: 0;
  color: #64748b;
  font-size: 0.85rem;
}

#interaction-area {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 768px) {
  #interaction-area {
    flex-direction: row;
    align-items: flex-start;
  }
}

.nav-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 0 0 auto;
}

.nav-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-group button {
  min-width: 120px;
}

#elapsed-time {
  margin-left: 5px;
}

.form-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

button {
  padding: 6px 12px;
}

#results {
  word-break: break-word;
}

.json-result {
  white-space: pre-wrap;
  font-family: monospace;
}

.conversation-meta {
  margin-bottom: 6px;
}

.conversation-messages {
  margin-left: 10px;
}

.message {
  margin: 8px 0;
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f9f9f9;
}

.message-user {
  background: #e6f7ff;
}

.message-assistant {
  background: #f6ffed;
}

.message-system {
  background: #fffbe6;
}

.message-other {
  background: #f5f5f5;
}

.message-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85em;
  font-weight: bold;
  margin-bottom: 4px;
}

.message-content {
  white-space: pre-wrap;
}

.message-timestamp {
  font-weight: normal;
  color: #555;
}

.message-id {
  font-weight: normal;
  color: #777;
  margin-left: 5px;
}

.message-files {
  margin-top: 4px;
}

.file-entry {
  background: #eef6ff;
  padding: 4px;
  margin: 4px 0;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.file-header {
  font-weight: bold;
}

.file-matches {
  margin-top: 4px;
}

.message-citations {
  margin-top: 4px;
}

.url-citation {
  background: #fff0f0;
  padding: 4px;
  margin: 4px 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  word-break: break-word;
}

.conversation-annotations {
  margin-left: 10px;
  margin-top: 6px;
}

.message-annotations {
  margin-top: 4px;
  margin-left: 10px;
}

.annotation {
  margin: 4px 0;
  white-space: pre-wrap;
  font-style: italic;
}

.conversation-summary {
  margin-top: 10px;
  margin-left: 10px;
  white-space: pre-wrap;
}

.memory-meta {
  margin-bottom: 6px;
}

.memory-context {
  margin-left: 10px;
  margin-bottom: 8px;
}

.memory-entry {
  margin: 4px 0;
  padding: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f9f9f9;
}

.memory-entry-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85em;
  font-weight: bold;
  margin-bottom: 4px;
}

.memory-entry-content {
  white-space: pre-wrap;
}

.config-meta {
  margin-bottom: 6px;
}

.config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.config-actions button {
  margin-left: 4px;
}

.config-actions .delete-button {
  float: none;
}

.config-actions .disabled-button {
  float: none;
}

.disabled-button {
  background-color: gray;
  color: #fff;
  border: none;
  padding: 4px 8px;
  cursor: not-allowed;
  float: right;
  opacity: 0.6;
}

.disabled-button:hover {
  background-color: gray;
}

.config-section {
  margin-left: 10px;
  margin-bottom: 8px;
}

.config-section-title {
  font-weight: bold;
  margin-bottom: 4px;
}

.config-files {
  margin-top: 4px;
}

.result-item {
  border-bottom: 1px solid #ddd;
  padding: 4px 0;
}

mark {
  padding: 0 2px;
  border-radius: 2px;
}

.severity-red {
  background: #fee2e2;
  color: #b91c1c;
  padding: 2px;
  margin-top: 2px;
}

.severity-orange {
  background: #fed7aa;
  color: #9a3412;
  padding: 2px;
  margin-top: 2px;
}

.severity-yellow {
  background: #fef3c7;
  color: #92400e;
  padding: 2px;
  margin-top: 2px;
}

.severity-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

#results-wrapper {
  overflow-y: auto;
  border: 1px solid #ddd;
  padding: 5px;
  flex: 1;
  min-height: 0;
}

#results-container {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 5px;
  min-height: 0;
}

.result-nav {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  padding: 5px 10px;
  cursor: pointer;
  height: auto;
  display: flex;
  align-items: center;
  width: 30px;
  justify-content: center;
  align-self: stretch;
}

#match-nav,
#file-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#file-nav.disabled {
  opacity: 0.5;
}

.current-match {
  outline: 2px solid #000;
}

.current-file {
  outline: 2px solid #000;
}

#spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 3px solid #ccc;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

#spinner.active {
  display: inline-block;
}

@keyframes spin {
  from {
    transform: rotate(0);
  }

  to {
    transform: rotate(360deg);
  }
}

#status {
  margin-left: 10px;
}

#reset-form {
  display: none;
}

#page-info {
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

#summary-info {
  font-weight: bold;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#page-progress {
  flex: 1;
  height: 8px;
}

.delete-button {
  background-color: #e53935;
  color: #fff;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  float: right;
}

.delete-button:hover {
  background-color: #c62828;
}

/* User info alignment */
.user-info {
  float: right;
  margin-top: -3px;
}

/* Load more button */
.load-more-hidden {
  display: none;
}

/* TOTP group hidden */
.totp-group-hidden {
  display: none;
}

/* Authentication styles */
.auth-container {
  max-width: 400px;
  margin: 100px auto;
  padding: 30px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.auth-header img {
  width: 60px;
  height: 60px;
  margin-bottom: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-weight: bold;
  color: #333;
}

.form-group input {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.form-group input:focus {
  outline: none;
  border-color: #007bff;
}

.totp-required {
  border-color: #28a745 !important;
  background-color: #f8fff9;
}

.totp-required:focus {
  border-color: #28a745 !important;
  box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.auth-button {
  padding: 12px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
}

.auth-button:hover {
  background: #0056b3;
}

.auth-button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.auth-links {
  text-align: center;
  margin-top: 20px;
}

.auth-links a {
  color: #007bff;
  text-decoration: none;
}

.auth-links a:hover {
  text-decoration: underline;
}

.error-message {
  color: #dc3545;
  background: #f8d7da;
  padding: 10px;
  border-radius: 4px;
  display: none;
}

.tab-container {
  display: flex;
  margin-bottom: 20px;
}

.tab-button {
  flex: 1;
  padding: 10px;
  background: #f8f9fa;
  border: 1px solid #ddd;
  cursor: pointer;
}

.tab-button.active {
  background: white;
  border-bottom-color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* SAML Authentication styles */
.saml-section {
  margin-bottom: 20px;
}

.saml-button {
  width: 100%;
  padding: 12px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s;
}

.saml-button:hover {
  background: #218838;
}

.saml-button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.auth-divider {
  margin: 20px 0;
  text-align: center;
  position: relative;
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #ddd;
}

.auth-divider span {
  background: white;
  padding: 0 15px;
  color: #666;
  font-size: 14px;
}

.totp-group-hidden {
  display: none;
}

/* Authentication form defaults - hide everything initially until JS configures */
.tab-container {
  display: none;
}

.saml-section {
  display: none;
}

#legacy-login-section {
  display: none;
}

#legacy-register-section {
  display: none;
}

.auth-divider {
  display: none;
}

/* SAML-only layout adjustments */
.saml-only .tab-container {
  display: none !important;
}

.saml-only .auth-divider {
  display: none !important;
}

.saml-only #login-tab {
  text-align: center;
}

/* Legacy-only layout adjustments */
.legacy-only .saml-section {
  display: none !important;
}

/* Error state for no auth methods */
.no-auth-methods {
  text-align: center;
  padding: 20px;
  color: #dc3545;
}

/* ============================================================================
   User Search Modal Styles
   ============================================================================ */

.user-search-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.user-search-modal[aria-hidden="true"] {
  display: none;
}

.user-search-dialog {
  background: white;
  border-radius: 8px;
  padding: 24px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  position: relative;
}

.user-search-dialog h2 {
  margin: 0 0 16px 0;
  font-size: 1.5em;
  color: #333;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 4px 8px;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #000;
}

.modal-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.user-search-field {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.user-search-field input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}

.user-search-field input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.user-search-field button {
  padding: 8px 20px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.user-search-field button:hover:not(:disabled) {
  background: #0056b3;
}

.user-search-field button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.modal-helper {
  font-size: 0.85em;
  color: #666;
  margin: 0 0 4px 0;
}

.modal-error {
  font-size: 0.9em;
  color: #d11;
  margin: 4px 0;
  min-height: 1.2em;
}

.user-search-results {
  margin-top: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
  max-height: 500px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.user-search-table {
  width: 100%;
  border-collapse: collapse;
}

.user-search-table thead {
  position: sticky;
  top: 0;
  background: #f8f9fa;
  z-index: 1;
}

.user-search-table th {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  font-size: 0.9em;
  color: #495057;
}

.user-search-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.user-search-table tbody tr:hover {
  background-color: #f8f9fa;
}

.user-search-table tbody tr:last-child td {
  border-bottom: none;
}

.insert-id-btn {
  padding: 6px 12px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  font-weight: 500;
  transition: background 0.2s;
  white-space: nowrap;
}

.insert-id-btn:hover {
  background: #218838;
}

.insert-id-btn:active {
  background: #1e7e34;
}

.more-results-indicator {
  padding: 8px;
  text-align: center;
  font-size: 0.9em;
  color: #666;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
}

/* Link button style for search trigger */
.link-button {
  background: none;
  border: none;
  color: #007bff;
  cursor: pointer;
  font-size: 0.9em;
  padding: 0;
  text-decoration: none;
  transition: color 0.2s;
}

.link-button:hover:not(:disabled) {
  color: #0056b3;
  text-decoration: underline;
}

.link-button:disabled {
  color: #ccc;
  cursor: not-allowed;
  text-decoration: none;
}

.link-button[hidden] {
  display: none;
}

/* Label row for search trigger placement */
.label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

/* End-date field indicators */
.required-indicator {
  color: #ff4444;
  font-weight: bold;
  margin-left: 2px;
  font-size: 0.9em;
}

.optional-indicator {
  color: #888;
  font-style: italic;
  font-size: 0.85em;
  font-weight: normal;
  margin-left: 4px;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
  .user-search-dialog {
    max-width: 100%;
    max-height: 95vh;
    padding: 16px;
  }

  .user-search-table th,
  .user-search-table td {
    padding: 6px 4px;
    font-size: 0.85em;
  }

  .insert-id-btn {
    padding: 4px 8px;
    font-size: 0.8em;
  }
}
