/* Loading placeholder styles */
.loading-placeholder {
  padding: var(--size-8) var(--size-4);
  text-align: center;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}

.loading-placeholder::after {
  content: '';
  display: inline-block;
  width: 40px;
  height: 40px;
  margin-top: var(--size-4);
  border: 4px solid var(--border-2);
  border-radius: 50%;
  border-top-color: var(--indigo-9);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Dark mode styles */
html[data-theme="dark"] .loading-placeholder::after {
  border-color: var(--border-2-dark);
  border-top-color: var(--indigo-6);
}

/* Global HTMX loading indicator */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
}

/* Page loading overlay */
#page-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(2px);
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: var(--size-3);
}

html[data-theme="dark"] #page-loader {
  background: rgba(15, 23, 42, 0.8);
}

#page-loader.htmx-request,
#page-loader.loading {
  display: flex;
}

.page-loader__spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-2);
  border-radius: 50%;
  border-top-color: var(--indigo-7);
  animation: spin 0.8s ease-in-out infinite;
}

html[data-theme="dark"] .page-loader__spinner {
  border-color: var(--border-2-dark);
  border-top-color: var(--indigo-5);
}

.page-loader__text {
  color: var(--text-2);
  font-size: var(--font-size-1);
}

html[data-theme="dark"] .page-loader__text {
  color: var(--text-2-dark);
}

/* Content area loading state */
#content-wrapper.htmx-request {
  position: relative;
  min-height: 200px;
}

#content-wrapper.htmx-request::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(1px);
  z-index: 100;
}

#content-wrapper.htmx-request::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-2);
  border-radius: 50%;
  border-top-color: var(--indigo-7);
  animation: spin 0.8s ease-in-out infinite;
  z-index: 101;
}

html[data-theme="dark"] #content-wrapper.htmx-request::before {
  background: rgba(15, 23, 42, 0.7);
}

html[data-theme="dark"] #content-wrapper.htmx-request::after {
  border-color: var(--border-2-dark);
  border-top-color: var(--indigo-5);
}

/* Table loading state */
.table-container.htmx-request,
.urls-section.htmx-request {
  position: relative;
  min-height: 100px;
}

.table-container.htmx-request::before,
.urls-section.htmx-request::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 10;
}

.table-container.htmx-request::after,
.urls-section.htmx-request::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-2);
  border-radius: 50%;
  border-top-color: var(--indigo-7);
  animation: spin 0.8s ease-in-out infinite;
  z-index: 11;
}

html[data-theme="dark"] .table-container.htmx-request::before,
html[data-theme="dark"] .urls-section.htmx-request::before {
  background: rgba(15, 23, 42, 0.7);
}

html[data-theme="dark"] .table-container.htmx-request::after,
html[data-theme="dark"] .urls-section.htmx-request::after {
  border-color: var(--border-2-dark);
  border-top-color: var(--indigo-5);
}

/* Inline spinner for buttons and small elements */
.spinner-inline {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
  opacity: 0.7;
}
