/* styles/components/modal.css */

/* Base wrapper ---------------------------------------------------------- */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface-default);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 4px 8px var(--shadow-subtle);
  z-index: 1000;
  box-sizing: border-box;
}

/* Size / behaviour modifiers ------------------------------------------- */
.modal--form {
  width: min(1100px, 90vw);
  padding: 2rem;
}

.modal--simple {
  width: min(400px, 90vw);
  padding: 2rem;
}

.modal--simple:has(.ai-job-started, .validation-failed, .confirm-ai-answer) { 
  width: min(500px, 90vw) !important;
}

.ai-job-started, .validation-failed {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}


.modal--simple .button-group {
  margin-top: 1.5rem;
  margin-bottom: 0px;
}

.modal--narrow {
  width: auto;
  padding: 2rem;
}

.modal--narrow .form-group input,
.modal--narrow .form-group select,
.modal--narrow .form-group textarea {
  width: auto;
}

/* Close button ---------------------------------------------------------- */
.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.modal__close:hover {
  color: white;
  background: var(--interactive-primary);
}

/* Overlay --------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-background);
  display: none;
  z-index: 999;
}

.overlay.is-active {
  display: block;
}

/* Modal header and content --------------------------------------------- */
.modal h2 {
  color: var(--text-primary);
  font-size: 1.5rem;
  margin: 0 0 1.5rem 0;
  font-weight: 500;
}

/* Table styles scoped to modal ----------------------------------------- */
.data-table-container {
  border: 1px solid var(--border-subtle);
  margin-top: 0px;
  margin-bottom: 1rem;
  overflow-y: auto;              /* ONLY vertical scroll */
  overflow-x: hidden;            /* NO horizontal scroll */
  max-height: 300px;
  border-radius: 4px !important;
}

.actions-cell {
  white-space: nowrap;
  text-align: center !important;
}

.actions-th {
  text-align: center !important;
}

.action-link {
  color: var(--interactive-secondary);
  text-decoration: none;
  margin-right: 12px;
  font-size: 16px;
  display: inline-block;
  padding: 2px;
  transition: color 0.2s ease;
  cursor: pointer;
}

.action-link:hover {
  text-decoration: none;
  color: var(--color-primary);
}

.action-link:last-child {
  margin-right: 0;
}

/* Modal content sections */
.modal-section {
  margin-bottom: 1.5rem;
}

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

.modal h2 {
  font-weight: 700;
}

.modal th,
.modal td {
  text-align: left;
  padding: 14px;
  vertical-align: middle;
}

.modal tr.selected-row {
  background-color: rgba(19, 92, 121, 0.1) !important;
}

.modal th {
  background-color: var(--table-header-bg);
  color: var(--table-header-text);
  font-weight: 600;
  border-bottom: 2px solid var(--border-subtle);
}

/* Sortable table headers */
.sortable-header {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color 0.2s ease;
}

.sortable-header:hover {
  background-color: var(--interactive-hover);
}

.sort-indicator {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--text-subtle);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sortable-header:hover .sort-indicator {
  opacity: 0.5;
}

.sort-indicator--active {
  opacity: 1 !important;
  color: var(--interactive-primary);
}

.modal tr[data-item-id] {
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}

.modal tr[data-item-id]:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.modal tr:hover{
  background-color: rgba(0, 0, 0, 0.05);
}


/* Outline button */
.btn-outline {
  background-color: transparent;
  color: var(--interactive-primary);
  border: 1px solid var(--interactive-primary);
}

.btn-outline:hover {
  background-color: var(--interactive-hover);
}


.modal--options .modal-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.modal--options .btn {
  width: 100%;
  padding: 10px;
  text-align: center;
}

/* component-specific modal attributes */

.projects-modal .form-group {
  max-width: 600px;
}

.history-modal {
  width: 90% !important;
}

@media (max-width: 1100px) {
  .history-modal {
    width: 97% !important;
  }
}

