/* Real-Time Data Synchronization CSS & Animations */

:root {
  --sync-connected: #10b981;
  --sync-reconnecting: #f59e0b;
  --sync-offline: #ef4444;
  --sync-glow: rgba(16, 185, 129, 0.35);
  --card-bg: rgba(22, 27, 34, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover-border: rgba(56, 189, 248, 0.4);
}

/* Connection Status Badge */
.connection-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  transition: all 0.3s ease;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  position: relative;
}

.connection-status-pill.status-CONNECTED {
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}
.connection-status-pill.status-CONNECTED .status-dot {
  background: var(--sync-connected);
  box-shadow: 0 0 10px var(--sync-connected);
}
.connection-status-pill.status-CONNECTED .status-dot::after {
  content: '';
  position: absolute;
  top: -3px; left: -3px; right: -3px; bottom: -3px;
  border-radius: 50%;
  border: 2px solid var(--sync-connected);
  animation: pulse-ring 1.8s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.connection-status-pill.status-RECONNECTING {
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}
.connection-status-pill.status-RECONNECTING .status-dot {
  background: var(--sync-reconnecting);
  animation: status-blink 1s infinite alternate;
}

.connection-status-pill.status-DISCONNECTED {
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.connection-status-pill.status-DISCONNECTED .status-dot {
  background: var(--sync-offline);
}

@keyframes pulse-ring {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

@keyframes status-blink {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

/* Cards Grid */
.realtime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* Real-time Item Card */
.realtime-item-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.realtime-item-card:hover {
  transform: translateY(-3px);
  border-color: var(--card-hover-border);
  box-shadow: 0 12px 40px rgba(56, 189, 248, 0.15);
}

/* Entrance & Exit Animations for Targeted DOM Updates */
.item-entering {
  animation: slide-in-down 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.item-deleting {
  animation: scale-out-fade 0.32s cubic-bezier(0.4, 0, 1, 1) forwards !important;
  pointer-events: none;
}

.item-highlight-flash {
  animation: highlight-glow 1.2s ease-out forwards;
}

@keyframes slide-in-down {
  0% {
    opacity: 0;
    transform: translateY(-25px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scale-out-fade {
  0% {
    opacity: 1;
    transform: scale(1);
    max-height: 250px;
  }
  100% {
    opacity: 0;
    transform: scale(0.85);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
  }
}

@keyframes highlight-glow {
  0% {
    border-color: #38bdf8;
    box-shadow: 0 0 25px rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.15);
  }
  100% {
    border-color: var(--card-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    background: var(--card-bg);
  }
}

/* Card Elements */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-category-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #38bdf8;
}

.item-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0;
  line-height: 1.35;
}

.card-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

/* Status Badges */
.item-status-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-pending { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }
.status-in-progress { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }
.status-completed { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.status-cancelled { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }

/* Priority Badges */
.item-priority-badge {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}
.priority-urgent { background: rgba(239, 68, 68, 0.25); color: #f87171; }
.priority-high { background: rgba(249, 115, 22, 0.25); color: #fb923c; }
.priority-medium { background: rgba(59, 130, 246, 0.25); color: #60a5fa; }
.priority-low { background: rgba(107, 114, 128, 0.25); color: #9ca3af; }

.item-description {
  font-size: 0.88rem;
  color: #94a3b8;
  line-height: 1.5;
  margin-bottom: 18px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.78rem;
  color: #64748b;
}

.meta-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.meta-info span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.version-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.72rem;
  color: #cbd5e1;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-icon.btn-delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

/* Toast Container & Alerts */
#realtime-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.realtime-toast {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  padding: 12px 16px;
  border-radius: 12px;
  color: #f8fafc;
  font-size: 0.88rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: toast-slide-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-success { border-left: 4px solid #10b981; }
.toast-info { border-left: 4px solid #38bdf8; }
.toast-warning { border-left: 4px solid #f59e0b; }
.toast-error { border-left: 4px solid #ef4444; }

.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-user {
  color: #38bdf8;
  font-weight: 600;
}

.toast-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

.toast-fade-out {
  animation: toast-fade-out 0.35s ease forwards;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-fade-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* Empty State */
.empty-state-box {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  background: var(--card-bg);
  border: 1px dashed var(--card-border);
  border-radius: 16px;
  color: #94a3b8;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  color: #38bdf8;
}
