/* ============================================
   UX V3-C — Surcharges profondes (Juillet 2026)
   - Bottom sheets pour mobile-native feel
   - Empty states engageants
   - Quick Actions contextuelles
   - Onboarding wizard progressif
   - Offline indicator
   - Pull-to-refresh
   - INP opt : content-visibility, idle paints
   ============================================ */

/* === Variables étendues === */
:root {
    --sheet-bg: rgba(13, 17, 23, 0.98);
    --sheet-handle: rgba(255, 255, 255, 0.22);
    --neon-warn: #fbbf24;
    --neon-danger: #f87171;
    --neon-success: #4ade80;
    --ink-soft: rgba(255, 255, 255, 0.55);
    --ink-muted: rgba(255, 255, 255, 0.38);
    --ease-out-spring: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* === 1. CONTENT-VISIBILITY pour INP === */
.glass-card,
.tab-content > div,
.weekly-stat,
.badges-grid > div {
    content-visibility: auto;
    contain-intrinsic-size: 1px 200px;
}

/* === 2. Bottom Sheet System === */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms var(--ease-out-spring);
}
.sheet-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}
.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--sheet-bg);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border: 1px solid var(--glass-border);
    border-bottom: none;
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.65);
    z-index: 9501;
    transform: translateY(100%);
    transition: transform 380ms var(--ease-out-spring);
    max-height: 86vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 20px max(24px, env(safe-area-inset-bottom));
}
.bottom-sheet.visible {
    transform: translateY(0);
}
.bottom-sheet::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--sheet-handle);
    border-radius: 4px;
    margin: 6px auto 18px;
}
.bottom-sheet h3 {
    font-family: 'Rajdhani', system-ui;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-size: 1.15rem;
    color: var(--neon-core);
    margin-bottom: 12px;
}

/* === 3. (retiré) Quick Actions contextuels — supprimé === */

/* === 4. Empty States engageants === */
.empty-state {
    text-align: center;
    padding: 40px 24px;
    color: var(--ink-soft);
}
.empty-state-svg {
    width: 88px;
    height: 88px;
    margin: 0 auto 16px;
    opacity: 0.7;
    filter: drop-shadow(0 0 12px rgba(200, 255, 58, 0.18));
}
.empty-state h4 {
    font-family: 'Rajdhani', system-ui;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 6px;
    letter-spacing: 0.04em;
}
.empty-state p {
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 16px;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}
.empty-state-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(200, 255, 58, 0.18), rgba(74, 222, 128, 0.12));
    border: 1px solid rgba(200, 255, 58, 0.45);
    color: var(--neon-core);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}
.empty-state-cta:active { transform: scale(0.96); }

