/* ==========================================
   🍎 iOS-STYLE ANIMATIONS & EFFECTS
   iOS 16+ Inspired Fluid Animations
   ========================================== */

:root {
    /* iOS Spring Curves */
    --spring-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --spring-snappy: cubic-bezier(0.4, 0.0, 0.2, 1);
    --spring-bouncy: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --spring-elastic: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* iOS Durations */
    --duration-instant: 0.1s;
    --duration-quick: 0.2s;
    --duration-smooth: 0.35s;
    --duration-fluid: 0.5s;
    --duration-slow: 0.7s;
}

/* ==========================================
   1. CARD ANIMATIONS (iOS Style)
   ========================================== */

.ios-card {
    transform: scale(1);
    transition: all var(--duration-smooth) var(--spring-snappy);
    will-change: transform, box-shadow;
}

.ios-card:hover {
    transform: scale(1.02) translateY(-5px);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 0 60px rgba(156, 39, 176, 0.4);
}

.ios-card:active {
    transform: scale(0.98) translateY(0);
    transition: all var(--duration-instant) var(--spring-smooth);
}

/* Card Entry Animation */
@keyframes cardSlideIn {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ios-card-enter {
    animation: cardSlideIn var(--duration-fluid) var(--spring-elastic);
}

/* ==========================================
   2. BUTTON ANIMATIONS (iOS Style)
   ========================================== */

.ios-button {
    position: relative;
    overflow: hidden;
    transform: scale(1);
    transition: all var(--duration-quick) var(--spring-snappy);
    will-change: transform, box-shadow;
}

.ios-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width var(--duration-smooth) var(--spring-elastic),
                height var(--duration-smooth) var(--spring-elastic);
}

.ios-button:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(156, 39, 176, 0.4);
}

.ios-button:active {
    transform: scale(0.95);
    transition: all var(--duration-instant) var(--spring-smooth);
}

.ios-button:active::before {
    width: 300px;
    height: 300px;
}

/* Haptic Feedback Effect */
@keyframes hapticPulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.ios-button.haptic {
    animation: hapticPulse 0.15s var(--spring-snappy);
}

/* ==========================================
   3. MODAL ANIMATIONS (iOS Style)
   ========================================== */

