/* ========================================
   Supermarkets Dashboard – Custom Styles
   ======================================== */

/* Base transitions */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft 0.3s ease-out;
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out;
}

.animate-pulse-soft {
  animation: pulse-soft 2s ease-in-out infinite;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.5rem;
}

.dark .skeleton {
  background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
  background-size: 200% 100%;
}

/* RTL support */
[dir="rtl"] .sidebar {
  right: 0;
  left: auto;
}

[dir="rtl"] .translate-x-full {
  transform: translateX(100%);
}

[dir="rtl"] .-translate-x-full {
  transform: translateX(-100%);
}

/* Stat card hover effect */
.stat-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 10px -5px rgba(0, 0, 0, 0.04);
}

.dark .stat-card:hover {
  box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.3), 0 4px 10px -5px rgba(0, 0, 0, 0.2);
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.dark ::-webkit-scrollbar-thumb {
  background: #4b5563;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

/* Table styles */
.products-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.products-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s;
}

.products-table thead th:hover {
  background-color: #f3f4f6;
}

.dark .products-table thead th:hover {
  background-color: #374151;
}

.products-table tbody tr {
  transition: background-color 0.15s;
  cursor: pointer;
}

.products-table tbody tr:hover {
  background-color: #f9fafb;
}

.dark .products-table tbody tr:hover {
  background-color: #1f2937;
}

.products-table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid #f3f4f6;
}

.dark .products-table td {
  border-bottom-color: #1f2937;
}

/* AI match badge */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 9999px;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Sort indicator */
.sort-indicator {
  display: inline-flex;
  margin-inline-start: 0.25rem;
  opacity: 0.5;
  transition: opacity 0.15s, transform 0.15s;
}

.sort-indicator.active {
  opacity: 1;
}

.sort-indicator.desc {
  transform: rotate(180deg);
}

/* Pagination */
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.5rem;
  transition: all 0.15s;
}

.pagination-btn:hover:not(:disabled) {
  background-color: #f3f4f6;
}

.dark .pagination-btn:hover:not(:disabled) {
  background-color: #374151;
}

.pagination-btn.active {
  background-color: #4f46e5;
  color: white;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Health indicator dot */
.health-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  display: inline-block;
  flex-shrink: 0;
}

.health-dot.healthy {
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.health-dot.degraded {
  background-color: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.health-dot.unhealthy {
  background-color: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

/* Circuit breaker visual */
.circuit-breaker {
  position: relative;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid;
  transition: all 0.2s;
}

.circuit-breaker.closed {
  border-color: #d1fae5;
  background-color: #ecfdf5;
}

.dark .circuit-breaker.closed {
  border-color: #065f46;
  background-color: rgba(16, 185, 129, 0.1);
}

.circuit-breaker.open {
  border-color: #fecaca;
  background-color: #fef2f2;
}

.dark .circuit-breaker.open {
  border-color: #991b1b;
  background-color: rgba(239, 68, 68, 0.1);
}

.circuit-breaker.half-open {
  border-color: #fde68a;
  background-color: #fffbeb;
}

.dark .circuit-breaker.half-open {
  border-color: #92400e;
  background-color: rgba(245, 158, 11, 0.1);
}

/* DLQ error detail */
.error-detail {
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background-color: #1f2937;
  color: #f87171;
  overflow-x: auto;
  max-height: 200px;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  height: 1.5rem;
  width: 2.75rem;
  align-items: center;
  border-radius: 9999px;
  transition: background-color 0.2s;
  cursor: pointer;
}

.toggle-switch .toggle-dot {
  display: inline-block;
  height: 1rem;
  width: 1rem;
  border-radius: 9999px;
  background-color: white;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Tooltip */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 0.5rem;
  background-color: #1f2937;
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 50;
}

.tooltip:hover::after {
  opacity: 1;
}

/* Progress bar */
.progress-bar {
  height: 0.375rem;
  border-radius: 9999px;
  background-color: #e5e7eb;
  overflow: hidden;
}

.dark .progress-bar {
  background-color: #374151;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.5s ease-out;
}

/* Focus styles */
*:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* Print styles */
@media print {
  .sidebar,
  header,
  .toast-container {
    display: none !important;
  }

  main {
    margin: 0 !important;
  }
}
