/* =========================================================
   Shopij Smart Page Preloader — styles
   Self-contained (no Tailwind dependency) so it works even
   before the page's own CSS/JS has finished loading.
   ========================================================= */

#shopij-preloader {
  --sp-primary: #004ac6;
  --sp-primary-dark: #003ea8;
  --sp-on-primary: #ffffff;
  --sp-bg: #f8f9ff;
  --sp-on-surface: #0b1c30;
  --sp-on-surface-variant: #434655;
  --sp-outline: #c3c6d7;
  --sp-error-bg: #fff1f0;
  --sp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;

  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sp-bg);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.28s ease;
}

#shopij-preloader.sp-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0s linear 0.28s;
}

#shopij-preloader .sp-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px;
  max-width: 320px;
  font-family: var(--sp-font);
}

/* Only the panel matching the overlay's current state is shown */
#shopij-preloader[data-active-state="loading"] .sp-panel[data-state="loading"],
#shopij-preloader[data-active-state="offline"] .sp-panel[data-state="offline"],
#shopij-preloader[data-active-state="error"] .sp-panel[data-state="error"] {
  display: flex;
  animation: sp-fade-in 0.2s ease;
}

@keyframes sp-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Loading state ---------- */
.sp-logo-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.sp-spinner {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(0, 74, 198, 0.15);
  border-top-color: var(--sp-primary);
  animation: sp-spin 0.9s linear infinite;
}

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

.sp-logo {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--sp-primary);
}

.sp-dots {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.sp-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sp-primary);
  opacity: 0.35;
  animation: sp-dot-bounce 1.1s ease-in-out infinite;
}

.sp-dots span:nth-child(2) { animation-delay: 0.15s; }
.sp-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sp-dot-bounce {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}

/* ---------- Text ---------- */
.sp-text {
  margin: 0;
  font-size: 14px;
  color: var(--sp-on-surface-variant);
}

.sp-title {
  margin: 4px 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--sp-on-surface);
}

.sp-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
}

/* ---------- Buttons ---------- */
.sp-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
  justify-content: center;
}

.sp-btn {
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 9999px;
  font-family: inherit;
  transition: transform 0.15s ease, background 0.15s ease;
}

.sp-btn:active { transform: scale(0.96); }

.sp-btn-primary {
  background: var(--sp-primary);
  color: var(--sp-on-primary);
}

.sp-btn-primary:hover { background: var(--sp-primary-dark); }

.sp-btn-secondary {
  background: transparent;
  color: var(--sp-primary);
  border: 1.5px solid var(--sp-outline);
}

/* ---------- Accessibility ---------- */
.sp-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .sp-spinner { animation: none; opacity: 0.85; }
  .sp-dots span { animation: none; opacity: 0.6; }
  .sp-panel { animation: none !important; }
  #shopij-preloader,
  #shopij-preloader.sp-hidden {
    transition: opacity 0.01s linear;
  }
}

/* ---------- Small screens ---------- */
@media (max-width: 380px) {
  .sp-logo-wrap { width: 72px; height: 72px; }
  #shopij-preloader .sp-panel { padding: 16px; max-width: 280px; }
}