@keyframes modalSlideUp {
    0% {
        opacity: 0;
        transform: translateY(100%);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modalFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.ios-modal {
    animation: modalSlideUp var(--duration-fluid) var(--spring-elastic);
    will-change: transform, opacity;
}

.ios-modal-content {
    animation: modalFadeIn var(--duration-smooth) var(--spring-snappy);
}

.ios-modal.closing {
    animation: modalSlideUp var(--duration-smooth) var(--spring-snappy) reverse;
}

/* Modal Backdrop */
.ios-backdrop {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    background: rgba(0, 0, 0, 0.4);
    animation: fadeIn var(--duration-smooth) var(--spring-smooth);
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* ==========================================
   4. LIST ANIMATIONS (iOS Style)
   ========================================== */

.ios-list-item {
    opacity: 0;
    transform: translateX(-20px);
    animation: listItemSlideIn var(--duration-smooth) var(--spring-elastic) forwards;
}

@keyframes listItemSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Stagger Animation */
.ios-list-item:nth-child(1) { animation-delay: 0s; }
.ios-list-item:nth-child(2) { animation-delay: 0.05s; }
.ios-list-item:nth-child(3) { animation-delay: 0.1s; }
.ios-list-item:nth-child(4) { animation-delay: 0.15s; }
.ios-list-item:nth-child(5) { animation-delay: 0.2s; }
.ios-list-item:nth-child(6) { animation-delay: 0.25s; }
.ios-list-item:nth-child(7) { animation-delay: 0.3s; }
.ios-list-item:nth-child(8) { animation-delay: 0.35s; }

/* Swipe Gesture Effect */
.ios-list-item.swiping {
    transform: translateX(-80px);
    transition: transform var(--duration-smooth) var(--spring-snappy);
}

.ios-list-item.swiping .delete-action {
    opacity: 1;
    transform: scale(1);
}

/* ==========================================
   5. TAB BAR ANIMATIONS (iOS Style)
   ========================================== */

.ios-tab-bar {
    position: relative;
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    background: rgba(255, 255, 255, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ios-tab-item {
    position: relative;
    transition: all var(--duration-quick) var(--spring-snappy);
    transform: scale(1);
}

.ios-tab-item:active {
    transform: scale(0.9);
}

.ios-tab-item.active {
    color: var(--primary-color);
}

.ios-tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 80%;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
    animation: tabIndicatorExpand var(--duration-smooth) var(--spring-elastic) forwards;
}

@keyframes tabIndicatorExpand {
    0% { transform: translateX(-50%) scaleX(0); }
    100% { transform: translateX(-50%) scaleX(1); }
}

/* Tab Switch Animation */
.ios-tab-content {
    animation: tabContentFade var(--duration-smooth) var(--spring-snappy);
}

@keyframes tabContentFade {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   6. NAVBAR ANIMATIONS (iOS Style)
   ========================================== */

.ios-navbar {
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateY(0);
    transition: transform var(--duration-smooth) var(--spring-snappy);
}

.ios-navbar.hidden {
    transform: translateY(-100%);
}

.ios-navbar-item {
    position: relative;
    transition: all var(--duration-quick) var(--spring-snappy);
}

.ios-navbar-item::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 100%;
    height: 2px;
    background: var(--primary-color);
    border-radius: 2px;
    transition: transform var(--duration-smooth) var(--spring-elastic);
}

.ios-navbar-item:hover::before,
.ios-navbar-item.active::before {
    transform: translateX(-50%) scaleX(1);
}

.ios-navbar-item:active {
    transform: scale(0.95);
}

/* ==========================================
   7. INPUT ANIMATIONS (iOS Style)
   ========================================== */

.ios-input {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: all var(--duration-smooth) var(--spring-snappy);
}

.ios-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(156, 39, 176, 0.2);
    transform: scale(1.02);
}

.ios-input:focus + .ios-label {
    transform: translateY(-25px) scale(0.85);
    color: var(--primary-color);
}

.ios-label {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    transition: all var(--duration-smooth) var(--spring-elastic);
    pointer-events: none;
    color: rgba(255, 255, 255, 0.6);
}

/* ==========================================
   8. TOGGLE SWITCH (iOS Style)
   ========================================== */

.ios-switch {
    position: relative;
    width: 51px;
    height: 31px;
    background: rgba(120, 120, 128, 0.32);
    border-radius: 16px;
    cursor: pointer;
    transition: all var(--duration-smooth) var(--spring-snappy);
}

.ios-switch::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    transition: all var(--duration-smooth) var(--spring-elastic);
}

.ios-switch.active {
    background: var(--primary-color);
}

.ios-switch.active::before {
    transform: translateX(20px);
}

.ios-switch:active::before {
    width: 30px;
}

/* ==========================================
   9. BADGE ANIMATIONS (iOS Style)
   ========================================== */

.ios-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    transform: scale(0);
    animation: badgePop var(--duration-smooth) var(--spring-bouncy) forwards;
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.ios-badge.pulse {
    animation: badgePulse 2s var(--spring-smooth) infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(156, 39, 176, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(156, 39, 176, 0);
    }
}

/* ==========================================
   10. SKELETON LOADING (iOS Style)
   ========================================== */

.ios-skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 2s ease-in-out infinite;
    border-radius: 12px;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================
   11. NOTIFICATION BANNER (iOS Style)
   ========================================== */

.ios-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translate(-50%, -120%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 15px 20px;
    min-width: 300px;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    animation: notificationSlideDown var(--duration-fluid) var(--spring-elastic) forwards;
}

@keyframes notificationSlideDown {
    0% {
        transform: translate(-50%, -120%);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.ios-notification.dismissing {
    animation: notificationSlideUp var(--duration-smooth) var(--spring-snappy) forwards;
}

@keyframes notificationSlideUp {
    0% {
        transform: translate(-50%, 0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -120%);
        opacity: 0;
    }
}

/* ==========================================
   12. CONTEXT MENU (iOS Style)
   ========================================== */

.ios-context-menu {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    transform: scale(0.9);
    opacity: 0;
    animation: contextMenuPop var(--duration-smooth) var(--spring-elastic) forwards;
}

@keyframes contextMenuPop {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.ios-context-menu-item {
    padding: 12px 16px;
    border-radius: 8px;
    transition: all var(--duration-quick) var(--spring-snappy);
    cursor: pointer;
}

.ios-context-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ios-context-menu-item:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.15);
}

/* ==========================================
   13. PROGRESS BAR (iOS Style)
   ========================================== */

.ios-progress {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.ios-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
    transition: width var(--duration-smooth) var(--spring-snappy);
    position: relative;
}

.ios-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progressShimmer 2s ease-in-out infinite;
}

@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ==========================================
   14. FLOATING ACTION BUTTON (iOS Style)
   ========================================== */

.ios-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(156, 39, 176, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transform: scale(0);
    animation: fabPop var(--duration-fluid) var(--spring-bouncy) forwards;
    transition: all var(--duration-smooth) var(--spring-snappy);
    z-index: 1000;
}

@keyframes fabPop {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

.ios-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 40px rgba(156, 39, 176, 0.6);
}

.ios-fab:active {
    transform: scale(0.9);
}

/* ==========================================
   15. PULL TO REFRESH (iOS Style)
   ========================================== */

.ios-pull-refresh {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    opacity: 0;
    transition: all var(--duration-smooth) var(--spring-snappy);
}

.ios-pull-refresh.pulling {
    opacity: 1;
    top: 10px;
}

.ios-pull-refresh-spinner {
    width: 100%;
    height: 100%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   16. CHIP/TAG (iOS Style)
   ========================================== */

.ios-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    font-size: 0.875rem;
    transition: all var(--duration-quick) var(--spring-snappy);
    cursor: pointer;
}

.ios-chip:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.ios-chip:active {
    transform: scale(0.95);
}

.ios-chip .close {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--duration-quick) var(--spring-snappy);
}

.ios-chip .close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ==========================================
   17. SEGMENTED CONTROL (iOS Style)
   ========================================== */

.ios-segmented {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 2px;
    position: relative;
}

.ios-segmented-item {
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--duration-smooth) var(--spring-snappy);
    z-index: 1;
}

