/* 
 * Enhanced UI Components for WashU Car Wash Portal
 * Modern, polished components with sophisticated interactions
 * Following 8px spacing system and consistent design language
 */

/* ===== ENHANCED KPI TILES ===== */

.kpi-tile {
  --kpi-bg: linear-gradient(135deg, #ffffff 0%, #f8fafe 100%);
  --kpi-border: var(--brand-primary-08, var(--primary-08, rgba(19, 150, 212, 0.08)));
  --kpi-shadow: 0 4px 20px var(--brand-primary-08, var(--primary-08, rgba(19, 150, 212, 0.08)));
  
  position: relative;
  background: var(--kpi-bg);
  border: 1px solid var(--kpi-border);
  border-radius: 20px;
  padding: 24px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}

.kpi-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi-tile:hover::before {
  transform: scaleX(1);
}

.kpi-tile::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--brand-primary-05, var(--primary-05, rgba(19, 150, 212, 0.05))), transparent);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.kpi-tile:hover::after {
  opacity: 1;
  animation: kpi-pulse 2s ease-in-out infinite;
}

@keyframes kpi-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(180deg); }
}

.kpi-tile:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px var(--brand-primary-15, var(--primary-15, rgba(19, 150, 212, 0.15)));
  border-color: var(--primary);
}

/* KPI Icon */
.kpi-icon-wrapper {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.kpi-icon-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  opacity: 1;
  transition: opacity 0.3s ease;
}

