/* =====================================================
   COMPONENTS - Reusable UI Components
   ===================================================== */

/* =====================================================
   STAT CARDS
   ===================================================== */

.stat-card {
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--stat-color, var(--bs-primary, #2563eb));
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
  font-size: 1.25rem;
}

.stat-card .stat-number,
.stat-card .number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--stat-color, var(--bs-primary, #2563eb));
}

.stat-card .stat-label,
.stat-card h4 {
  color: var(--bs-secondary-color, #6c757d);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  font-weight: 500;
}

/* Stat card color variants */
.stat-card--total,
.stat-card:nth-child(1)    { --stat-color: #2563eb; }
.stat-card--synced,
.stat-card:nth-child(2)    { --stat-color: #10b981; }
.stat-card--warning,
.stat-card:nth-child(3)    { --stat-color: #f59e0b; }
.stat-card--error,
.stat-card:nth-child(4)    { --stat-color: #ef4444; }

.stat-card .stat-icon {
  background: color-mix(in srgb, var(--stat-color, #2563eb) 12%, transparent);
  color: var(--stat-color, #2563eb);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* =====================================================
   TABLES
   ===================================================== */

.ds-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 8px;
  overflow: hidden;
}

.ds-table thead th {
  background: var(--bs-tertiary-bg, #f8f9fa);
  color: var(--bs-secondary-color, #6c757d);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--bs-border-color, #dee2e6);
  position: sticky;
  top: 0;
  z-index: 1;
}

.ds-table tbody tr {
  transition: background-color 0.15s ease;
}

.ds-table tbody tr:hover {
  background-color: var(--bs-tertiary-bg, rgba(0,0,0,0.02));
}

.ds-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0,0,0,0.05));
  font-size: 0.875rem;
  vertical-align: middle;
}

.ds-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table wrapper for horizontal scroll */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--bs-border-color, #dee2e6);
}

.table-wrapper .ds-table {
  border: none;
  border-radius: 0;
}

/* =====================================================
   TABS (unified)
   ===================================================== */

.ds-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--bs-border-color, #dee2e6);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.ds-tab {
  padding: 0.75rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--bs-secondary-color, #6c757d);
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color 0.15s ease;
  white-space: nowrap;
  font-size: 0.9375rem;
}

.ds-tab:hover {
  color: var(--bs-body-color, #212529);
}

.ds-tab.active {
  color: var(--bs-primary, #2563eb);
  font-weight: 600;
}

.ds-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bs-primary, #2563eb);
  border-radius: 1px 1px 0 0;
}

.ds-tab-content {
  display: none;
}

.ds-tab-content.active {
  display: block;
}

/* =====================================================
   STATUS BADGES
   ===================================================== */

.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}

.ds-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.ds-badge--synced,
.status-badge.status-synced {
  background: #d1fae5;
  color: #065f46;
}

.ds-badge--unsynced,
.status-badge.status-unsynced {
  background: #fee2e2;
  color: #991b1b;
}

.ds-badge--inconsistent,
.status-badge.status-inconsistent {
  background: #fef3c7;
  color: #92400e;
}

/* Dark mode badge overrides */
[data-bs-theme="dark"] .ds-badge--synced,
[data-bs-theme="dark"] .status-badge.status-synced {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

[data-bs-theme="dark"] .ds-badge--unsynced,
[data-bs-theme="dark"] .status-badge.status-unsynced {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

[data-bs-theme="dark"] .ds-badge--inconsistent,
[data-bs-theme="dark"] .status-badge.status-inconsistent {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

/* =====================================================
   FILTER BAR
   ===================================================== */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem;
  background: var(--bs-tertiary-bg, #f8f9fa);
  border-radius: 8px;
  border: 1px solid var(--bs-border-color, #dee2e6);
  margin-bottom: 1.5rem;
}

/* =====================================================
   PAGE CONTENT (layout wrapper)
   ===================================================== */

.page-content {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1rem;
}

@media (max-width: 768px) {
  .page-content {
    padding: 0 0.5rem;
  }
}

/* =====================================================
   PAGE HEADER
   ===================================================== */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-header__subtitle {
  color: var(--bs-secondary-color, #6c757d);
  font-size: 0.875rem;
  margin: 0.25rem 0 0 0;
}

.page-header__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* =====================================================
   EMPTY STATE
   ===================================================== */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bs-secondary-color, #6c757d);
}

.empty-state__icon {
  font-size: 3rem;
  opacity: 0.5;
  margin-bottom: 1rem;
  display: block;
}

.empty-state__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--bs-body-color);
}

.empty-state__text {
  font-size: 0.875rem;
}

/* =====================================================
   RESPONSE CONTAINER (API tests)
   ===================================================== */

.response-container {
  max-height: 400px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--bs-border-color, #dee2e6);
  padding: 1rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  background: var(--bs-tertiary-bg, #f8f9fa);
}

[data-bs-theme="dark"] .response-container {
  background: #1a1a2e;
}

/* =====================================================
   LOADING OVERLAY
   ===================================================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay__content {
  background: var(--bs-body-bg, #fff);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* =====================================================
   FOOTER
   ===================================================== */

.app-footer {
  background: var(--bs-tertiary-bg, #f8f9fa);
  border-top: 1px solid var(--bs-border-color, #dee2e6);
  color: var(--bs-secondary-color, #6c757d);
}

.app-footer a {
  color: var(--bs-primary, #2563eb);
}

/* =====================================================
   ENDPOINT CARDS (API test)
   ===================================================== */

.endpoint-card {
  border-left: 5px solid var(--bs-primary, #0d6efd);
  border-radius: 8px;
  margin-bottom: 1rem;
  transition: box-shadow 0.2s ease;
}

.endpoint-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.endpoint-card.method-get    { border-left-color: #0d6efd; }
.endpoint-card.method-post   { border-left-color: #198754; }
.endpoint-card.method-put    { border-left-color: #fd7e14; }
.endpoint-card.method-delete { border-left-color: #dc3545; }

.badge-method {
  width: 70px;
  text-align: center;
  font-family: monospace;
  font-weight: 600;
}

/* =====================================================
   DARK MODE OVERRIDES for inline-styled elements
   ===================================================== */

[data-bs-theme="dark"] .stat-card {
  background: var(--bs-body-bg);
  border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .stat-card h4 {
  color: var(--bs-secondary-color);
}

[data-bs-theme="dark"] .ds-table thead th {
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .ds-table tbody td {
  border-color: var(--bs-border-color-translucent);
}

[data-bs-theme="dark"] .filter-bar {
  background: var(--bs-tertiary-bg);
  border-color: var(--bs-border-color);
}

/* =====================================================
   CARD IMPROVEMENTS
   ===================================================== */

.card {
  border-radius: 8px;
  transition: box-shadow 0.25s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .page-header {
    flex-direction: column;
  }
  
  .ds-tabs {
    gap: 0;
  }
  
  .ds-tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
