/* =========================================================================
   Sokolink — UX feedback: loaders, skeletons & offline screen
   Styles only; js/ux-feedback.js builds every element. Kept tiny and
   dependency-free for cheap Android phones on slow connections.
   ========================================================================= */

/* ---- top progress bar (shows while any network request is in flight) ---- */
.sl-topbar {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0;
    background: var(--color-primary, #1a56db);
    box-shadow: 0 0 8px rgba(26, 86, 219, 0.6);
    z-index: 2000;
    opacity: 0;
    transition: width 0.2s ease, opacity 0.3s ease;
    pointer-events: none;
}
.sl-topbar.active { opacity: 1; }

/* ---- full-screen spinner overlay (for explicit blocking waits) ---- */
.sl-spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(1px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 1900;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.sl-spinner-overlay.active { opacity: 1; visibility: visible; }
.sl-spinner {
    width: 38px; height: 38px;
    border: 3px solid var(--color-gray-200, #e5e7eb);
    border-top-color: var(--color-primary, #1a56db);
    border-radius: 50%;
    animation: sl-spin 0.8s linear infinite;
}
.sl-spinner-overlay .sl-spinner-msg {
    font-size: var(--text-sm, 0.875rem);
    color: var(--color-gray-600, #4b5563);
    font-family: var(--font-sans, sans-serif);
}
@keyframes sl-spin { to { transform: rotate(360deg); } }

/* inline spinner you can drop anywhere */
.sl-spinner-sm {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid var(--color-gray-200, #e5e7eb);
    border-top-color: var(--color-primary, #1a56db);
    border-radius: 50%;
    animation: sl-spin 0.8s linear infinite;
    vertical-align: middle;
}

/* ---- skeleton placeholders (shimmer) ---- */
.sl-skel {
    position: relative;
    overflow: hidden;
    background: var(--color-gray-100, #f3f4f6);
    border-radius: 6px;
}
.sl-skel::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.65), transparent);
    animation: sl-shimmer 1.3s infinite;
}
@keyframes sl-shimmer { 100% { transform: translateX(100%); } }
.sl-skel-line { height: 12px; margin: 8px 0; }
.sl-skel-line.w-40 { width: 40%; }
.sl-skel-line.w-60 { width: 60%; }
.sl-skel-line.w-80 { width: 80%; }
.sl-skel-title { height: 18px; width: 50%; margin: 10px 0 14px; }
.sl-skel-card {
    border: 1px solid var(--color-gray-100, #f3f4f6);
    border-radius: var(--border-radius-lg, 10px);
    padding: 16px;
    margin: 10px 0;
}
.sl-skel-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--color-gray-100, #f3f4f6);
}
.sl-skel-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.sl-skel-grow { flex: 1; }

/* reduce motion for users who ask for it */
@media (prefers-reduced-motion: reduce) {
    .sl-spinner, .sl-spinner-sm { animation-duration: 1.4s; }
    .sl-skel::after { animation: none; }
}

/* ---- offline / connection-interrupted full screen ---- */
.sl-offline {
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, #0b2a66 0%, #1a56db 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    z-index: 2100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    font-family: var(--font-sans, sans-serif);
}
.sl-offline.active { opacity: 1; visibility: visible; }
.sl-offline-icon {
    width: 84px; height: 84px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
    margin-bottom: 20px;
    animation: sl-pulse 2s ease-in-out infinite;
}
@keyframes sl-pulse {
    0%,100% { transform: scale(1); opacity: 1; }
    50%     { transform: scale(1.06); opacity: 0.85; }
}
.sl-offline h2 { margin: 0 0 8px; font-size: 1.5rem; font-weight: 700; }
.sl-offline p  { margin: 0 0 6px; font-size: 1rem; max-width: 420px; line-height: 1.55; opacity: 0.92; }
.sl-offline .sl-offline-sub { font-size: 0.85rem; opacity: 0.7; margin-top: 2px; }
.sl-offline-actions { margin-top: 24px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.sl-offline-btn {
    border: none;
    border-radius: 999px;
    padding: 11px 22px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.sl-offline-btn.primary { background: #fff; color: #1a56db; }
.sl-offline-btn.primary:hover { background: #eef2ff; }
.sl-offline-btn.ghost { background: rgba(255,255,255,0.14); color: #fff; }
.sl-offline-btn.ghost:hover { background: rgba(255,255,255,0.24); }
.sl-offline-btn[disabled] { opacity: 0.6; cursor: default; }
.sl-offline-retrying { margin-top: 16px; font-size: 0.85rem; opacity: 0.85; min-height: 20px; }

/* thin “back online” toast */
.sl-net-toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%) translateY(140%);
    background: var(--color-success, #057a5f);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    z-index: 2050;
    transition: transform 0.3s ease;
    font-family: var(--font-sans, sans-serif);
}
.sl-net-toast.show { transform: translateX(-50%) translateY(0); }
