/* ══════════════════════════════════════════════════════════════
   TheBookFlight — Global UX System
   Toast notifications, loading overlays, connection monitor,
   error boundaries, and page transitions
   ══════════════════════════════════════════════════════════════ */

/* ── Toast Notification System ── */
.tbf-toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}
.tbf-toast {
  pointer-events: auto;
  background: #131b2f;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 320px;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  backdrop-filter: blur(20px);
  animation: tbf-toast-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.3s ease;
  font-family: 'Inter', sans-serif;
}
.tbf-toast--removing {
  animation: tbf-toast-out 0.3s ease forwards;
}
.tbf-toast__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.tbf-toast--error .tbf-toast__icon {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
}
.tbf-toast--success .tbf-toast__icon {
  background: rgba(16,185,129,0.12);
  color: #10b981;
}
.tbf-toast--warning .tbf-toast__icon {
  background: rgba(245,158,11,0.12);
  color: #f59e0b;
}
.tbf-toast--info .tbf-toast__icon {
  background: rgba(59,130,246,0.12);
  color: #3b82f6;
}
.tbf-toast__body { flex: 1; min-width: 0; }
.tbf-toast__title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}
.tbf-toast__msg {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  line-height: 1.5;
}
.tbf-toast__close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.tbf-toast__close:hover { color: #fff; background: rgba(255,255,255,0.06); }
.tbf-toast__action {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.tbf-toast__action:hover { background: rgba(255,255,255,0.1); }

.tbf-toast__progress {
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.tbf-toast__progress-bar {
  height: 100%;
  border-radius: 3px;
  animation: tbf-toast-progress 5s linear forwards;
}
.tbf-toast--error .tbf-toast__progress-bar { background: #ef4444; }
.tbf-toast--success .tbf-toast__progress-bar { background: #10b981; }
.tbf-toast--warning .tbf-toast__progress-bar { background: #f59e0b; }
.tbf-toast--info .tbf-toast__progress-bar { background: #3b82f6; }

@keyframes tbf-toast-in {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes tbf-toast-out {
  to { transform: translateX(100px) scale(0.95); opacity: 0; }
}
@keyframes tbf-toast-progress {
  from { width: 100%; }
  to { width: 0%; }
}

/* ── Full-Screen Loading Overlay ── */
.tbf-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,10,20,0.85);
  backdrop-filter: blur(12px);
  z-index: 99998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-family: 'Inter', sans-serif;
  animation: tbf-overlay-in 0.3s ease;
}
@keyframes tbf-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tbf-overlay__plane {
  font-size: 48px;
  animation: tbf-plane-fly 2s ease-in-out infinite;
}
@keyframes tbf-plane-fly {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-12px) rotate(5deg); }
}

.tbf-overlay__title {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  text-align: center;
}
.tbf-overlay__sub {
  font-size: 14px;
  color: rgba(255,255,255,0.45);
  text-align: center;
  max-width: 360px;
}

.tbf-overlay__dots {
  display: flex;
  gap: 8px;
}
.tbf-overlay__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(208,2,27,0.6);
  animation: tbf-dot-pulse 1.4s ease-in-out infinite;
}
.tbf-overlay__dot:nth-child(2) { animation-delay: 0.2s; }
.tbf-overlay__dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes tbf-dot-pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.2); opacity: 1; }
}

.tbf-overlay__cancel {
  margin-top: 20px;
  padding: 10px 24px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: none;
}
.tbf-overlay__cancel.visible { display: block; }
.tbf-overlay__cancel:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── Connection Lost Banner ── */
.tbf-offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999998;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  padding: 10px 20px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  animation: tbf-offline-slide 0.3s ease;
  box-shadow: 0 4px 20px rgba(239,68,68,0.3);
}
.tbf-offline-banner i { font-size: 16px; }
@keyframes tbf-offline-slide {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

.tbf-online-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999998;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  padding: 10px 20px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  animation: tbf-offline-slide 0.3s ease;
  box-shadow: 0 4px 20px rgba(16,185,129,0.3);
}

/* ── Page Transition ── */
.tbf-page-exit {
  animation: tbf-page-out 0.25s ease forwards;
}
@keyframes tbf-page-out {
  to { opacity: 0; transform: translateY(-8px) scale(0.99); }
}

/* ── Mobile Responsive Toasts ── */
@media (max-width: 640px) {
  .tbf-toast-container {
    top: auto;
    bottom: 16px;
    right: 12px;
    left: 12px;
  }
  .tbf-toast {
    min-width: unset;
    max-width: unset;
    width: 100%;
    border-radius: 14px;
    padding: 14px 16px;
  }
  .tbf-overlay__title { font-size: 18px; }
  .tbf-overlay__sub { font-size: 13px; padding: 0 20px; }
}