.ios-segmented-item.active {
    color: var(--text-primary);
}

.ios-segmented-indicator {
    position: absolute;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    transition: all var(--duration-smooth) var(--spring-elastic);
    z-index: 0;
}

/* ==========================================
   18. PARALLAX SCROLL EFFECT
   ========================================== */

.ios-parallax {
    transform: translateZ(0);
    will-change: transform;
    transition: transform 0.1s linear;
}

/* ==========================================
   19. GLASSMORPHISM ENHANCEMENTS
   ========================================== */

.ios-glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

.ios-glass-light {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
}

.ios-glass-heavy {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
}

/* ==========================================
   20. UTILITY ANIMATIONS
   ========================================== */

.ios-fade-in {
    animation: fadeIn var(--duration-smooth) var(--spring-smooth);
}

.ios-slide-up {
    animation: slideUp var(--duration-smooth) var(--spring-elastic);
}

@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.ios-bounce {
    animation: bounce var(--duration-fluid) var(--spring-bouncy);
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.ios-pulse {
    animation: pulse 2s var(--spring-smooth) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ==========================================
   21. RESPONSIVE TOUCH FEEDBACK
   ========================================== */

@media (hover: none) and (pointer: coarse) {
    /* Mobile touch optimizations */
    .ios-button:active,
    .ios-card:active,
    .ios-list-item:active {
        transform: scale(0.96);
        transition: transform 0.1s var(--spring-smooth);
    }
}

/* ==========================================
   22. REDUCE MOTION (Accessibility)
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