/* === 5. Offline Indicator === */
.offline-indicator {
    position: fixed;
    top: max(76px, calc(env(safe-area-inset-top) + 70px));
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    background: rgba(251, 191, 36, 0.18);
    color: var(--neon-warn);
    border: 1px solid rgba(251, 191, 36, 0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 9400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease, transform 300ms ease;
    display: flex;
    align-items: center;
    gap: 6px;
}
.offline-indicator.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.offline-indicator::before {
    content: '⚡';
    font-size: 0.85rem;
}

/* === 6. Pull-to-Refresh === */
.ptr-indicator {
    position: fixed;
    top: max(80px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(7, 9, 13, 0.95);
    border: 2px solid rgba(200, 255, 58, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    z-index: 9300;
    opacity: 0;
    transition: opacity 200ms ease, transform 250ms var(--ease-out-spring);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.ptr-indicator.visible { opacity: 1; }
.ptr-indicator.spinning { animation: ptrSpin 800ms linear infinite; }
@keyframes ptrSpin {
    from { transform: translateX(-50%) translateY(0) rotate(0deg); }
    to   { transform: translateX(-50%) translateY(0) rotate(360deg); }
}

/* === 7. (retiré) Voice Button FAB — supprimé === */

/* === 8. Tab transitions fluides === */
.tab-content {
    animation: tabSlideIn 320ms var(--ease-out-spring);
}
@keyframes tabSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === 9. (retiré) ancien Onboarding Wizard — supprimé === */

/* === 10. Form grouping pour réduire la charge cognitive === */
.form-group-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color var(--transition), background var(--transition);
}
.form-group-card:hover {
    border-color: rgba(200, 255, 58, 0.22);
}
.form-group-card-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--neon-core);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

/* === 11. (retiré) Smart "Heure" hint — supprimé === */

/* === 12. Badges gamification pulse === */
.badge-unlocked-pulse {
    animation: badgeUnlock 1.2s var(--ease-in-out-spring);
}
@keyframes badgeUnlock {
    0%   { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(200, 255, 58, 0.7); }
    60%  { transform: scale(1.08); box-shadow: 0 0 0 16px rgba(200, 255, 58, 0); }
    100% { transform: scale(1); }
}

/* === 13. Skeleton amélioré : shimmer signature === */
.skel-bar {
    background: linear-gradient(90deg,
        rgba(200, 255, 58, 0.04) 0%,
        rgba(200, 255, 58, 0.14) 50%,
        rgba(200, 255, 58, 0.04) 100%) !important;
    background-size: 200% 100% !important;
}

/* === 14. Safe area + notch pour iPhone 15 Pro === */
@supports (padding: max(0px)) {
    .tab-system {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }
}

/* === 15. Reduce data : mode économie === */
@media (prefers-reduced-data: reduce) {
    .top-header { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(7, 9, 13, 0.98) !important; }
    .tab-system { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* === 16. Focus mode (quand l'utilisateur répond) === */
.focus-mode .top-header,
.focus-mode .tab-system {
    opacity: 0.25;
    transition: opacity 400ms ease;
}
.focus-mode .glass-card {
    box-shadow: 0 12px 40px rgba(200, 255, 58, 0.15), var(--shadow-card);
    border-color: rgba(200, 255, 58, 0.4) !important;
}

/* === 17. Haptic visual feedback (au-delà du ripple) === */
.haptic-tap {
    position: relative;
    overflow: hidden;
}

/* === 18. Amélioration scrollbar desktop === */
@media (min-width: 768px) {
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb {
        background: rgba(200, 255, 58, 0.18);
        border-radius: 10px;
        border: 2px solid var(--bg-deep);
    }
    ::-webkit-scrollbar-thumb:hover { background: rgba(200, 255, 58, 0.35); }
}

/* === 19. Program card (sortie générateur) === */
.program-gen-card {
    background: linear-gradient(135deg, rgba(200, 255, 58, 0.08), rgba(74, 222, 128, 0.04));
    border: 1px solid rgba(200, 255, 58, 0.3);
    border-radius: var(--radius-card);
    padding: 24px;
    margin: 16px 0;
    position: relative;
    overflow: hidden;
    animation: tabSlideIn 500ms var(--ease-out-spring);
}
.program-gen-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(200, 255, 58, 0.08) 50%, transparent 100%);
    animation: progGenShine 2.4s ease-out;
    pointer-events: none;
}
@keyframes progGenShine {
    from { transform: translateX(0); }
    to   { transform: translateX(50%); }
}

/* === 20. Program generation loading étapes === */
.gen-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 0;
}
.gen-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--ink-muted);
    transition: color 400ms ease;
}
.gen-step.done { color: var(--neon-success); }
.gen-step.active { color: #fff; font-weight: 600; }
.gen-step-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
    transition: background 400ms ease;
}
.gen-step.done .gen-step-icon { background: rgba(74, 222, 128, 0.18); }
.gen-step.active .gen-step-icon {
    background: rgba(200, 255, 58, 0.18);
    animation: genStepPulse 1s ease-in-out infinite;
}
@keyframes genStepPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(200, 255, 58, 0.5); }
    50%      { box-shadow: 0 0 0 8px rgba(200, 255, 58, 0); }
}