.kpi-icon-wrapper::after {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  border-radius: 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.kpi-tile:hover .kpi-icon-wrapper::after {
  opacity: 1;
  animation: icon-glow 2s ease-in-out infinite;
}

@keyframes icon-glow {
  0%, 100% { filter: blur(10px); }
  50% { filter: blur(20px); }
}

.kpi-icon {
  position: relative;
  z-index: 1;
  color: white;
  font-size: 28px;
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.kpi-tile:hover .kpi-icon {
  transform: scale(1.2) rotate(10deg);
}

/* KPI Value with Count Animation */
.kpi-value-wrapper {
  margin-bottom: 12px;
}

.kpi-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
  line-height: 1;
  display: inline-block;
  position: relative;
}

.kpi-value[data-animated="true"] {
  animation: value-count-up 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes value-count-up {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    filter: blur(4px);
  }
  50% {
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.kpi-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* KPI Progress Bar */
.kpi-progress-wrapper {
  position: relative;
  margin-top: auto;
}

.kpi-progress {
  height: 8px;
  background: var(--brand-primary-10, var(--primary-10, rgba(19, 150, 212, 0.1)));
  border-radius: 100px;
  overflow: visible;
  position: relative;
}

.kpi-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 100px;
  position: relative;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px var(--brand-primary-30, var(--primary-30, rgba(19, 150, 212, 0.3)));
}

.kpi-progress-bar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: white;
  border: 3px solid var(--primary);
  border-radius: 50%;
  box-shadow: 0 2px 8px var(--brand-primary-40, var(--primary-40, rgba(19, 150, 212, 0.4)));
  animation: progress-pulse 2s ease-in-out infinite;
}

@keyframes progress-pulse {
  0%, 100% { transform: translateY(-50%) scale(1); }
  50% { transform: translateY(-50%) scale(1.2); }
}

/* KPI Trend Indicator */
.kpi-trend {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.kpi-trend.up {
  background: var(--brand-success-10, rgba(34, 197, 94, 0.1));
  color: var(--brand-success, #22c55e);
}

.kpi-trend.down {
  background: var(--brand-danger-10, rgba(239, 68, 68, 0.1));
  color: var(--brand-danger, #ef4444);
}

.kpi-trend.neutral {
  background: var(--brand-muted-10, rgba(107, 114, 128, 0.1));
  color: var(--brand-muted, #6b7280);
}

.kpi-trend i {
  font-size: 14px;
  animation: trend-bounce 2s ease-in-out infinite;
}

@keyframes trend-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* ===== ENHANCED DASHBOARD CARDS ===== */

.dashboard-card {
  background: white;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.dashboard-card:hover {
  transform: translateY(-8px) scale(1.01);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

.dashboard-card-header {
  padding: 24px;
  background: linear-gradient(135deg, #f8fafe 0%, #f1f7ff 100%);
  border-bottom: 1px solid var(--brand-primary-08, var(--primary-08, rgba(19, 150, 212, 0.08)));
  position: relative;
  overflow: hidden;
}

.dashboard-card-header::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  transition: left 0.6s ease;
}

.dashboard-card:hover .dashboard-card-header::after {
  left: 100%;
}

.dashboard-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.dashboard-card-title i {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  font-size: 16px;
}

.dashboard-card-body {
  padding: 24px;
}

/* ===== FILTER BAR ===== */

.filter-bar {
  border-radius: 16px;
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  position: sticky;
  top: 80px;
  z-index: 100;
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 8px 40px rgba(0, 0, 0, 0.15),
    0 1px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(255, 255, 255, 0.2);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-select,
.filter-input {
  min-width: 140px;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s ease;
  background: white;
}

.filter-select:hover,
.filter-input:hover {
  border-color: var(--primary);
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--brand-primary-10, var(--primary-10, rgba(19, 150, 212, 0.1)));
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--primary);
  color: white;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.filter-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--brand-primary-30, var(--primary-30, rgba(19, 150, 212, 0.3)));
}

.filter-chip.inactive {
  background: white;
  color: var(--text-secondary);
  border-color: rgba(0, 0, 0, 0.1);
}

.filter-chip .remove {
  font-size: 16px;
  margin-left: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.filter-chip .remove:hover {
  opacity: 1;
}

/* ===== ENHANCED TABLES ===== */

.table-enhanced {
  width: 100%;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.table-enhanced thead {
  background: linear-gradient(135deg, #f8fafe 0%, #f1f7ff 100%);
  position: sticky;
  top: 0;
  z-index: 10;
}

.table-enhanced th {
  padding: 16px 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--brand-primary-10, var(--primary-10, rgba(19, 150, 212, 0.1)));
  white-space: nowrap;
}

.table-enhanced tbody tr {
  transition: background-color 0.2s ease !important;
  position: relative;
  transform: none !important;
}

.table-enhanced tbody tr::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: rgba(0, 0, 0, 0.05);
}

.table-enhanced tbody tr:hover {
  background: var(--brand-primary-02, var(--primary-02, rgba(19, 150, 212, 0.02))) !important;
  /* Use inset box-shadow for left indicator to avoid layout shift */
  box-shadow: inset 4px 0 0 var(--primary);
  transform: none !important;
}

/* Disable pseudo-element that can shift cells in some browsers */
.table-enhanced tbody tr:hover::before { content: none !important; }

.table-enhanced td {
  padding: 16px 20px;
  font-size: 14px;
  color: var(--text-primary);
}

/* Table Status Badges */
.table-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.table-status.active {
  background: var(--brand-success-10, rgba(34, 197, 94, 0.1));
  color: var(--brand-success, #22c55e);
}

.table-status.pending {
  background: var(--brand-warning-10, rgba(251, 191, 36, 0.1));
  color: var(--brand-warning, #f59e0b);
}

.table-status.inactive {
  background: var(--brand-muted-10, rgba(107, 114, 128, 0.1));
  color: var(--brand-muted, #6b7280);
}

.table-status.error {
  background: var(--brand-danger-10, rgba(239, 68, 68, 0.1));
  color: var(--brand-danger, #ef4444);
}

.table-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== ENHANCED FORMS ===== */

.form-group-enhanced {
  margin-bottom: 24px;
}

.form-label-enhanced {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  transition: color 0.2s ease;
}

.form-control-enhanced {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font-size: 14px;
  transition: all 0.3s ease;
  background: white;
}

.form-control-enhanced:hover {
  border-color: var(--brand-primary-30, var(--primary-30, rgba(19, 150, 212, 0.3)));
}

.form-control-enhanced:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--brand-primary-10, var(--primary-10, rgba(19, 150, 212, 0.1)));
  transform: translateY(-2px);
}

.form-control-enhanced:focus + .form-label-enhanced {
  color: var(--primary);
}

/* Floating Label */
.form-floating-enhanced {
  position: relative;
}

.form-floating-enhanced .form-control-enhanced {
  padding-top: 20px;
  padding-bottom: 8px;
}

.form-floating-enhanced .form-label-enhanced {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  transition: all 0.2s ease;
  pointer-events: none;
  background: white;
  padding: 0 4px;
}

.form-floating-enhanced .form-control-enhanced:focus ~ .form-label-enhanced,
.form-floating-enhanced .form-control-enhanced:not(:placeholder-shown) ~ .form-label-enhanced {
  top: 0;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--primary);
}

/* ===== SKELETON LOADERS ===== */

.skeleton-wrapper {
  padding: 20px;
}

.skeleton-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.skeleton-line {
  height: 12px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
  margin-bottom: 12px;
}

.skeleton-line.title {
  height: 24px;
  width: 40%;
  margin-bottom: 20px;
}

.skeleton-line.short {
  width: 60%;
}

.skeleton-line.medium {
  width: 80%;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.4s ease-in-out infinite;
}

.skeleton-chart {
  height: 300px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.4s ease-in-out infinite;
  border-radius: 12px;
}

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

/* ===== EMPTY STATES ===== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  width: 120px;
  height: 120px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
  border-radius: 50%;
  position: relative;
}

.empty-state-icon i {
  font-size: 48px;
  color: var(--text-secondary);
  opacity: 0.5;
}

.empty-state-icon::after {
  content: '';
  position: absolute;
  inset: -20px;
  border: 2px dashed rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  animation: rotate-slow 20s linear infinite;
}

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

.empty-state-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== TOOLTIPS ===== */

.tooltip-enhanced {
  position: relative;
}

.tooltip-enhanced::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: var(--text-primary);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 1000;
}

.tooltip-enhanced::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  border: 4px solid transparent;
  border-top-color: var(--text-primary);
  opacity: 0;
  transition: all 0.2s ease;
  pointer-events: none;
}

.tooltip-enhanced:hover::after,
.tooltip-enhanced:hover::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ===== SUCCESS/ERROR STATES ===== */

.success-state {
  animation: success-pulse 0.6s ease;
}

@keyframes success-pulse {
  0% { transform: scale(1); }
  50% { 
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
  }
  100% { transform: scale(1); }
}

.error-state {
  animation: error-shake 0.5s ease;
}

@keyframes error-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */

@media (max-width: 768px) {
  .kpi-tile {
    padding: 20px;
  }
  
  .kpi-value {
    font-size: 28px;
  }
  
  .dashboard-card-header {
    padding: 20px;
  }
  
  .dashboard-card-body {
    padding: 20px;
  }
  
  .filter-bar {
    padding: 12px;
    gap: 12px;
  }
  
  .table-enhanced th,
  .table-enhanced td {
    padding: 12px 16px;
  }
}
