/* ============================================================
   Swissapp Space — utilitaires + animations
   ============================================================ */

* { -webkit-font-smoothing: antialiased; }

/* ===== Splash screen ===== */
#loading-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #7f1d1d 0%, #e63946 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: white;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
#loading-screen .logo {
    margin-bottom: 1.2rem;
    animation: splashFloat 2s ease-in-out infinite;
}
#loading-screen .logo-circle {
    width: 90px; height: 90px;
    background: white;
    color: #e63946;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 3rem;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
#loading-screen .logo-name {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 2rem;
    text-align: center;
    line-height: 1;
}
#loading-screen .logo-name small {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.7;
    margin-top: 4px;
}
#loading-screen .loading-spinner {
    width: 2.5rem; height: 2.5rem;
    border: 3px solid rgba(255,255,255,0.25);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes splashFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ===== Common animations ===== */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes scaleIn { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.6; transform: scale(1.15); } }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }
@keyframes loadingBar { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.fade-in-up { animation: fadeInUp 0.5s ease-out forwards; }
.fade-in { animation: fadeIn 0.4s ease-out forwards; }
.slide-up { animation: slideUp 0.3s ease-out forwards; }
.scale-in { animation: scaleIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.pulse-dot { animation: pulse 2s infinite; }

.stagger-item { opacity: 0; transform: translateY(20px); animation: fadeInUp 0.5s ease-out forwards; }
.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.10s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.20s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.30s; }
.stagger-item:nth-child(7) { animation-delay: 0.35s; }
.stagger-item:nth-child(8) { animation-delay: 0.40s; }

/* ===== Skeleton ===== */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200px 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: 8px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 20px; left: 16px; right: 16px;
    padding: 14px 18px;
    border-radius: 16px;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 1100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.18);
    box-shadow: 0 16px 40px rgba(0,0,0,0.18);
    color: white;
    animation: toastIn 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 480px;
    margin: 0 auto;
}
.toast i { font-size: 1.05rem; flex-shrink: 0; }
.toast.success { background: linear-gradient(135deg, rgba(16,185,129,0.92), rgba(5,150,105,0.92)); }
.toast.error   { background: linear-gradient(135deg, rgba(239,68,68,0.92), rgba(220,38,38,0.92)); }
.toast.info    { background: linear-gradient(135deg, rgba(230,57,70,0.92), rgba(127,29,29,0.92)); }
.toast.slide-out { animation: toastOut 0.25s ease-in forwards; }

@keyframes toastIn { 0% { transform: translateY(-100%) scale(0.92); opacity: 0; } 100% { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes toastOut { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-100%); opacity: 0; } }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}
.modal-content {
    background: white;
    width: 100%;
    max-width: 480px;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 24px 24px 0 0;
    animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    -webkit-overflow-scrolling: touch;
}
@media (min-width: 640px) {
    .modal-overlay { align-items: center; }
    .modal-content { border-radius: 24px; max-height: 88vh; animation: scaleIn 0.25s ease-out; }
}

/* ===== Bottom nav ===== */
.bottom-nav {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid #e2e8f0;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px;
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: transparent;
}
.bottom-nav-item i { font-size: 1.25rem; transition: transform 0.15s; }
.bottom-nav-item.active { color: #e63946; }
.bottom-nav-item.active i { transform: scale(1.1); }

/* ===== Header ===== */
.app-header {
    background: linear-gradient(135deg, #7f1d1d 0%, #e63946 100%);
    color: white;
    padding: 14px 16px calc(14px + env(safe-area-inset-top)) 16px;
    padding-top: calc(14px + env(safe-area-inset-top));
}

/* ===== Tile (style src_my) ===== */
.sw-tile {
    background: #fff;
    border: 1px solid #d8d8d8;
    border-radius: 20px;
    padding: 24px 16px;
    text-align: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}
.sw-tile:hover, .sw-tile:active {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.10);
    border-color: #e63946;
}
.sw-tile-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, #e63946, #7f1d1d);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.sw-tile-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
}
.sw-tile-hint {
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.4;
    font-weight: 500;
}

/* ===== Card ===== */
.sw-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    overflow: hidden;
}

/* ===== Inputs ===== */
.sw-input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    transition: all 0.15s;
    outline: none;
}
.sw-input:focus {
    border-color: #e63946;
    box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.12);
}

/* ===== Buttons ===== */
.sw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 22px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1;
}
.sw-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.sw-btn-primary {
    background: linear-gradient(135deg, #e63946, #7f1d1d);
    color: white;
    box-shadow: 0 4px 14px rgba(230, 57, 70, 0.25);
}
.sw-btn-primary:active:not(:disabled) { transform: scale(0.98); }
.sw-btn-secondary {
    background: #f1f5f9;
    color: #1e293b;
}
.sw-btn-secondary:hover { background: #e2e8f0; }
.sw-btn-danger {
    background: #fee2e2;
    color: #991b1b;
}
.sw-btn-ghost {
    background: transparent;
    color: #64748b;
}

/* ===== Badge ===== */
.sw-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.sw-badge-success { background: #dcfce7; color: #166534; }
.sw-badge-warn    { background: #fef3c7; color: #92400e; }
.sw-badge-danger  { background: #fee2e2; color: #991b1b; }
.sw-badge-info    { background: #dbeafe; color: #1e40af; }
.sw-badge-neutral { background: #f1f5f9; color: #475569; }

/* ===== Stats card ===== */
.sw-stat {
    background: white;
    border-radius: 16px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.sw-stat-label { font-size: 0.65rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }
.sw-stat-value { font-size: 1.5rem; font-weight: 800; color: #0f172a; line-height: 1.1; }
.sw-stat-hint  { font-size: 0.72rem; color: #64748b; }

/* ===== Code/mono ===== */
.sw-mono {
    font-family: 'JetBrains Mono', 'Menlo', monospace;
    font-size: 0.78rem;
    background: #f8fafc;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    color: #475569;
    word-break: break-all;
}

/* ===== Scrollbar ===== */
.sw-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.sw-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ===== Loading bar (header skeleton) ===== */
.loading-bar {
    position: relative;
    overflow: hidden;
}
.loading-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: loadingBar 1.4s infinite;
}

/* ===== Hide scrollbar utility ===== */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* ===== iOS safe area ===== */
.safe-pb { padding-bottom: env(safe-area-inset-bottom); }
.safe-pt { padding-top: env(safe-area-inset-top); }
