/* =====================================================================
   APPLE-STYLE ANIMATIONS
   Hub Insight Capital - Animações inspiradas no design system da Apple
   ===================================================================== */

/* ============================================
   1. VIEW TRANSITIONS - Fade + Slide Up
   ============================================ */

/* Animação de entrada para views */
@keyframes viewEnterIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.view-animate-in {
    animation: viewEnterIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Staggered entrance for child cards/sections within a view */
.view-animate-in > .card,
.view-animate-in > .home-kpi-card,
.view-animate-in > div > .card,
.view-animate-in > .grid-stack {
    animation: cardStaggerIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.view-animate-in > .card:nth-child(1),
.view-animate-in > div > .card:nth-child(1) { animation-delay: 0.06s; }
.view-animate-in > .card:nth-child(2),
.view-animate-in > div > .card:nth-child(2) { animation-delay: 0.12s; }
.view-animate-in > .card:nth-child(3),
.view-animate-in > div > .card:nth-child(3) { animation-delay: 0.18s; }
.view-animate-in > .card:nth-child(4),
.view-animate-in > div > .card:nth-child(4) { animation-delay: 0.24s; }

@keyframes cardStaggerIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ============================================
   2. MODAL - Backdrop Blur + Scale
   ============================================ */

.modal-overlay.show {
    background-color: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: modalOverlayIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-overlay.show .modal-content {
    animation: modalContentIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

@keyframes modalOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalContentIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Modal close button spring */
.modal-header .modal-close {
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.1) !important;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.modal-header .modal-close:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.1);
}


/* ============================================
   3. BUTTONS - Press Feedback (Spring)
   ============================================ */

.btn-primary,
.btn-secondary,
.modal-btn-primary,
.modal-btn-secondary,
.login-button {
    position: relative;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease,
                background-color 0.2s ease,
                border-color 0.2s ease !important;
}

.btn-primary:hover,
.modal-btn-primary:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 15px rgba(204, 255, 0, 0.25);
}

.btn-primary:active,
.modal-btn-primary:active {
    transform: scale(0.95) !important;
    transition-duration: 0.1s !important;
}

.btn-secondary:hover,
.modal-btn-secondary:hover {
    transform: scale(1.03);
}

.btn-secondary:active,
.modal-btn-secondary:active {
    transform: scale(0.95) !important;
    transition-duration: 0.1s !important;
}

/* Ripple effect */
.btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}


/* ============================================
   4. CARDS - Hover Spring
   ============================================ */

.home-kpi-card {
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.4s ease,
                border-color 0.3s ease;
}

.home-kpi-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(204, 255, 0, 0.2);
}

.home-kpi-card:active {
    transform: translateY(-1px) scale(0.98);
    transition-duration: 0.1s;
}


/* ============================================
   5. DROPDOWN - Context Menu Style
   ============================================ */

.metric-menu-dropdown.show,
.apple-dropdown.show {
    animation: dropdownScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
    transform-origin: top right;
}

@keyframes dropdownScaleIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.metric-menu-item,
.apple-dropdown-item {
    border-radius: 0.5rem;
    transition: background 0.15s ease !important;
}

.metric-menu-item:hover,
.apple-dropdown-item:hover {
    background: rgba(204, 255, 0, 0.1) !important;
}


/* ============================================
   6. TOAST NOTIFICATIONS - Apple Style
   ============================================ */

.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.apple-toast {
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color, #222222);
    border-radius: 0.875rem;
    padding: 0.875rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    min-width: 280px;
    max-width: 400px;
    animation: toastIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto;
}

.apple-toast.exit {
    animation: toastOut 0.35s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.apple-toast .toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.apple-toast .toast-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: #ffffff;
}

.apple-toast .toast-sub {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 2px;
}

.apple-toast .toast-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    margin-left: auto;
    flex-shrink: 0;
    transition: color 0.2s ease;
    line-height: 1;
}

.apple-toast .toast-close:hover {
    color: #fff;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
}


/* ============================================
   7. SKELETON LOADING - Shimmer
   ============================================ */

.skeleton {
    background: linear-gradient(90deg,
        var(--border-color, #222222) 25%,
        rgba(255, 255, 255, 0.05) 50%,
        var(--border-color, #222222) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    background: var(--bg-secondary, #111111);
    border: 1px solid var(--border-color, #222222);
    border-radius: 1rem;
    padding: 1.25rem;
}

.skeleton-circle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.skeleton-line {
    height: 12px;
    margin-bottom: 0.5rem;
}

.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-line.tall { height: 24px; width: 50%; margin-bottom: 0.75rem; }


/* ============================================
   8. PROGRESS BAR - Smooth with Shine
   ============================================ */

.apple-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color, #222222);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.apple-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dark, #88CC00), var(--accent-color, #CCFF00));
    border-radius: 999px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.apple-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}


/* ============================================
   9. SEGMENTED CONTROL - iOS Style
   ============================================ */

.apple-segmented {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 0.625rem;
    padding: 3px;
    position: relative;
}

.apple-segmented-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    background: none;
    color: var(--text-muted, #666666);
    font-size: 0.825rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: color 0.25s ease;
    font-family: inherit;
    position: relative;
    z-index: 1;
}

.apple-segmented-btn.active {
    color: var(--text-primary, #ffffff);
}

.segmented-indicator {
    position: absolute;
    top: 3px;
    height: calc(100% - 6px);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    transition: left 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}


/* ============================================
   10. LIST ITEMS - Hover + Stagger Entrance
   ============================================ */

.list-animate .apple-list-item {
    opacity: 0;
    transform: translateX(-15px);
}

.list-animate.animate .apple-list-item {
    animation: listSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.list-animate.animate .apple-list-item:nth-child(1) { animation-delay: 0s; }
.list-animate.animate .apple-list-item:nth-child(2) { animation-delay: 0.05s; }
.list-animate.animate .apple-list-item:nth-child(3) { animation-delay: 0.05s; }
.list-animate.animate .apple-list-item:nth-child(4) { animation-delay: 0.15s; }
.list-animate.animate .apple-list-item:nth-child(5) { animation-delay: 0.2s; }

@keyframes listSlideIn {
    from {
        opacity: 0;
        transform: translateX(-15px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}


/* ============================================
   11. TOGGLE SWITCH - iOS Style
   ============================================ */

.apple-toggle {
    width: 51px;
    height: 31px;
    background: #39393d;
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    border: none;
    padding: 0;
    transition: background 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.apple-toggle.on {
    background: var(--accent-color, #CCFF00);
}

.apple-toggle::after {
    content: '';
    position: absolute;
    width: 27px;
    height: 27px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.apple-toggle.on::after {
    transform: translateX(20px);
}


/* ============================================
   12. BADGE BOUNCE
   ============================================ */

.badge-pulse {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0 6px;
    animation: badgeBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes badgeBounceIn {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}


/* ============================================
   13. GLOBAL SMOOTH TRANSITIONS
   ============================================ */

/* Suavizar inputs globalmente */
input:focus,
select:focus,
textarea:focus {
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

/* Menu links - smooth color transitions */
.menu-link {
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Sidebar smooth */
.app-menu {
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                min-width 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