/* History modal title with tooltip support */
.history-modal-title[title]:not([title=""]) {
  position: relative;
  cursor: help;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-modal-title[title]:not([title=""]):hover::after {
  content: attr(title);
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 4px;
  padding: 8px 12px;
  background-color: var(--color-gray-800);
  color: var(--color-white);
  font-size: var(--font-size-sm);
  white-space: normal;
  max-width: 400px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 9997;
}

/* Style for search input and button combination */
.inline-search-group {
  display: flex;
  gap: 8px;
}

.inline-search-group input {
  flex: 1;
}

.inline-search-group button {
  flex: 0 0 auto;
}

/* Projects Modal: */
.search-container {
  display: flex;
  gap: 8px;
  max-width: 600px;
}

.search-container input {
  flex: 1;
}

.perm-delete-btn {
  color: #dc3545;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 14px;
  font-weight: bold;
}

.perm-delete-btn:hover {
  color: #bd2130;
}

/* Security UI Enhancements 
 * 
 * Minimal additions to existing design system for security features
 * Reuses tokens from tokens.css and existing form/modal styles
 */

/* Enhanced error display for security contexts */
.inline-error.security {
  background-color: rgba(220, 53, 69, 0.1);
  border: 1px solid var(--status-error);
  border-radius: 4px;
  padding: 12px;
  margin: 8px 0;
}

.inline-error.warning {
  background-color: rgba(255, 193, 7, 0.1);
  border: 1px solid var(--status-warning);
  color: var(--color-gray-800);
}

.security-error {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.security-error i {
  color: var(--status-error);
  margin-right: 8px;
}

.security-error strong {
  color: var(--status-error);
  font-weight: var(--font-weight-semibold);
}

.security-error p {
  margin: 4px 0;
  line-height: var(--line-height-relaxed);
}

/* Password strength indicator - reuses existing color tokens */
.password-strength {
  margin-top: 8px;
}

.strength-bar {
  width: 100%;
  height: 6px;
  background-color: var(--color-gray-200);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.strength-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.strength-fill.strength-weak {
  background-color: var(--status-error);
}

.strength-fill.strength-medium {
  background-color: var(--status-warning);
}

.strength-fill.strength-strong {
  background-color: var(--status-success);
}

.strength-text {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

/* Password requirements - uses existing list styles */
.password-requirements {
  background-color: var(--background-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 12px;
  font-size: var(--font-size-sm);
}

.password-requirements strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 8px;
}

.password-requirements ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
}

.password-requirements li {
  margin-bottom: 4px;
  line-height: var(--line-height-relaxed);
}

/* Password input with toggle - extends existing form styles */
.password-input-group {
  position: relative;
  display: block;
  width: 100%;
}

.password-input-group input {
  /* padding-right: 65px; */
  /* Increased space for toggle button to prevent overlap */
}

.toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 2px;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-password:hover {
  color: var(--text-primary);
  background-color: var(--interactive-hover);
}

.toggle-password:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Alert components - reuses existing status colors */
.alert {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert i {
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-warning {
  background-color: rgba(255, 193, 7, 0.1);
  border: 1px solid var(--status-warning);
  color: var(--color-gray-800);
}

.alert-info {
  background-color: rgba(19, 92, 121, 0.1);
  border: 1px solid var(--status-info);
  color: var(--color-gray-800);
}

.alert-warning i {
  color: var(--status-warning);
}

.alert-info i {
  color: var(--status-info);
}

/* Radio group styling - extends existing form styles */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.radio-group label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  font-weight: var(--font-weight-normal);
}

.radio-group label:hover {
  background-color: var(--interactive-hover);
}

.radio-group input[type="radio"] {
  margin: 0;
  flex-shrink: 0;
  margin-top: 2px;
}

/* Validation errors - consistent with existing error styles */
.validation-errors {
  color: var(--status-error);
}

.validation-errors strong {
  display: block;
  margin-bottom: 8px;
  font-weight: var(--font-weight-semibold);
}

.validation-errors ul {
  margin: 0;
  padding-left: 20px;
}

.validation-errors li {
  margin-bottom: 4px;
  line-height: var(--line-height-relaxed);
}

/* Temporary password display */
.temp-password-result {
  text-align: center;
}

.temp-password-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  background-color: var(--background-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}

.temp-password-display code {
  font-family: 'Courier New', monospace;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  background-color: var(--color-white);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  user-select: all;
}

.copy-btn {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background-color: var(--interactive-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* Input Field State Classes - Three distinct visual states */

/* Always read-only fields - permanently non-editable */
.field-readonly {
  color: var(--input-disabled-text) !important;
  cursor: not-allowed !important;
  border: 1px solid var(--border-subtle) !important;
}

/* Editable fields - currently in edit mode */
.field-editable {
  background-color: var(--input-bg) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--input-border) !important;
  cursor: text !important;
}

/* Editable but temporarily locked fields - can be edited but currently locked */
.field-locked {
  background-color: var(--surface-subtle) !important;
  color: var(--text-secondary) !important;
  cursor: not-allowed !important;
  border: 1px solid var(--border-subtle) !important;
  opacity: 0.8;
}

/* Focus states for editable fields only */
.field-editable:focus {
  border-color: var(--border-focus) !important;
  outline: 2px solid var(--focus-ring) !important;
  outline-offset: -1px;
}

/* Ensure readonly and locked fields cannot be focused */
.field-readonly:focus,
.field-locked:focus {
  outline: none !important;
}

/* Legacy readonly field styling - kept for backwards compatibility */
.readonly-field {
  background-color: var(--input-disabled-bg) !important;
  color: var(--input-disabled-text) !important;
  cursor: not-allowed;
}

/* Field help text - extends existing form styles */
.field-help {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 4px;
  line-height: var(--line-height-relaxed);
}

/* Login help section */
.login-help {
  margin-top: 16px;
  text-align: center;
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
}

.login-help a {
  color: var(--interactive-primary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  transition: color 0.2s ease;
}

.login-help a:hover {
  color: var(--interactive-primary-hover);
  text-decoration: underline;
}

/* Enhanced button group - extends existing button styles */
.button-group {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.button-group .btn {
  flex: 0 1 auto;
  min-width: 100px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .password-input-group {
    position: relative;
    display: block;
    width: 100%;
  }

  .password-input-group input {
    /* padding-right: 65px; */
    width: 100%;
  }

  .temp-password-display {
    flex-direction: column;
    gap: 12px;
  }

  .button-group {
    flex-direction: column;
  }

  .button-group .btn {
    width: 100%;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .strength-bar {
    border: 1px solid var(--text-primary);
  }

  .alert {
    border-width: 2px;
  }

  .password-requirements {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

  .strength-fill,
  .toggle-password,
  .radio-group label,
  .copy-btn {
    transition: none;
  }
}

/* Documents Modal - Height constraints and pagination */
.documents-modal {
  max-height: 90vh;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.documents-modal .actions-column {
  min-width: 160px;
}

.documents-modal h2 {
  flex-shrink: 0;
}

.documents-modal .modal-section {
  flex-shrink: 0;
  margin-bottom: 16px;  
}

.documents-modal .doc-input {
  padding: 8px;
    font-size: 14px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text-primary);
    background: var(--input-bg);
}

/* Override for Shoelace buttons with doc-input class */
.documents-modal sl-button.doc-input,
.documents-modal sl-dropdown .doc-input {
  background: transparent;
  border: none;
  padding: 0;
}

/* Shoelace override button color for Access and Date Filters */
/* For button groups specifically */
sl-button-group sl-button[variant="default"]::part(base) {
  background-color: #f5f5f5 !important;
  border-color: #d1d1d1 !important;
  color: #333 !important;
  height: 32.8px !important;
  min-height: 32.8px !important;
  font-family: Arial, sans-serif !important;
      flex-wrap: wrap;
    align-content: center;
}

sl-button-group sl-button[variant="primary"]::part(base) {
  background-color: #135c79 !important;
  border-color: #135c79 !important;
  color: white !important;
  height: 32.8px !important;
  min-height: 32.8px !important;
  font-family: Arial, sans-serif !important;
      flex-wrap: wrap;
    align-content: center;
}

.documents-modal .documents-table-container {
  border: 1px solid var(--border-subtle);
  flex: 1 1 auto;
  overflow-y: auto; /* Table container should scroll */
  display: flex;
  flex-direction: column;
  max-height: none; /* Use flex-based sizing instead of fixed height */
  min-height: 200px;
  border-radius: 4px !important;
  /* Minimum space for at least a few rows */
}

/* Override flex layout for AccordionTable (uses native table element) */
.documents-modal .documents-table-container:has(.data-table) {
  display: block;
  overflow-y: auto; /* Ensure scroll is enabled */
}

.documents-modal .documents-table {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.documents-modal .documents-table thead{
  position: sticky;
  top: 0;
}

/* Reset flex layout for native table elements (AccordionTable) */
.documents-modal table.documents-table {
  display: table !important;
  flex: none;
  overflow: visible;
  width: 100%;
}

.documents-modal .responsive-table-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.documents-modal__footer {
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  margin-top: 3px !important;
  background: var(--surface-default);
  position: relative;
  z-index: 10;
  /* Ensure footer is always visible */
  min-height: 60px;
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  order: 999;
  /* Force it to appear last */
}

/* Ensure pagination controls are always visible */
.documents-modal .responsive-table-pagination {
  flex-shrink: 0;
  background: var(--surface-default);
  border-top: 1px solid var(--border-subtle);
  padding: 8px 0;
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Fix pagination button layout and styling */
.documents-modal .pagination-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
}

.documents-modal .pagination-btn {
  background: none !important;
  border: none !important;
  padding: 4px 8px !important;
  font-size: 14px !important;
  color: var(--text-secondary) !important;
  cursor: pointer;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: auto !important;
  font-weight: normal !important;
}

.documents-modal .pagination-btn:hover:not(:disabled) {
  color: var(--text-primary) !important;
  background: none !important;
}

.documents-modal .pagination-btn:disabled {
  color: var(--text-muted) !important;
  cursor: not-allowed !important;
  opacity: 0.5 !important;
  pointer-events: none !important;
  background: none !important;
  border: none !important;
}

.documents-modal .pagination-btn[disabled] {
  color: var(--text-muted) !important;
  cursor: not-allowed !important;
  opacity: 0.5 !important;
  pointer-events: none !important;
  background: none !important;
  border: none !important;
}

.documents-modal .pagination-btn i {
  font-size: 12px;
}

/* Style pagination info to match the clean look */
.documents-modal .pagination-info {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.documents-modal .pagination-info-text {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.documents-modal .page-size-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.documents-modal .page-size-selector label {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.documents-modal .page-size-select {
  padding: 2px 6px;
  font-size: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  background: var(--surface-default);
  color: var(--text-primary);
}

/* Adjust responsive table layout for documents modal */
@media (max-width: 768px) {
  .documents-modal {
    max-height: 95vh;
    width: 95vw;
    margin: 2.5vh auto;
  }

  .documents-modal .documents-table-container {
    max-height: none; /* Use flex-based sizing on mobile too */
  }
}


/* User modal */

.admin-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.admin-actions-grid .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.url-result {
  text-align: left;
}

.url-display {
  background-color: var(--background-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 12px;
  margin: 12px 0;
}

.url-display input {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 8px;
}

.security-warning {
  background-color: rgba(255, 193, 7, 0.1);
  border: 1px solid var(--status-warning);
  border-radius: 4px;
  padding: 12px;
  margin: 8px 0;
}

.security-warning i {
  color: var(--status-warning);
  margin-right: 8px;
}

.security-warning p {
  margin: 4px 0;
}

@media (max-width: 768px) {
  .admin-actions-grid {
    grid-template-columns: 1fr;
  }
}

/* Real-time validation feedback styles */
.validation-feedback {
  font-size: var(--font-size-sm);
  margin-top: 4px;
  min-height: 20px;
}

.validation-feedback--error {
  color: var(--status-error);
}

.validation-feedback--success {
  color: var(--status-success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.validation-feedback--success i {
  font-size: 14px;
}

.validation-errors-list {
  margin: 0;
  padding-left: 20px;
  list-style: disc;
}

.validation-errors-list li {
  margin-bottom: 2px;
  line-height: 1.4;
}

/* Input validation states */
.input--error {
  border-color: var(--status-error) !important;
  background-color: rgba(220, 53, 69, 0.05);
}

.input--valid {
  border-color: var(--status-success) !important;
  background-color: rgba(40, 167, 69, 0.05);
}

/* Ensure password requirements section has proper spacing */
.password-requirements {
  margin-top: 16px;
}

/* Register Modal Responsive Layout */
.modal--register {
  width: min(1100px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
}

.register-form-content {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.register-form-main {
  flex: 2;
  min-width: 0;
}

.register-form-sidebar {
  flex: 1;
  min-width: 250px;
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.form-group--full {
  width: 100%;
}

/* Responsive validation feedback that only takes space when present */
.validation-feedback {
  min-height: 0 !important;
  margin-top: 4px;
  transition: all 0.2s ease;
}

.validation-feedback:empty {
  display: none;
}

.validation-feedback:not(:empty) {
  display: block;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
  }

  to {
    opacity: 1;
    max-height: 100px;
  }
}

/* Responsive breakpoints for register modal */
@media (max-width: 1024px) {
  .modal--register {
    width: min(900px, 95vw);
  }

  .register-form-content {
    gap: 1.5rem;
  }
}

@media (max-width: 768px) {
  .modal--register {
    width: 95vw;
    padding: 1.5rem;
    max-height: 95vh;
  }

  .register-form-content {
    flex-direction: column;
    gap: 1.5rem;
  }

  .register-form-sidebar {
    order: -1;
    min-width: auto;
  }

  .form-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .password-requirements {
    margin-top: 0;
    padding: 1rem;
    font-size: var(--font-size-sm);
  }
}

@media (max-width: 480px) {
  .modal--register {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding: 1rem;
    top: 0;
    left: 0;
    transform: none;
  }

  .register-form-content {
    gap: 1rem;
  }

  .button-group {
    margin-top: 1rem;
  }
}

/* Password Reset Modal Responsive Layout */
.modal--password-reset {
  width: min(1000px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
}

.password-reset-content {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.password-reset-main {
  flex: 2;
  min-width: 0;
}

.password-reset-sidebar {
  flex: 1;
  min-width: 250px;
}

.password-reset-form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.password-reset-form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.password-reset-form-group--full {
  width: 100%;
}

/* Responsive breakpoints for password reset modal */
@media (max-width: 1024px) {
  .modal--password-reset {
    width: min(900px, 95vw);
  }

  .password-reset-content {
    gap: 1.5rem;
  }
}

@media (max-width: 768px) {
  .modal--password-reset {
    width: 95vw;
    padding: 1.5rem;
    max-height: 95vh;
  }

  .password-reset-content {
    flex-direction: column;
    gap: 1.5rem;
  }

  .password-reset-sidebar {
    order: -1;
    min-width: auto;
  }

  .password-reset-form-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .password-requirements {
    margin-top: 0;
    padding: 1rem;
    font-size: var(--font-size-sm);
  }
}

@media (max-width: 480px) {
  .modal--password-reset {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding: 1rem;
    top: 0;
    left: 0;
    transform: none;
  }

  .password-reset-content {
    gap: 1rem;
  }

  .button-group {
    margin-top: 1rem;
  }
}

/* Vector Index Management Modal */
.modal--large {
  width: min(1200px, 95vw);
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
}

.modal__content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

/* Section styling */
.section {
  margin-bottom: 1.5rem;
}

.section h3 {
  margin: 0 0 1rem 0;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 500;
}

/* Metadata display */
.metadata-display {
  background: var(--background-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 1rem;
}

.metadata-row {
  display: flex;
  margin-bottom: 0.5rem;
}

.metadata-row:last-child {
  margin-bottom: 0;
}

.metadata-label {
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 100px;
  flex-shrink: 0;
}

.metadata-value {
  color: var(--text-primary);
  font-weight: 400;
}

/* Indexes list and grid */
.indexes-list {
  min-height: 200px;
}

.indexes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 1rem;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  border: 2px dashed var(--border-subtle);
  border-radius: 8px;
}

.empty-state p {
  margin: 0.5rem 0;
}

.text-muted {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* Index card styling */
.index-card {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
  background: var(--surface-default);
  transition: box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.index-card:hover {
  box-shadow: 0 2px 8px var(--shadow-subtle);
}

.index-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
}

.index-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
  flex: 1;
}

.index-status {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.status--success {
  background: rgba(40, 167, 69, 0.1);
  color: var(--status-success);
  border: 1px solid var(--status-success);
}

.status--pending {
  background: rgba(255, 193, 7, 0.1);
  color: var(--status-warning);
  border: 1px solid var(--status-warning);
}

.status--error {
  background: rgba(220, 53, 69, 0.1);
  color: var(--status-error);
  border: 1px solid var(--status-error);
}

.status--warning {
  background: rgba(255, 193, 7, 0.1);
  color: #856404;
  border: 1px solid #ffc107;
}

.status--default {
  background: rgba(108, 117, 125, 0.1);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* Index details */
.index-details {
  margin-bottom: 1rem;
}

.detail-row {
  display: flex;
  margin-bottom: 0.5rem;
  font-size: var(--font-size-sm);
}

.detail-row:last-child {
  margin-bottom: 0;
}

.detail-label {
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 120px;
  flex-shrink: 0;
}

.detail-value {
  color: var(--text-primary);
  word-break: break-word;
}

/* Index actions */
.index-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn--small {
  padding: 0.375rem 0.75rem;
  font-size: var(--font-size-sm);
  min-width: auto;
}

.btn--small i {
  font-size: var(--font-size-xs);
  margin-right: 0.25rem;
}

/* Status details modal content - Enhanced for vector index details modal */
.status-details {
  padding: var(--spacing-4, 16px);
  max-width: 100%;
  box-sizing: border-box;
}

.status-details h4 {
  margin: 0 0 var(--spacing-4, 16px) 0;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--spacing-2, 8px);
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-3, 12px);
  margin-top: var(--spacing-3, 12px);
  width: 100%;
  box-sizing: border-box;
}

/* Responsive grid for smaller screens */
@media (max-width: 600px) {
  .status-grid {
    grid-template-columns: 1fr;
  }
}

.status-item {
  display: flex;
  flex-direction: column;
  padding: var(--spacing-2, 8px);
  background: var(--surface-subtle, #f8f9fa);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  box-sizing: border-box;
}

.status-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.status-value {
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.4;
  font-weight: 400;
}

/* Status-specific styling for different states */
.status-value.status--success {
  color: var(--status-success, #28a745);
  font-weight: 500;
}

.status-value.status--pending {
  color: var(--status-warning, #ffc107);
  font-weight: 500;
}

.status-value.status--error {
  color: var(--status-error, #dc3545);
  font-weight: 500;
}

.status-value.status--warning {
  color: var(--status-warning, #ffc107);
  font-weight: 500;
}

/* Loading overlay for modal */
#modalLoadingOverlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 10px;
}

/* Responsive adjustments for vector index modal */
@media (max-width: 1024px) {
  .modal--large {
    width: 95vw;
    padding: 1.5rem;
  }
  
  .indexes-grid {
    grid-template-columns: 1fr;
  }
  
  .status-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .modal--large {
    width: 95vw;
    padding: 1rem;
    max-height: 95vh;
  }
  
  .index-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .index-actions {
    justify-content: flex-start;
  }
  
  .btn--small {
    flex: 1;
    min-width: auto;
    justify-content: center;
  }
  
  .metadata-row,
  .detail-row {
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .metadata-label,
  .detail-label {
    min-width: auto;
    font-weight: 500;
  }
}

@media (max-width: 480px) {
  .modal--large {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding: 1rem;
    top: 0;
    left: 0;
    transform: none;
  }
  
  .section {
    margin-bottom: 1rem;
  }
  
  .index-actions {
    flex-direction: column;
  }
  
  .btn--small {
    width: 100%;
  }
}

/* Vector Search Preview Modal Styles */
.vector-search-preview-modal {
  max-width: 900px !important;
}

.vector-search-preview-modal .section {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}

.vector-search-preview-modal .section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

/* Search Results Styles */
.results-container {
  min-height: 200px;
}

.search-results-table .similarity-score {
  font-weight: 600;
  padding: 2px 8px;
  background: var(--surface-accent);
  border-radius: 12px;
  font-size: 0.875rem;
}

.search-results-table .chunk-preview {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.4;
}

.search-results-table .document-key-field {
  font-family: var(--font-family-mono);
  font-size: 0.8rem;
}

.search-results-table .responsive-table-row.selected {
  background-color: var(--surface-accent) !important;
  border-left: 3px solid var(--interactive-primary);
}

.search-results-table .responsive-table-row:hover {
  background-color: var(--surface-hover);
  cursor: pointer;
}

/* Selected Chunk Content Styles */
.selected-chunk-info {
  display: flex;
  gap: 2rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--surface-subtle);
  border-radius: 6px;
}

.chunk-metadata {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chunk-metadata .metadata-label {
  font-weight: 500;
  color: var(--text-secondary);
}

.chunk-metadata .metadata-value {
  font-weight: 600;
  color: var(--text-primary);
}

.chunk-content-display {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}

.chunk-content {
  padding: 1rem;
  background: var(--surface-default);
  line-height: 1.6;
}

.chunk-content p {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chunk-metadata-section {
  border-top: 1px solid var(--border-subtle);
  padding: 1rem;
  background: var(--surface-subtle);
}

.chunk-metadata-section h4 {
  margin: 0 0 0.75rem 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.metadata-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metadata-key {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  font-weight: 500;
}

.metadata-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-family: var(--font-family-mono);
  background: var(--surface-default);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
}

/* Loading States */
.vector-search-preview-modal .loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  z-index: 1000;
}

.vector-search-preview-modal .loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-subtle);
  border-top: 3px solid var(--interactive-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive adjustments for vector search modal */
@media (max-width: 768px) {
  .vector-search-preview-modal {
    max-width: 95vw !important;
  }
  
  .selected-chunk-info {
    flex-direction: column;
    gap: 1rem;
  }
  
  .metadata-grid {
    grid-template-columns: 1fr;
  }
  
  .search-results-table .responsive-table-header {
    display: none; /* Hide header on mobile for card-style layout */
  }
}

/* ====================================================================
   ACCOUNT MODAL TAB NAVIGATION
   ==================================================================== */

.account-tabs {
  display: flex;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 0;
}

.account-tab {
  padding: 0.75rem 1.5rem;
  border-radius: 8px 8px 0 0;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
}

.account-tab:hover:not(:disabled) {
  background: var(--interactive-hover);
  color: var(--text-primary);
}

.account-tab.is-active {
  background: var(--interactive-primary);
  border-color: var(--interactive-primary);
  color: var(--text-on-primary);
  position: relative;
}

.account-tab.is-active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--interactive-primary);
}

.account-tab:disabled {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
}

.account-tab:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.tab-pane {
  display: none;
}

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

/* Account Modal - Flexbox Layout for Proper Height Management */
.account-modal {
  min-height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Modal section containing tabs should grow */
.account-modal > .modal-section:has(.account-tab-content) {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.account-modal .modal-section {
  margin-bottom: 0px;
}

.account-modal .action-group{
  margin-top: 0px;
}

/* Tab navigation should not grow */
.account-modal .account-tabs {
  flex-shrink: 0;
}

/* Account tab content container should grow but NOT scroll */
.account-modal .account-tab-content {
  flex: 1;
  overflow: hidden; /* NOT auto - tables inside will scroll */
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Tab panes should grow to fill space */
.account-modal .tab-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.account-modal .tab-pane.active {
  display: flex;
}

/* Search controls should not grow */
.account-modal .inline-search-group {
  flex-shrink: 0;
}

/* The ACTUAL table container should scroll */
.account-modal .data-table-container {
  flex: 1;
  max-height: none !important;
  overflow-y: auto;              /* Vertical scroll enabled */
  overflow-x: hidden;            /* NO horizontal scroll */
  border: 1px solid var(--border-subtle);
  min-height: 0;
}

/* Footer and header sections must not shrink - always visible */
.account-modal > .modal-section:not(:has(.account-tab-content)) {
  flex-shrink: 0;
}

.account-modal > h2 {
  flex-shrink: 0;
}


.account-modal .doc-input {
  border-radius: 4px;
}

/* Base styles for locked inputs to look like labels */
.doc-input.field-locked {
  background: transparent !important;
  border: none !important;
  padding: 0;
  color: #333; /* Regular text color */
  cursor: default;
  opacity: 1; /* Override default disabled opacity */
  font-size: 16px;
  height: auto;
}

.corpus-selector-btn.field-locked sl-button.doc-input::part(base), sl-button.filter-select::part(base) {
    justify-content: flex-start;
    width: 100%;
    border: none !important;
}

/* Removed global sticky header rule - was causing floating headers in chunking modal */

.users-data-table-container {
  margin-top: 0px;
  margin-bottom: 1rem;
  overflow-y: auto;
  max-height: 300px;
  border-radius: 4px !important;
  /* overflow: hidden; */
}

/*Hide overflow:hidden above to allow sticky headers to work*/
.users-data-table-container thead th{
  position: sticky !important;
  top: 0 !important;
  z-index: 1 !important;
}

/* Users Modal */
.users-form-group {
    display: flex;
    gap: var(--spacing-4);
    align-items: flex-end;
    flex-wrap: wrap;
    padding: var(--spacing-3) 0 var(--spacing-4) 0;
    margin-bottom: var(--spacing-4);
}

.users-modal .doc-input {
  padding: 8px;
  font-size: 14px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  color: var(--text-primary);
  background: var(--input-bg);
}

/* Override for Shoelace buttons with doc-input class */
.users-modal sl-button.doc-input,
.users-modal sl-dropdown .doc-input {
  background: transparent;
  border: none;
  padding: 0;
  height: 34px;
}

sl-button.doc-input::part(base), sl-button.filter-select::part(base) {
    justify-content: flex-start;
    width: 100%;
    height: 34px;
    align-items: anchor-center;
    font-size: 14px;
    font-family: inherit;

}

sl-button:hover::part(base) {
    background-color: var(--interactive-hover) !important;
    border-color: var(--interactive-hover) !important;
    color: var(--text-primary) !important;
}

/* Disabled state for Shoelace dropdown buttons (matches disabled input styling) */
sl-button.doc-input[disabled]::part(base) {
    background-color: var(--input-disabled-bg, #e9ecef) !important;
    color: var(--input-disabled-text, #999999) !important;
    cursor: not-allowed !important;
    opacity: 1 !important;
}

.users-modal thead {
  position: sticky;
  top: 0;
  z-index: 1;
}


/* Responsive Design for Account Modal */
@media (max-width: 768px) {
  .account-tabs {
    flex-direction: column;
    border-bottom: none;
  }

  .account-tab {
    border-radius: 6px;
    justify-content: center;
  }

  .account-tab.is-active::after {
    display: none;
  }

  .account-modal .data-table-container {
    max-height: none; /* Use flex-based sizing on mobile too */
  }
}

/* ====================================================================
   PROJECT MODAL TAB NAVIGATION
   ==================================================================== */

.project-tabs {
  display: flex;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 0;
  margin-bottom: 1rem;
}

.project-tab {
  padding: 0.75rem 1.5rem;
  border-radius: 8px 8px 0 0;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
}

.project-tab:hover:not(:disabled) {
  background: var(--interactive-hover);
  color: var(--text-primary);
}

.project-tab.is-active {
  background: var(--interactive-primary);
  border-color: var(--interactive-primary);
  color: var(--text-on-primary);
  position: relative;
}

.project-tab.is-active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--interactive-primary);
}

.project-tab:disabled,
.project-tab.tab-disabled {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
}

.project-tab:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Tab panels */
.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  background-color: var(--color-white);
}

/* Tab controls section (search, filters, etc.) */
.tab-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.tab-controls .search-input {
  flex: 1;
  min-width: 200px;
}

/* Tab content area */
.tab-content {
  overflow-y: auto;
  max-height: 400px !important;
  border: 1px solid var(--border-subtle);
  border-radius: 4px !important;
}

.project-documents-table thead {
  position: sticky;
  top: 0;
  z-index: 1;

}

/* Project Modal - Flexbox Layout for Proper Height Management */
.project-modal {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Direct children that should not grow - always visible */
.project-modal > h2,
.project-modal > form,
.project-modal > .project-tabs,
.project-modal > .modal-section {
  flex-shrink: 0;
}

/* Tab panel - MUST override .tab-panel.is-active specificity! */
.project-modal > .tab-panel.is-active {
  display: flex !important; /* Force flex over block from .tab-panel.is-active */
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Hide inactive tab panels properly */
.project-modal > .tab-panel:not(.is-active) {
  display: none;
}

/* Tab controls should not grow */
.project-modal .tab-controls {
  flex-shrink: 0;
}

/* Tab content wrapper must be constrained */
.project-modal .tab-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: none !important; /* Override global fixed 400px */
  border: none; /* Remove border from wrapper */
}

/* THE FIX: documentsTableContainer should scroll */
/* When AccordionTable renders native table element, container needs display: block with height constraint */
.project-modal #documentsTableContainer {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}

/* Override for AccordionTable (native table element) - must use display: block with height */
.project-modal #documentsTableContainer:has(.data-table) {
  display: block;
  height: 100%; /* Fill available flex space */
  overflow-y: auto;
}

/* Ensure the table inside takes full width but doesn't control height */
.project-modal #documentsTableContainer table.data-table {
  display: table !important;
  width: 100%;
  height: auto;
}

/* Users table should also scroll and display as table */
.project-modal .users-data-table-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  display: table;
  width: 100%;
}

/* Project modal specific data-table-container (fallback if used) */
.project-modal .data-table-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 4px !important;
  max-height: none !important;
}

/* Responsive Design for Project Modal */
@media (max-width: 768px) {
  .project-tabs {
    flex-direction: column;
    border-bottom: none;
  }

  .project-tab {
    border-radius: 6px;
    justify-content: center;
  }

  .project-tab.is-active::after {
    display: none;
  }

  .project-modal .data-table-container {
    max-height: 300px;
  }

  .tab-controls {
    flex-direction: column;
    gap: 0.5rem;
  }

  .tab-controls .search-input {
    width: 100%;
  }
}


/* ====================================================================
   USER MODAL TAB NAVIGATION
   ==================================================================== */

.user-tabs {
  display: flex;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 0;
  margin-bottom: 1rem;
}

.user-tab {
  padding: 0.75rem 1.5rem;
  border-radius: 8px 8px 0 0;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
}

.user-tab:hover:not(:disabled) {
  background: var(--interactive-hover);
  color: var(--text-primary);
}

.user-tab.is-active {
  background: var(--interactive-primary);
  border-color: var(--interactive-primary);
  color: var(--text-on-primary);
  position: relative;
}

.user-tab.is-active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--interactive-primary);
}

.user-tab:disabled {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
}

.user-tab:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.user-modal .permissions {
  margin-bottom: 4px
}

.user-modal input[type="checkbox"]:disabled {
  accent-color: #404040;
}

/* Responsive Design for User Modal */
@media (max-width: 768px) {
  .user-tabs {
    flex-direction: column;
    border-bottom: none;
  }

  .user-tab {
    border-radius: 6px;
    justify-content: center;
  }

  .user-tab.is-active::after {
    display: none;
  }
}

/* Permission tags/chips for user modal - styles now in tag.css */

/* ====================================================================
   CHILD MODAL STYLES
   ==================================================================== */
.user-modal ~ .accounts-modal.modal--form[style*="z-index"] {
  width: min(1000px, 90vw) !important;
}
.user-modal ~ .projects-modal.modal--form[style*="z-index"] {
  width: min(1000px, 90vw) !important;
}

.user-modal ~ .add-docchain-permission-modal, .add-corpus-permission-modal {
  width: min(700px, 90vw) !important;
}

.add-docchain-permission-modal .button-group, 
.add-corpus-permission-modal .button-group {
  margin-top: 1.5rem !important;
  margin-bottom: 0px !important;
}

/* ====================================================================
   ALPHABET FILTER BUTTONS (Accounts Modal)
   ==================================================================== */

.alphabet-filter-container {
  padding: var(--spacing-3);
  margin-bottom: 12px;
}

.alphabet-filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: space-between;
}

.alphabet-btn {
  min-width: 26px;
  height: 26px;
  padding: 4px 8px;
  background: var(--surface-default);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.alphabet-btn:hover {
  background: var(--interactive-hover);
  border-color: var(--interactive-primary);
  color: var(--interactive-primary);
}

.alphabet-btn--active {
  background: var(--interactive-primary) !important;
  border-color: var(--interactive-primary) !important;
  color: var(--text-on-primary) !important;
  font-weight: 600;
}

.alphabet-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* 0-9 button gets slightly more width */
.alphabet-btn[data-letter="0-9"] {
  min-width: 48px;
}

/* Responsive adjustments for alphabet filters */
@media (max-width: 768px) {
  .alphabet-filter-buttons {
    gap: 4px;
  }

  .alphabet-btn {
    min-width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .alphabet-btn[data-letter="0-9"] {
    min-width: 40px;
  }
}

@media (max-width: 480px) {
  .alphabet-filter-container {
    padding: var(--spacing-2);
  }

  .alphabet-filter-buttons {
    gap: 3px;
  }

  .alphabet-btn {
    min-width: 24px;
    height: 24px;
    font-size: 11px;
    padding: 2px 4px;
  }

  .alphabet-btn[data-letter="0-9"] {
    min-width: 36px;
  }
}

/* ====================================================================
   SHOELACE COMPONENT OVERRIDES
   ==================================================================== */

/* Shoelace Dropdown Overrides - Left-align text in form input buttons */
/* Applied to all sl-buttons with doc-input or filter-select class used as dropdown triggers */
sl-button.doc-input::part(base),
sl-button.filter-select::part(base) {
    justify-content: flex-start;
    width: 100%;
}

sl-button.doc-input::part(label),
sl-button.filter-select::part(label) {
    flex: 1 1 auto;
    text-align: left;
}


/* User Permission fields */
.add-user-perms {
  border-radius: 4px;
}

/* Fix Modal Tab Pane Padding Issue */
.modal .tab-pane {
  padding: 1rem 0px;
}

/* Tooltip Info Icon */
.fa-info-circle {
  cursor: help !important;
}

/* User Groups Modal Specific Styles */
.user-groups-modal, .user-group-add-modal { 
  width: min(500px, 90vw);
}

/* Shoelace Dropdown Panel Customization */

.add-docchain-permission-modal .process-selector-dropdown sl-menu,
.add-corpus-permission-modal .corpus-selector-dropdown sl-menu {
  width: 634px;
}

.users-modal .permission-filter-dropdown sl-menu {
  width: 200px;
}

/* Scope these to your specific dropdown too */
.add-corpus-permission-modal .corpus-selector-dropdown sl-dropdown,
.add-corpus-permission-modal .corpus-selector-dropdown sl-button,
.add-corpus-permission-modal .corpus-selector-dropdown sl-dropdown::part(panel) {
  width: 100%;
}

.date-column {
  min-width: 170px;
}

/* Account Modal - Base table settings */
.account-modal .data-table-container table {
  width: 100%;
  table-layout: fixed;  /* FORCE columns to respect widths */
}

/* Allow text wrapping in all table cells by default */
.account-modal .data-table-container table td {
  white-space: normal;
  word-wrap: break-word;
}

/* ========== USERS TABLE ========== */
/* Target the Users table specifically (in #usersTabContent) */
#usersTabContent .data-table-container table thead th:nth-child(1) { width: 12%; }  /* Username */
#usersTabContent .data-table-container table thead th:nth-child(2) { width: 28%; }  /* Email */
#usersTabContent .data-table-container table thead th:nth-child(3) { width: 30%; }  /* Role */
#usersTabContent .data-table-container table thead th:nth-child(4) { width: 18%; }  /* Created */
#usersTabContent .data-table-container table thead th:nth-child(5) { width: 12%; }  /* Actions */

/* Username - prevent mid-word breaks */
#usersTabContent .data-table-container table td:nth-child(1) {
  overflow-wrap: anywhere;  /* Break anywhere if needed, but prefer whole words */
}

/* Email - allow breaks at punctuation */
#usersTabContent .data-table-container table td:nth-child(2) {
  word-break: break-all;  /* Break at any character including @ and dots */
}

/* Role - normal word wrapping */
#usersTabContent .data-table-container table td:nth-child(3) {
  overflow-wrap: break-word;
}

/* ========== PROJECTS TABLE ========== */
/* Target the Projects table specifically (in #projectsTabContent) */
#projectsTabContent .data-table-container table thead th:nth-child(1) { width: 30%; }  /* Project Name */
#projectsTabContent .data-table-container table thead th:nth-child(2) { width: 15%; }  /* Code */
#projectsTabContent .data-table-container table thead th:nth-child(3) { width: 20%; }  /* Owner */
#projectsTabContent .data-table-container table thead th:nth-child(4) { width: 20%; }  /* Created */
#projectsTabContent .data-table-container table thead th:nth-child(5) { width: 15%; }  /* Actions */

/* Project Name - allow wrapping but prefer words */
#projectsTabContent .data-table-container table td:nth-child(1) {
  overflow-wrap: break-word;
}

/* ========== FILTER STATUS MESSAGE ========== */
/* Displays current filter state above tables in accounts modal */
.filter-status-message {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--surface-subtle);
  border-left: 3px solid var(--interactive-primary);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.filter-status-message i {
  color: var(--interactive-primary);
}

/* ====================================================================
   CHUNKING PREVIEW MODAL
   ==================================================================== */

.chunking-preview-modal {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;  /* Prevent modal itself from scrolling */
}

.chunking-preview-modal > h2,
.chunking-preview-modal > .modal__close,
.chunking-preview-modal > .modal__footer {
  flex-shrink: 0;  /* Keep header/footer fixed */
}

/* Modal content scrolls - ALL content scrolls together */
.chunking-preview-modal .modal__content {
  flex: 1;
  overflow-y: auto;  /* THIS SCROLLS ALL THE CONTENT */
  overflow-x: hidden;
  min-height: 0;
  padding: 1rem;
  gap: 0.75rem;
  display: flex;
  flex-direction: column;
}

/* Two-column grid for top sections (Document Info + Chunking Parameters) */
.chunking-preview-modal .modal-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Sections inside the grid get card styling */
.chunking-preview-modal .modal-section-grid .modal-section {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 1rem;
  background: var(--surface-subtle);
}

.chunking-preview-modal .modal-section-grid .modal-section h3 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Sections just stack naturally - no special overflow */
.chunking-preview-modal .modal-section {
  flex-shrink: 0;
}

/* Table container - NO OVERFLOW - modal__content handles scrolling */
.chunking-preview-modal .data-table-container {
  overflow: visible !important;
  max-height: none !important;
  border: none !important;
  margin: 0 !important;
}

/* Selected chunk section - NO scrollbar, modal__content handles it */
.chunking-preview-modal #selectedChunkSection {
  flex-shrink: 0;
}

/* Analytics Grid */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.analytics-card {
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.analytics-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.analytics-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Removed conflicting max-height rule - the table container now uses flex: 1 from line 2736 */

/* Chunking Table Styles */
.chunking-table .token-count,
.chunking-table .char-count {
  font-family: var(--font-family-mono);
  font-weight: 500;
}

.chunking-table .chunk-preview {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.4;
}

.chunking-table .responsive-table-row {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.chunking-table .responsive-table-row:hover {
  background-color: var(--surface-hover);
}

.chunking-table .responsive-table-row.selected {
  background-color: var(--surface-accent);
  border-left: 3px solid var(--interactive-primary);
}

/* Chunk Content Display */
.chunk-content-display {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--surface-default);
  overflow: hidden;
}

.chunk-content-display .chunk-metadata {
  display: flex;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.875rem;
}

.chunk-content-display .chunk-metadata strong {
  color: var(--text-primary);
}

.chunk-content-display .chunk-text {
  padding: 1rem;
  margin: 0;
  background: var(--surface-default);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-family-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Loading overlay */
.chunking-preview-modal .loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  z-index: 1000;
  border-radius: 10px;
}

.chunking-preview-modal .loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-subtle);
  border-top: 3px solid var(--interactive-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .chunking-preview-modal {
    max-width: 95vw !important;
  }

  .analytics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chunk-content-display .chunk-metadata {
    flex-direction: column;
    gap: 0.5rem;
  }
}